Teach a Dog to REST

190,304 views
191,336 views

Published on

this is an old version. new version here: http://blog.apigee.com/detail/slides_for_restful_api_design_second_edition_webinar/

It's been 10 years since Fielding first defined REST. So, where are all the elegant REST APIs? While many claim REST has arrived, many APIs in the wild exhibit arbitrary, productivity-killing deviations from true REST. We'll start with a typical poorly-designed API and iterate it into a well-behaved RESTful API.

7 Comments
171 Likes
Statistics
Notes
No Downloads
Views
Total views
190,304
On SlideShare
0
From Embeds
0
Number of Embeds
75
Actions
Shares
0
Downloads
1,239
Comments
7
Likes
171
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Teach a Dog to REST

    1. 1. Teach a Dog to RESTBrian Mulloy@landlessnessApigee@apigee
    2. 2. Application developers are kingmakers.
    3. 3. Make your API easy to learn.
    4. 4. Good APIs are a design problem.
    5. 5. Idempotent methods
    6. 6. I won’t say things like that.
    7. 7. Let’s look at puppies.
    8. 8. hackett hacketthackett hackett
    9. 9. .../getAllDogs/locationVerify/foodNeeded/createRecurringDogWalk/giveDirectOrder/healthCheck/getRecurringDogWalkSchedule/getLocation/getDog/massDogParty/getNewDogsSince/getRedDogs/getSittingDogs/dogStateChangesSearch/replaceSittingDogsWithRunningDogs/saveDog...
    10. 10. A puppy’s world is big.
    11. 11. JnL law_kevenSmithsonians National Zoo hackett
    12. 12. ... .../getAllDogs /getAllLeashedDogs/verifyLocation /verifyVeterinarianLocation/feedNeeded /feedNeededFood/createRecurringWakeUp /createRecurringMedication/giveDirectOrder /doDirectOwnerDiscipline/checkHealth /doExpressCheckupWithVeterinarian/getRecurringWakeUpSchedule /getRecurringFeedingSchedule/getLocation /getHungerLevel/getDog /getSquirrelChasingPuppies/newDog /newDogForOwner/getNewDogsSince /getNewDogsAtKennelSince/getRedDogs /getRedDogsWithoutSiblings/getSittingDogs /getSittingDogsAtPark/setDogStateTo /setLeashedDogStateTo/replaceSittingDogsWithRunningDogs /replaceParkSittingDogsWithRunningDogs/saveDog /saveMommaDogsPuppies... ...
    13. 13. We are on a slippery slope.
    14. 14. Keep the simple things simple.
    15. 15. Hopkinsii
    16. 16. We only need two URLs.
    17. 17. The first is for a collection.
    18. 18. /dogs
    19. 19. The second is for an element.
    20. 20. /dogs/bo
    21. 21. POSTGETPUTDELETE
    22. 22. CREATEREADUPDATEDELETE
    23. 23. Resource POST GET PUT DELETE create read update delete replace create a delete all /dogs list dogs dogs with new dog dogs new dogs if exists treat as a update Bo collection/dogs/bo show Bo delete Bo create new if not dog in it create Bo Wikipedia
    24. 24. Resource POST GET PUT DELETE create read update delete replace create a delete all /dogs list dogs dogs with new dog dogs new dogs treat as a if exists collection update Bo/dogs/bo create show Bo delete Bo new dog if not in it create Bo Wikipedia
    25. 25. Resource POST GET PUT DELETE create read update delete bulk create a delete all /dogs list dogs update new dog dogs dogs if exists update Bo/dogs/bo error show Bo delete Bo if not error Wikipedia
    26. 26. Verbs are bad.
    27. 27. Nouns are good.
    28. 28. Plurals are better.
    29. 29. What about associations?
    30. 30. GET /owners/obama/dogsPOST /owners/obama/dogs
    31. 31. What about complex variations?
    32. 32. Cody Simms
    33. 33. Sweep variations under the ‘?’.
    34. 34. /dogs?color=red&state=running&location=park
    35. 35. What about pagination?
    36. 36. FacebookoffsetlimitTwitterpagerppLinkedInstartcount
    37. 37. /dogs?limit=25&offset=50
    38. 38. What about versioning?
    39. 39. Twilio/2010-04-01/Accounts/salesforce.com/services/data/v20.0/sobjects/AccountFacebook?v=1.0
    40. 40. /v1/dogs
    41. 41. Please give me exactly what I need.
    42. 42. LinkedIn/people:(id,first-name,last-name,industry)Facebook/joe.smith/friends?fields=id,name,pictureGoogle (partial response)?fields=title,media:group(media:thumbnail)
    43. 43. /dogs?fields=name,color,location
    44. 44. What about formats?
    45. 45. Google Data?alt=jsonFoursquare/venue.jsonDiggContent-Type: application/json?type=json
    46. 46. /dogs.json/dogs/bo.json
    47. 47. What about the rest of the URL?
    48. 48. Facebook graph.facebook.com api.facebook.com developers.facebook.comFoursquare api.foursquare.com developers.foursquare.com Twitter api.twitter.com search.twitter.com stream.twitter.com dev.twitter.com
    49. 49. API gatewayapi.teachdogrest.comDeveloper connectiondev.teachdogrest.comDo web redirectsapi ! devdevelopers ! devdeveloper ! dev
    50. 50. Be RESTfulOnly 2 URLsNo verbsUse nouns as pluralsSweep complexity behind the ‘?’Borrow from leading APIs
    51. 51. THANK YOUQuestions and ideas to:Brian Mulloy@landlessnessbrian@apigee.com

    ×