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

Let's talk about REST

Jon Anning
November 25, 2013

Let's talk about REST

The spiffiness, the sulkiness, the general interestingness of RESTful APIs and their implementation in today's internet.
High level, just a bit of fun really :)

Jon Anning

November 25, 2013
Tweet

More Decks by Jon Anning

Other Decks in Technology

Transcript

  1. SOAP: COMPLEX <?xml  version="1.0"?>   <soap:Envelope   xmlns:soap="http://www.w3.org/2001/12/soap-­‐envelope"   soap:encodingStyle="http://www.w3.org/2001/12/soap-­‐encoding">

       <soap:body  pb="http://www.acme.com/phonebook">      <pb:GetUserDetails>        <pb:UserID>12345</pb:UserID>      </pb:GetUserDetails>    </soap:Body>   </soap:Envelope>
  2. SOAP: COMPLEX <?xml  version="1.0"?>   <soap:Envelope   xmlns:soap="http://www.w3.org/2001/12/soap-­‐envelope"   soap:encodingStyle="http://www.w3.org/2001/12/soap-­‐encoding">

       <soap:body  pb="http://www.acme.com/phonebook">      <pb:GetUserDetails>        <pb:UserID>12345</pb:UserID>      </pb:GetUserDetails>    </soap:Body>   </soap:Envelope>
  3. SEE ALL OF THEse internet WIDGETS GET  http://awesomewidgets.com/api/widgets   !

    MAKE me A WIDGET, internet POST  http://awesomewidgets.com/api/widgets   Data:          name  =  smash   ! show me this supposed SINGLE WIDGET WITH ID 123 GET  http://awesomewidgets.com/api/widgets/123   ! UPDATE THAT WIDGET UPDATE IT UPDATE ITTTT PUT  http://awesomewidgets.com/api/widgets/123   Data:          name  =  kaboom          color  =  electric  puce   ! DELETE THAT STUPID WIDGET I MEAN WHAT THE HELL internet DELETE  http://awesomewidgets.com/api/widgets/123
  4. jon@raven:~  (ruby-­‐2.0.0-­‐head)   [◦]  % curl  -­‐i  http://coffee.is.local/rest/players HTTP/1.1  200

     OK   Server:  nginx/1.0.11   Date:  Thu,  21  Nov  2013  13:54:06  GMT   Content-­‐Type:  application/json   Connection:  keep-­‐alive   vary:  Accept-­‐Encoding   content-­‐length:  3312   ! [{"_id":"ce185d9a-­‐6e8f-­‐4f82-­‐af52-­‐4f104652c38d","etab":18,"ltab": 0,"name":"Silvia","total":414},{"_id":"799e8aa0-­‐ b346-­‐48ee-­‐8d7f-­‐756d68d34de2","etab":34,"ltab": 1,"name":"Javier","total":481}, {"_id":"c9909966-­‐6d79-­‐4bce-­‐9b46-­‐9a995bbf01b3","etab":4,"ltab":
  5. handily http has a whole bunch of very well understood

    status codes What happens when aN API request goes wrong?
  6. real time sucks. client API anything new? nope. client API

    How about now? nope. client API And now?? widgets!
  7. POST  http://awesomewidgets.com/api/widgets/hooks   Data:           myApp

     =  widgetfu           Callback  =  http://widgetfu.com/api/widgets/track   hipster api