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

Web API

Web API

Talk about Web APIs - Medellin.rb

Jean Pierre

July 08, 2015
Tweet

More Decks by Jean Pierre

Other Decks in Programming

Transcript

  1. Web API • Interface for exposing your data or a

    service to different users. • Is a HTTP request that the interface responds with a JSON or XML message. • Considered a synonym for “web service”
  2. Web API History • Salesforce - Feb 7, 2000 with

    XML responses • Ebay - Nov 20, 2000, licensed eBay partners and developers. • Amazon - July 16, 2002, third parties, XML • Flickr - February 2004, open to the public, XML • Facebook - August 15th 2006, Version 1.0 • Twitter - September 20, 2006 • Google Maps, Amazon S3, Foursquare, Instagram…
  3. REST • Representational state transfer • Architecture style that use

    HTTP requests to access a collection or a specific resource. • Constraints: Client–server, Stateless, Cacheable, Layered system, Code on demand (optional), Uniform interface
  4. List of status code • 200 OK • 201 Created

    • 202 Accepted • 400 Bad Request • 401 Unauthorized • 403 Forbidden • 404 Not Found • 500 Internal Server Error
  5. API Versioning • In order to allow breaking changes to

    an interface, we can version it so that clients may specify exactly what representation they expect for their requests.
  6. Basic access authentication • Doesn’t require cookies, sessions, identifier or

    login page. • Encodes in base 64 the credentials: Base64.encode64(‘medellinrb:api') • Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=
  7. Token authentication • An API client uses a token identifier

    to make authenticated HTTP requests. • Tokens can be regenerated without changing the password • If the token is compromised only the API access is vulnerable, not the master account. • Can generate different permissions per token.
  8. References • https://en.wikipedia.org/wiki/Application_programming_interface#Web_APIs • http://apievangelist.com/2012/12/20/history-of-apis/ • http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm • https://www.facebook.com/notes/facebook/facebook-development-platform- launches/2207512130

    • http://guides.rubyonrails.org/routing.html • http://rest.elkstein.org/ • http://mark-kirby.co.uk/2013/creating-a-true-rest-api/ • https://www.codeschool.com/blog/2014/02/03/token-based-authentication-rails/