5.
REST APIs Example Scenario Pitfalls of REST Design More Leveraging HTTP REST Examples
What is REST?
Roy Fielding, “Father” of REST
REST is a coordinated set of architectural
constraints that attempts to minimize latency and
network communication while at the same time
maximizing the independence and scalability of
component implementations. This is achieved by
placing constraints on connector semantics where
other styles have focused on component semantics.
REST enables the caching and reuse of
interactions, dynamic substitutability of
components, and processing of actions by
intermediaries, thereby meeting the needs of an
Internet-scale distributed hypermedia system.
Service-Oriented Architecture | Representational State Transfer (REST) and HATEOAS
5/84

6.
REST APIs Example Scenario Pitfalls of REST Design More Leveraging HTTP REST Examples
What is REST?
REST is not a standard
REST is not a protocol
REST is an architectural style for networked applications
REST deﬁnes a set of simple principles
(loosely followed by most API implementations)
Service-Oriented Architecture | Representational State Transfer (REST) and HATEOAS
6/84

15.
REST APIs Example Scenario Pitfalls of REST Design More Leveraging HTTP REST Examples
Manipulation of Resources
Creating a Resource
creates a new resource
But the server decides on that resources URI
Examples
POST
WWW: Posting to Web log
→ Server decides URI of posting
and any comments made on that post
Programmatic service: Creating a new employee record
Service-Oriented Architecture | Representational State Transfer (REST) and HATEOAS
16/84

16.
REST APIs Example Scenario Pitfalls of REST Design More Leveraging HTTP REST Examples
Manipulation of Resources
Safe Methods
Any client should be able to make the request
. . . as many times as necessary
GET, OPTIONS, HEAD
Service-Oriented Architecture | Representational State Transfer (REST) and HATEOAS
17/84

28.
REST APIs Example Scenario Pitfalls of REST Design More Leveraging HTTP REST Examples
HATEOAS
This is the hardest and of course,
most important part of REST
. . . But it makes the API “explorable”!
Service-Oriented Architecture | Representational State Transfer (REST) and HATEOAS
29/84

29.
Image used under Creative Commons from oliverkendal http://flickr.com/oliverkendal/

30.
REST APIs Example Scenario Pitfalls of REST Design More Leveraging HTTP REST Examples
Links
Use links to allow clients to
discover locations and operations
Link relations are used to express options
Clients do not need to know URLs
This controls the state
Service-Oriented Architecture | Representational State Transfer (REST) and HATEOAS
31/84

77.
REST APIs Example Scenario Pitfalls of REST Design More Leveraging HTTP REST Examples
Conclusion
Web-based services are about state machines
and business protocols
→ The HATEOAS constraint from REST
What can be called “RESTful” depends on who you ask
(it’s not a formally accepted deﬁnition)
Some say: You are not RESTful without hypermedia
I say: REST is about Representational State Transfer,
and hypermedia is an add-on (though very important)
There are still good APIs without hypermedia
(e. g. Amazon S3)
There are very bad APIs (pretending to be RESTful)
(e. g. Twitter API)
If in doubt, certain APIs can be considered “RESTish”
Certain ones are deﬁnitely no more than RESTish!
Service-Oriented Architecture | Representational State Transfer (REST) and HATEOAS
78/84

79.
REST APIs Example Scenario Pitfalls of REST Design More Leveraging HTTP REST Examples
Comparison REST vs. SOAP
Both are request/response type services
SOAP is more an RPC-style API (procedures with verb)
REST is about REST (duh!)
SOAP has strictly deﬁned interfaces,
and the communication can be veriﬁed
REST is more about evolving APIs,
and making them explorable through hypermedia
Bells’n’whistles in SOAP, but can be found in REST
(less obvious, less used: WADL, JSON schema, . . . )
Use . . .
SOAP for well managed “corporate-style” consumers
REST for many, less-deﬁned “citizen consumers”
REST if the API is likely to evolve
Service-Oriented Architecture | Representational State Transfer (REST) and HATEOAS
80/84

82.
THANKS TO
KIWI PYCON
AUCKLAND 2013
THE YEAR OF THE SNAKE
Kiwi PyCon 2013 will
be held at Auckland
University of
Technology's new
Sir Paul Reeves
Building, also
known as building
AKL
SIMPLICITY
WG at AUT's city
campus.
SEPTEMBER
FLEXIBILITY
BEAUTY
6-8
New Zealand's premier Python event of the year
http://nz.pycon.org/

83.
Questions?
Image used under Creative Commons from Boston Public Library
http://flickr.com/boston_public_library/