Advertisement
Advertisement

More Related Content

Advertisement

Recently uploaded(20)

Teach a Dog to REST

  1. Teach a Dog to REST Brian Mulloy @landlessness Apigee @apigee
  2. 20%
  3. Application developers are kingmakers.
  4. Make your API easy to learn.
  5. Good APIs are a design problem.
  6. Idempotent methods
  7. I won’t say things like that.
  8. Let’s look at puppies.
  9. hackett hackett hackett hackett
  10. ... /getAllDogs /locationVerify /foodNeeded /createRecurringDogWalk /giveDirectOrder /healthCheck /getRecurringDogWalkSchedule /getLocation /getDog /massDogParty /getNewDogsSince /getRedDogs /getSittingDogs /dogStateChangesSearch /replaceSittingDogsWithRunningDogs /saveDog ...
  11. A puppy’s world is big.
  12. JnL law_keven Smithsonian's National Zoo hackett
  13. ... ... /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 ... ...
  14. We are on a slippery slope.
  15. Keep the simple things simple.
  16. Hopkinsii
  17. We only need two URLs.
  18. The first is for a collection.
  19. /dogs
  20. The second is for an element.
  21. /dogs/bo
  22. POST GET PUT DELETE
  23. CREATE READ UPDATE DELETE
  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 if exists treat as a update Bo collection /dogs/bo show Bo delete Bo create new if not dog in it create Bo Wikipedia
  25. 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
  26. 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
  27. Verbs are bad.
  28. Nouns are good.
  29. Plurals are better.
  30. What about associations?
  31. GET /owners/bob/dogs POST /owners/bob/dogs
  32. What about complex variations?
  33. Cody Simms
  34. Sweep variations under the ‘?’
  35. /dogs?color=red&state=running&location=park
  36. What about pagination?
  37. Facebook offset limit Twitter page rpp LinkedIn start count
  38. /dogs?limit=25&offset=50
  39. What about searching?
  40. Global /search?q=fluffy+dog Scoped /owners/bob/dogs/search?q=fluffy
  41. What about versioning?
  42. Twilio /2010-04-01/Accounts/ salesforce.com /services/data/v20.0/sobjects/Account Facebook ?v=1.0
  43. /v1/dogs
  44. Please give me exactly what I need.
  45. LinkedIn /people:(id,first-name,last-name,industry) Facebook /joe.smith/friends?fields=id,name,picture Google (partial response) ?fields=title,media:group(media:thumbnail)
  46. /dogs?fields=name,color,location
  47. What about formats?
  48. Google Data ?alt=json Foursquare /venue.json Digg* Accept: application/json ?type=json * The type argument, if present, overrides the Accept header.
  49. /dogs.json /dogs/bo.json
  50. What about partial updates?
  51. What about errors?
  52. meredithfarmer
  53. Facebook HTTP Status Code: 200 {"type":"OAuthException","message":"(#803) Some of the aliases you requested do not exist: foo.bar"} Twilio HTTP Status Code: 401 {"status":401,"message":"Authenticate","code": 20003,"more_info":"http://www.twilio.com/docs/ errors/20003"} SimpleGeo HTTP Status Code: 401 {"code":401,"message":"Authentication Required"}
  54. Code for code 200 - OK 401 - Unauthorized http://en.wikipedia.org/wiki/List_of_HTTP_status_codes Message for people {“message” : “Verbose, plain language description of the problem with hints about how to fix it.” “more_info” : “http://dev.teachdogrest.com/ errors/12345”}
  55. What about the rest of the URL?
  56. Facebook graph.facebook.com api.facebook.com developers.facebook.com Foursquare api.foursquare.com developers.foursquare.com Twitter api.twitter.com search.twitter.com stream.twitter.com dev.twitter.com
  57. API gateway api.teachdogrest.com Developer connection dev.teachdogrest.com Do web redirects api ! dev developers ! dev developer ! dev
  58. What about defaults?
  59. Format json Pagination (depends on data size) limit=10&offset=0
  60. What about exceptional stuff?
  61. Client intercepts HTTP error codes
  62. Twitter /public_timelines.json? suppress_response_codes=true HTTP Status Code: 200 {"error" : "Could not authenticate you." }
  63. Always returns OK /dogs?suppress_response_codes=true Code for code ignoring 200 - OK Message for people code {“response_code” : “401”, “message” : “Verbose, plain language description of the problem with hints about how to fix it.” “more_info” : “http://dev.teachdogrest.com/ errors/12345”, “code” : 12345}
  64. Client supports limited HTTP methods
  65. Method Parameter create /dogs?method=post read /dogs update /dogs/bo?method=put&location=park delete /dogs/bo?method=delete
  66. Really? All of this? And iterate it?
  67. Application API Virtualization Layer API API API
  68. Be RESTful Only 2 URLs No verbs Use nouns as plurals Sweep complexity behind the ‘?’ Borrow from leading APIs Account for exceptional clients Add virtualization layer
  69. THANK YOU Questions and ideas to: Brian Mulloy @landlessness brian@apigee.com

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
Advertisement