The API Facade Pattern: Common Patterns - Episode 2


Published on

Whether you are starting from a green field or brown, in this webinar we'll share common patterns of facades that will help you get your API initiative off the ground.
- Data format mediation
- URL design
- Authorization and versioning

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Creative Commons Attribution-Share Alike 3.0 United States License
  • The API Facade Pattern: Common Patterns - Episode 2

    1. 1. API Façade: Common PatternsEpisode 2Webinar ShortsMarch 2012 SeriesBrian Mulloy Apigee@landlessness @apigee
    2. 2.
    3. 3.
    4. 4. New! IRC Channel #api-craft on freenode
    5. 5. Webinar Shorts - March 2012 New!Episode 1The API Facade: OverviewTuesday, March 6thEpisode 2The API Facade: Common PatternsTuesday, March 13thEpisode 3The API Facade: TechnologyTuesday, March 20thEpisode 4The API Facade: PeopleTuesday, March 27th
    6. 6. Episode 2 Topics• Recap: API façade• Errors• Stubs• URLs• Versioning• Data formats• Internal & external systems
    7. 7. Recap: API Façade
    8. 8. App App Developer API Facade Content Big DB Management JDBC RSS SOAPSystem
    9. 9. One Big Problem 1. Build up from systems of record App XML XML XML XML XML XML1. Objects Tables RSS RSS Tables RSS Content Big DB Management JDBC RSS SOAP System
    10. 10. Three Small Problems 1. Design the Ideal API 2. Implement Design with Stubs as Façade App 3. Mediate between Façade and Systems Developer1. Ideal Design2. API Facade3. Mediate Content Big DB Management JDBC RSS SOAP System
    11. 11. Common patterns
    12. 12. Errors
    13. 13. When I say errors, you say test-driven development.
    14. 14. Errors 200 201 304 400 401 403 404 500{“developerMessage”:“Verbose, plain language descriptionof the problem for the app developer with hints about howto fix it.”,“userMessage”:“Pass this message on to the appuser, if needed.”,"errorCode":12345, ”status":401,“moreInfo”:“”} Request Response API Facade nothing to see here
    15. 15. Errors GET /products?raise=500 (don’t support raise in production)Request Response API Facade nothing to see here
    16. 16. ErrorsRequest Response 404 Not Found API Facade 449 Retry With Big System
    17. 17. Stubs
    18. 18. Stubs{"products”: [{"product":{"id":"1234”,"name":"Widget”, "color":"white"}},{"product":{"id":"1235”, "name":"Gadget”, "color":"brown"}} ]} Request Response API Facade nothing to see here
    19. 19. Stubs GET /products?mock=true (don’t support mock in production)Request Response API Facade nothing to see here
    20. 20. URLs
    21. 21. URLs App Developer/v2/accounts
    22. 22. URLs/services/data/v20.0/sobjects/Account Big System
    23. 23. URLs /v2/accounts Request Response API Facade/services/data/v20.0/sobjects/Account Big System
    24. 24. Support Limited ClientsGET /v2/accounts/123?method=delete Request Response API FacadeDELETE /services/data/v20.0/sobjects/Account/123 Big System
    25. 25. Versioning
    26. 26. Versioning Fast App Slow App Developer Developer/v3/accounts /v2/accounts
    27. 27. Versioning GET /v2/accounts GET /v3/accounts Request API FacadeGET GET Big Old New Untried System System
    28. 28. Data Formats
    29. 29. Data FormatsHTML5 App Java AppDeveloper Developer JSON SOAP
    30. 30. Data Formats POST /v2/accounts.xml SOAP Request Response API Facade/services/data/v20.0/sobjects/Account SOAP SOAP
    31. 31. Data Formats GET /v2/accounts.json JSON Request Response API Facade/services/data/v20.0/sobjects/Account SOAP SOAP
    32. 32. Internal & external systems
    33. 33. Internal API Facade ContentDB Management SOAP JDBC
    34. 34. External API FacadeSOAP XML JSON RSS
    35. 35. Q&A
    36. 36. Q&AShould the version number appear in the URL immediatelyafter the domain name or is it better to have application nameafter domain name? Billing accounts /accounts/v2/create?
    37. 37. Q&AWith all the shunting you suggest make for a terrible complexlayer?
    38. 38. Q&AWhat would you recommend for a URL pattern for a sandboxinstance?
    39. 39. Q&AHow can a GET request be transformed to a SOAP POST,specifically when the SOAP POST request size is huge?
    40. 40. Q&AWhat about version in the request header instead of putting itin the URL, what would the drawback be of using it in therequest header?
    41. 41. Q&AShould every response follow a standard format that containserrors, if any, along with response body or should the responsebody change based on success or failure of the operation?
    42. 42. Q&AWhat is the functional difference between the raise and themock parameters again?
    43. 43. Q&AFor the API I am hosting façade pattern makes sense, but forthe external systems where I am consuming APIs, factory seemsmore appropriate. What’s your take?
    44. 44. Q&AWhat are your thoughts on REST sitemaps, worth it?
    45. 45. Q&AGet flash accounts should return all accounts right? Wouldn’twant to prevent this, what would a URL request look like? Ifyou’re reflecting a response from the database where thestate=Washington, how would that work?
    46. 46. THANK YOUSubscribe to API webinars
    47. 47. THANK YOUIRC#api-crafton freenode
    48. 48. THANK YOUQuestions and ideas
    49. 49. THANK YOUContact me