Slide 1

Slide 1 text

REST 101 Learning the core concepts of REST APIs

Slide 2

Slide 2 text

Agenda • Webservices • Resources • REST concepts

Slide 3

Slide 3 text

Webservices • Expose some operations in a remote system • Enable infrastructure decoupling • Example: • Almost everything! • Different specifications and implementations

Slide 4

Slide 4 text

REST Webservices • Things vs. Actions • Nouns vs. Verbs • Vs. SOAP and RPC

Slide 5

Slide 5 text

Resources • Abstractions of a ‘thing’ in the system • E.g. User resource • Identified by one or more URIs • E.g. api.system.com/v1/users/1 • Differ from their representation • The same resource can have multiple representations • Representation • How the resources are manipulated • Typically XML or JSON

Slide 6

Slide 6 text

REST concepts • Uniform Interface • Decouple the architecture • Elements: • HTTP verbs (GET, PUT, POST, DELETE, …) • URIs (resource naming) • HTTP responses (body + status code) • Stateless • Server doesn’t store any client state • Each request contains enough information to be processed • Any session state is kept in the client • Others (check this link)

Slide 7

Slide 7 text

REST concepts • Safe operations • Read-only, don’t modify resources in the server • GET, HEAD, OPTIONS • Idempotency • PUT and DELETE operations should be implemented as idempotents • Executing the same request multiple times leaves the system in the same state as the first call (the response may be different though) • E.g. deleting a user vs. creating a user • Hypermedia • Finite-state machine • Resources and manipulations

Slide 8

Slide 8 text

References • Roy Fielding doctoral dissertation that defines the basis of REST • http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm • Good website with a lot of material about the topic • http://www.restapitutorial.com • A post blog written by me about REST semantics • http://www.lucassaldanha.com/its-all-about-semantics/ • The REST Cook Book – has some nice material • http://restcookbook.com • Good post about REST • https://jcalcote.wordpress.com/2008/10/16/put-or-post-the-rest-of-the-story/