Upgrade to Pro — share decks privately, control downloads, hide ads and more …

APIs - the good, the bad and the ugly

Avatar for Nikhil Bendre Nikhil Bendre
September 14, 2014

APIs - the good, the bad and the ugly

This session would describe what are the best practices of writing RESTful APIs. What are the different tools to create and test these APIs? What are the common pitfalls and how to avoid them? What are some of the industries best public APIs, etc. This session might also include a quick and easy hands-on session to fire and launch some APIs in the cloud using Play! Framework.

Avatar for Nikhil Bendre

Nikhil Bendre

September 14, 2014

Other Decks in Technology

Transcript

  1. HTTP/1.1! Server:! 200 OK! nginx! Date:"Wed, 14 Content-Type:! Sep 2014

    14:03:33! application/json;! GMT! charset=utf-8! Connection: Status: 200! keep-alive OK! ETag:! "ef742caec0c19e2169ffb05e7d200d17"! Last-Modified: Sat, 13 Sep 2014 10:52:21 GMT! {! }! "talk": apis – the good, the bad & the ugly,! "name” : nikhil bendre,! "twitter” : @npbendre,! “site”: npbendre.com!
  2. API

  3. HTTP/1.1! Server:! 200 OK! nginx! Date:"Wed, 14 Content-Type:! Sep 2014

    14:03:33! application/json;! GMT! charset=utf-8! Connection: Status: 200! keep-alive OK! ETag:! "ef742caec0c19e2169ffb05e7d200d17"! Last-Modified: Sat, 13 Sep 2014 10:52:21 GMT! ! {! }! GET https://api.example.com/user/8913   "talk": apis – the good, the bad & the ugly,! "name” : nikhil bendre,! "twitter” : @npbendre,! “site”: npbendre.com!
  4. HTTP/1.1! Server:! 200 OK! nginx! Date:"Wed, 14 Content-Type:! Sep 2014

    14:03:33! application/json;! GMT! charset=utf-8! Connection: Status: 200! keep-alive OK! ETag:! "ef742caec0c19e2169ffb05e7d200d17"! Last-Modified: Sat, 13 Sep 2014 10:52:21 GMT! ! {! }! GET https://api.example.com/user/1234   "talk": apis – the good, the bad & the ugly,! "name” : nikhil bendre,! "twitter” : @npbendre,! “site”: npbendre.com!
  5. HTTP/1.1! Server:! 200 OK! nginx! Date:"Wed, 14 Content-Type:! Sep 2014

    14:03:33! application/json;! GMT! charset=utf-8! Connection: Status: 200! keep-alive OK! ETag:! "ef742caec0c19e2169ffb05e7d200d17"! Last-Modified: Sat, 13 Sep 2014 10:52:21 GMT! ! {! }! GET https://api.example.com/user/1234   "talk": apis – the good, the bad & the ugly,! "name” : nikhil bendre,! "twitter” : @npbendre,! “site”: npbendre.com!
  6. HTTP/1.1! Server:! 200 OK! nginx! Date:"Wed, 14 Content-Type:! Sep 2014

    14:03:33! application/json;! GMT! charset=utf-8! Connection: Status: 200! keep-alive OK! ETag:! "ef742caec0c19e2169ffb05e7d200d17"! Last-Modified: Sat, 13 Sep 2014 10:52:21 GMT! ! {! }! GET https://api.example.com/user/1234   "talk": apis – the good, the bad & the ugly,! "name” : nikhil bendre,! "twitter” : @npbendre,! “site”: npbendre.com!
  7. HTTP/1.1! Server:! 200 OK! nginx! Date:"Wed, 14 Content-Type:! Sep 2014

    14:03:33! application/json;! GMT! charset=utf-8! Connection: Status: 200! keep-alive OK! ETag:! "ef742caec0c19e2169ffb05e7d200d17"! Last-Modified: Sat, 13 Sep 2014 10:52:21 GMT! ! {! }! GET https://api.example.com/user/1234   "talk": apis – the good, the bad & the ugly,! "name” : nikhil bendre,! "twitter” : @npbendre,! “site”: npbendre.com!
  8. HTTP/1.1! Server:! 200 OK! nginx! Date:"Wed, 14 Content-Type:! Sep 2014

    14:03:33! application/json;! GMT! charset=utf-8! Connection: Status: 200! keep-alive OK! ETag:! "ef742caec0c19e2169ffb05e7d200d17"! Last-Modified: Sat, 13 Sep 2014 10:52:21 GMT! ! {! }! GET https://api.example.com/user/1234   "talk": apis – the good, the bad & the ugly,! "name” : nikhil bendre,! "twitter” : @npbendre,! “site”: npbendre.com!
  9. Partially update a resource GET POST PUT DELETE PATCH Retrieve

    resource Create resource Update a resource Delete a resource HEAD Get only the headers
  10. Bad {“error”: “code 782” } Good HTTP 1.1 400 {

    “error” : “field was missing”, “link” : “apidocs.com/400”, }   error response
  11. HTTP/1.1! Server:! 200 OK! nginx! Date:"Wed, 14 Content-Type:! Sep 2014

    14:03:33! application/json;! GMT! charset=utf-8! Connection: Status: 200! keep-alive OK! ETag:! "ef742caec0c19e2169ffb05e7d200d17"! Last-Modified: Sat, 13 Sep 2014 10:52:21 GMT! {! }! “data”: …! Server Response
  12. HTTP/1.1! 304 Not Modified! Date:"Wed, 14! Sep 2014 14:03:33! GMT!

    Last-Modified: Sat, 13 Sep 2014 10:53:21 GMT! Client Request curl -i -H "If-None-Match: \"ef742caec0c19e2169ffb05e7d200d17\"" "https://graph.beta.facebook.com/me/ adaccounts?access_token=___"!
  13. Attributions •  Cat by Marco Petrucci from The Noun Project

    •  Chat by Alberto Guerra Quintanilla from The Noun Project •  Coffee by Monika Ciapala from The Noun Project •  Key by Simple Icons from The Noun Project •  Lock by Jardson A. from The Noun Project •  Magnifying Glass by Naomi Atkinson from The Noun Project •  Gauge by Olivier Guin from The Noun Project •  Lock by Andrew Forrester from The Noun Project •  Fork by Dmitry Baranovskiy from The Noun Project •  Click icon is open source •  Document icon by Joe Richardson from The Noun Project •  Robot icon by Jon Trillana •  Tasks list by Arthur Shlain from The Noun Project •  Graph by David Waschbüsch from The Noun Project •  HTTP cats photo from girliemac •  Photo by Tojosan