2. Overview
• Roy Fielding’s Vision
• ReST = URI + HTTP + Hypermedia
• API Design
• Success Stories
• Q & A
3. ReST for a minute
What: Representational State Transfer (REST) architectural style
Who: Roy Thomas Fielding
When: 2000
Where: Chapter 5, Ph.D. dissertation: “Architectural Styles and the Design of Network-based Software Architectures”
Why: need for blueprints to guide the design and development of the architecture for the modern Web
• scalable component interactions
• general and uniform interfaces
• self-descriptive representations
• independent deployable components
• reduced interaction latency
• enforced security
• able to encapsulate legacy systems
How: HTTP + URI + (Client Pull - Resolver - [Cache] - Stateless [Tunnel] - Server ) = ULCODC$SS
4. Patterns
• (Uniform) Pipe and Filters
• Replicated Repository
• Cache$
• Client Server
• Layered Systems
• Remote Session
• Remote Data Access
• Mobile Code Styles
• Virtual Machine
• Remote Evaluation
• Code on Demand
• Mobile Agent
• Event-based Integration
• (Brokered) Distributed Objects
10. Data Structure
Data Element Examples
resource conceptual target of a hypertext reference
resource identifier URI (URN or URL)
resource metadata source link, alternates, vary, …
representation HTML, XML, JSON, JPG,…
representation metadata media-type, last-modified,…
control data if-modified-since, cache-control,…
14. 7 Steps to API design
1.List all data elements clients might need
2.Draw state diagrams (actions)
3.Reconcile Magic Strings (schema.org, DC, FOAF,…)
4.Select Media-types (html, xml, json, csv, hdf5,…)
5.Create a semantic profile (WSDL, WADL, APP, RAML,
Swagger,/ALPS,Json-LD, Json-Schema Hydra)
6. Write the code
7.Publish the API
from A Web API Design Methodology - Mike Amundsen
15. Some RESTful APIs
• Amazon S3
• Google DoubleClick Ad Exchange Buyer
• Google YouTube
• Twitter
• Twilio Voice and SMS
• Netflix API (2014/11)
• Facebook Graph
• EMC Isilon OneFS
16. Isilon REST API Example
The following request creates an access point named 'accesspoint1' on the namespace.
PUT /namespace/accesspoint1 HTTP/1.1
Host my_cluster:8080
Date: Fri, 15 Mar 2013 21:51:50 GMT
Content-Type: text/xml
{
"path": “/ifs/home/"
}
Example response
HTTP/1.1 200 OK
Date: Fri, 15 Mar 2013 21:51:50 GMT
Server: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8x
Allow: DELETE, GET, HEAD, POST, PUT, OPTIONS
x-isi-ifs-spec-version: 1.0
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=15, max=335
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/plain
17. Facebook Graph API - https://developers.facebook.com/tools/explorer
The Graph API is the primary way to get data in and out of Facebook's
platform. It's a low-level HTTP-based API that you can use to query
data, post new stories, manage ads, upload photos and a variety of
other tasks that an app might need to do
28. Business Perspective
from eMag Web APIs from Start to Finish
"As a result of Data Enabled Disruption, many
of Amazon’s former competitors are now dead.
By utilizing APIs at all points of the data
lifecycle, Amazon is able to continuously
improve the accuracy, applicability, and
accessibility of its data. "
29. Jeff Bezos
As Yegge's recalls that one day Jeff Bezos issued a mandate, sometime back around
2002 (give or take a year):
All teams will henceforth expose their data and functionality through service
interfaces.
Teams must communicate with each other through these interfaces.
There will be no other form of inter-process communication allowed: no direct linking,
no direct reads of another team’s data store, no shared-memory model, no back-doors
whatsoever.
The only communication allowed is via service interface calls over the network.
It doesn’t matter what technology they use.
All service interfaces, without exception, must be designed from the ground up to be
externalizable. That is to say, the team must plan and design to be able to expose the
interface to developers in the outside world. No exceptions.
Anyone who doesn’t do this will be fired. Thank you; have a nice day!
from http://apievangelist.com/2012/01/12/the-secret-to-amazons-success-internal-apis/
30. References
REST API Design Rulebook
Mark Masse (2011)
RESTful Web APIs
Leonard Richardson and Mike Amundsen
(2013)
REST APIs must be hypertext- driven
Roy T. Fielding: Untangled (2008)
RESTful Web Services
Leonard Richardson and Sam Ruby (2008)
HTTP Developer’s Handbook
Chris Shiflett (2003)
RESTful Web Services Cookbook
Subbu Allamaraju (2010)
Building Hypermedia APIs with HTML5 and Node
Mike Amundsen (2011)
31. Thank you.
Rodrigo Dias Arruda Senra
rodrigo.senra@emc.com
http://rodrigo.senra.nom.br
@rodsenra