0
API REST for beginners...
...or why I should care about building an
understandable API
POST /hello-world
Javier Lafora
(@eLafo)
A small walk through historyA small walk through history
Web of documents
Widgets
Web scraping
SOAP
Mashups
http://cartodb.github.io/lisbon-2014/#/2/24.7/-7.0/0
Internet of Things
Internet of everything
Same app on multiple devices
http://www.mediabistro.com/alltwitter/api-billionaires-club_b11424
http://www.programmableweb.com/news/9000-apis-mobile-gets-serious/2013/04/30
http://apiux.com/2013/05/29/api-hierarchy-needs/
https://www.lordabbett.com/content/lordabbett/en/perspectives/equityperspectives/finding-growth-
http://www.zdnet.com/internet-of-things-8-9-trillion-market-in-2020-212-billion-connected-things-7000021516/
Dissecting an HTTP Request
● Method
● Path
● Header
● Body
Methods
GET: Requests a representation of the specified resource
POST: Requests that the server accept the entity enclosed...
GET request
POST request
Dissecting an HTTP response
● Status
● Header
● Body
HTTP response
http://www.slideshare.net/supercoco9/what-is-rest-why-is-it-part-of-the-rails-way-railsconf-2014-jav
Defining an API
What to do...
...with what?
RPC
What to do?
In the body
With what?
In the body
POST /rpc HTTP/1.1
Host: www.upcdatabase.com
User-Agent: XMLRPC::Client...
REST
What to do?
In the HTTP method
With what?
In the path
GET /hello.txt HTTP/1.1
Host: www.example.com
REST-RPC Hybrid
What to do?
In the path
With what?
In the path
GET services/rest?api_key=xxx&method=flickr.photos.search&t...
REST
(Representational
State Transfer)
Roy Fielding
(2000)
Architecture for
the web
Resources
resources
are not
models
Uniform and constrained interface
http://www.ibm.com/developerworks/websphere/techjournal/0903_peterson/0903_peterson.html
REST Principles (some)
Addressability
Addressability
/bands/iron_maiden
/bands/the_beatles
/releases/20140529
/releases/last
Representation oriented
Statelessness
HATEOAS (Hypermedia as the
Engine of Application State)
Use methods and
response statuses well
Make your data format consistent
Versioning
https://invoicefu.com/es/developers/api_docs
https://developers.teowaki.com/api-overview
Questions?
aspgems.com
fin
Thanks
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
API REST for beginners or why you should make your API understandable
Upcoming SlideShare
Loading in...5
×

API REST for beginners or why you should make your API understandable

427

Published on

A brief introduction to REST and some context for newbies in this API world we are building

Published in: Software, Technology, Design
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
427
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "API REST for beginners or why you should make your API understandable"

  1. 1. API REST for beginners... ...or why I should care about building an understandable API
  2. 2. POST /hello-world Javier Lafora (@eLafo)
  3. 3. A small walk through historyA small walk through history
  4. 4. Web of documents
  5. 5. Widgets
  6. 6. Web scraping
  7. 7. SOAP
  8. 8. Mashups
  9. 9. http://cartodb.github.io/lisbon-2014/#/2/24.7/-7.0/0
  10. 10. Internet of Things
  11. 11. Internet of everything
  12. 12. Same app on multiple devices
  13. 13. http://www.mediabistro.com/alltwitter/api-billionaires-club_b11424
  14. 14. http://www.programmableweb.com/news/9000-apis-mobile-gets-serious/2013/04/30
  15. 15. http://apiux.com/2013/05/29/api-hierarchy-needs/
  16. 16. https://www.lordabbett.com/content/lordabbett/en/perspectives/equityperspectives/finding-growth-
  17. 17. http://www.zdnet.com/internet-of-things-8-9-trillion-market-in-2020-212-billion-connected-things-7000021516/
  18. 18. Dissecting an HTTP Request ● Method ● Path ● Header ● Body
  19. 19. Methods GET: Requests a representation of the specified resource POST: Requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the URI PUT: Requests that the enclosed entity be stored under the supplied URI PATCH: Apply partial modifications to a resource DELETE: Deletes the specified resource HEAD: Asks for the response identical to the one that would correspond to a GET request, but without the response body OPTIONS: Returns the HTTP methods that the server supports for the specified URL
  20. 20. GET request
  21. 21. POST request
  22. 22. Dissecting an HTTP response ● Status ● Header ● Body
  23. 23. HTTP response
  24. 24. http://www.slideshare.net/supercoco9/what-is-rest-why-is-it-part-of-the-rails-way-railsconf-2014-jav
  25. 25. Defining an API
  26. 26. What to do...
  27. 27. ...with what?
  28. 28. RPC What to do? In the body With what? In the body POST /rpc HTTP/1.1 Host: www.upcdatabase.com User-Agent: XMLRPC::Client (Ruby 1.8.4) Content-Type: text/xml; charset=utf-8 Content-Length: 158 Connection: keep-alive <?xml version="1.0" ?> <methodCall> <methodName>lookupUPC</methodNa me> ... </methodCall>
  29. 29. REST What to do? In the HTTP method With what? In the path GET /hello.txt HTTP/1.1 Host: www.example.com
  30. 30. REST-RPC Hybrid What to do? In the path With what? In the path GET services/rest?api_key=xxx&method=flickr.photos.search&tags=penguin HTTP/1.1 Host: www.flickr.com
  31. 31. REST (Representational State Transfer) Roy Fielding (2000) Architecture for the web
  32. 32. Resources
  33. 33. resources are not models
  34. 34. Uniform and constrained interface http://www.ibm.com/developerworks/websphere/techjournal/0903_peterson/0903_peterson.html
  35. 35. REST Principles (some)
  36. 36. Addressability
  37. 37. Addressability /bands/iron_maiden /bands/the_beatles /releases/20140529 /releases/last
  38. 38. Representation oriented
  39. 39. Statelessness
  40. 40. HATEOAS (Hypermedia as the Engine of Application State)
  41. 41. Use methods and response statuses well
  42. 42. Make your data format consistent
  43. 43. Versioning
  44. 44. https://invoicefu.com/es/developers/api_docs
  45. 45. https://developers.teowaki.com/api-overview
  46. 46. Questions?
  47. 47. aspgems.com fin Thanks
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×