$30 off During Our Annual Pro Sale. View Details »

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. lets talk about
    @astromoose

    View Slide

  2. mmm, rest

    View Slide

  3. View Slide

  4. sorry

    View Slide

  5. get to the
    point, jon

    View Slide

  6. representational state
    transfer

    View Slide

  7. hark, an fla!

    View Slide

  8. We all use rest
    every day

    View Slide

  9. get
    head
    post
    put
    delete
    trace
    options
    connect
    patch

    View Slide

  10. not a
    standard

    View Slide

  11. not a
    standard
    corba, rpc, soap are standards.

    View Slide

  12. not a
    standard
    corba, rpc, soap are standards.
    and they are also kind of craaaap

    View Slide

  13. SOAP: COMPLEX
     
    xmlns:soap="http://www.w3.org/2001/12/soap-­‐envelope"  
    soap:encodingStyle="http://www.w3.org/2001/12/soap-­‐encoding">  
       
         
         12345  
         
       

    View Slide

  14. SOAP: COMPLEX
     
    xmlns:soap="http://www.w3.org/2001/12/soap-­‐envelope"  
    soap:encodingStyle="http://www.w3.org/2001/12/soap-­‐encoding">  
       
         
         12345  
         
       


    View Slide

  15. REST: SIMPLE
    http://www.acme.com/phonebook/UserDetails/12345

    View Slide

  16. REST: SIMPLE
    http://www.acme.com/phonebook/UserDetails/12345

    View Slide

  17. so, rest
    apis.

    View Slide

  18. so, rest
    apis.
    omg ANOTHER TLA lol

    View Slide

  19. View Slide

  20. Get! put!
    post!
    delete!
    st!
    te!
    Get
    po
    del

    View Slide

  21. 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

    View Slide

  22. jon@raven:~  (ruby-­‐2.0.0-­‐head)  
    [○]  %

    View Slide

  23. jon@raven:~  (ruby-­‐2.0.0-­‐head)  
    [○]  % curl  -­‐i  http://coffee.is.local/rest/players

    View Slide

  24. 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":

    View Slide

  25. What happens when aN API request
    goes wrong?

    View Slide

  26. handily
    What happens when aN API request
    goes wrong?

    View Slide

  27. handily
    http has a whole bunch of very
    well understood status codes
    What happens when aN API request
    goes wrong?

    View Slide

  28. 4xx error
    5xx error
    means i messed up
    means you guys messed up

    View Slide

  29. here comes a bold statement!

    View Slide

  30. rest apis
    are usually
    great
    here comes a bold statement!

    View Slide

  31. documented
    &
    idempotent
    When they are

    View Slide

  32. View Slide

  33. Twitter thrives
    on its clients

    View Slide

  34. Is there anything
    wrong
    with rest?

    View Slide

  35. real time sucks.

    View Slide

  36. real time sucks.
    client API
    anything new?
    nope.

    View Slide

  37. real time sucks.
    client API
    anything new?
    nope.
    client API
    How about now?
    nope.

    View Slide

  38. real time sucks.
    client API
    anything new?
    nope.
    client API
    How about now?
    nope.
    client API
    And now??
    widgets!

    View Slide

  39. have big
    files to
    worry
    about

    View Slide

  40. View Slide

  41. The current hip answer?

    View Slide

  42. The current hip answer?
    client API

    View Slide

  43. The current hip answer?
    client API
    hey hey new widgets!

    View Slide

  44. The current hip answer?
    client API
    woahhhh
    hey hey new widgets!

    View Slide

  45. The current hip answer?
    client API
    woahhhh
    hey hey new widgets!
    resthooks

    View Slide

  46. POST  http://awesomewidgets.com/api/widgets/hooks  
    Data:  
            myApp  =  widgetfu  
            Callback  =  http://widgetfu.com/api/widgets/track  
    hipster api

    View Slide

  47. i guess you're thinking

    View Slide

  48. kthanx jon
    i guess you're thinking

    View Slide

  49. kthanx jon
    but why should we care?
    i guess you're thinking

    View Slide

  50. go forth and build
    internet lego

    View Slide

  51. restcookbook.com
    !
    apiary.io
    !
    sinatrarb.com
    !
    dev.twitter.com
    !
    developer.github.com
    !
    rest.elkstein.org
    !
    zapier.com

    View Slide

  52. CHeerio

    View Slide