Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Building API Integrations You Can Live With

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Wird geladen in …3
×

Hier ansehen

1 von 30 Anzeige

Building API Integrations You Can Live With

Herunterladen, um offline zu lesen

John Sheehan's talk from Future Insights Live 2014 in Las Vegas: "In this talk John will discuss strategies for debugging API problems, monitoring your dependencies so you can sleep at night and mitigating problems before they ruin your day."

Miss his talk? Join us at a future show: www.futureofwebapps.com. Sign up for our newsletter at futureinsights.com and get 15% off your next conference.

John Sheehan's talk from Future Insights Live 2014 in Las Vegas: "In this talk John will discuss strategies for debugging API problems, monitoring your dependencies so you can sleep at night and mitigating problems before they ruin your day."

Miss his talk? Join us at a future show: www.futureofwebapps.com. Sign up for our newsletter at futureinsights.com and get 15% off your next conference.

Anzeige
Anzeige

Weitere Verwandte Inhalte

Diashows für Sie (20)

Andere mochten auch (15)

Anzeige

Ähnlich wie Building API Integrations You Can Live With (20)

Weitere von Future Insights (20)

Anzeige

Building API Integrations You Can Live With

  1. 1. John Sheehan CEO, RunscopeRunscope Building APIBuilding API integrations youintegrations you can live with.can live with.
  2. 2. “ There's just no getting around it: you're building ayou're building a distributed systemdistributed system. -- Mark Cavage, ACM Queue
  3. 3. Mobile & Desktop Apps Web Sites & Applications Internal APIs 3rd-party Service APIs Public APIs
  4. 4. Mobile & Desktop Apps Web Sites & Applications Internal APIs 3rd-party Service APIs Public APIs fn(){} fn(){} fn(){} fn(){} fn(){}
  5. 5. fn(){} fn(){}fn(){}fn(){} fn(){} YOUR APPLICATIONYOUR APPLICATION
  6. 6. What are theWhat are the challenges for runningchallenges for running an API-drivenan API-driven application?application?
  7. 7. CHALLENGE #1CHALLENGE #1 Getting a complete picture of your app.
  8. 8. Watch and logWatch and log everythingeverything..
  9. 9. CHALLENGE #2CHALLENGE #2 Managing change.
  10. 10. Prefer lighter abstractions.
  11. 11. Think twice aboutThink twice about taking a dependencytaking a dependency on an SDK.on an SDK.
  12. 12. Your Code The API API SDK v1v1 v2v2
  13. 13. Your Code The API API SDK The API API SDKHTTP Client v1 JSON Parser v1
  14. 14. Your Code The API API SDK The API API SDKHTTP Client JSON Parser v1 RequiresRequires v1v1 RequiresRequires v2v2
  15. 15. Your Code The API API SDK ?????? ??????
  16. 16. SDKs OK:SDKs OK: Prototyping No good HTTP Client Building Clients Complex APIs Uses Native APIs
  17. 17. SDK DANGER:SDK DANGER: Using more than one Community-built Many dependencies Inactive
  18. 18. SDK FOR PROVIDERS:SDK FOR PROVIDERS: Definitely build them! ...for many platforms ...as native as possible ...and well-documented
  19. 19. HOW WE DOHOW WE DO Smarter HTTP client Thin wrappers
  20. 20. url = "https://ec2-23-212-199-23.us-west-2.amazo resp = requests.get(url) if resp.ok: return resp.json() else: # retry? return None def get_user(id): def main(): user = get_user(id) print user["name"]
  21. 21. class Identity def get_user(id): url = "service://identity/users/" + id resp = smart_client.get(url) if resp.ok: return User(resp.json()) return AnonymousUser() from Identity import get_user def main(): user = get_user(id) print user.name Auto-Auto- locatelocate serviceservice SmartSmart retriesretries
  22. 22. CHALLENGE #3CHALLENGE #3 High-fidelity testing.
  23. 23. Let’s look at some API testing frameworks.
  24. 24. require&'rubygems' require&'test/unit' require&'vcr' VCR.configure&do&|c| &c.cassette_library_dir&=&'fixtures/vcr_cassettes' &c.hook_into&:webmock&#"or":fakeweb end class&VCRTest&<&Test::Unit::TestCase &def&test_example_dot_com &&&VCR.use_cassette('synopsis')&do8 88888url&=&'http://yourapihere.com' &&&&&response&=&Net::HTTP.get_response(URI(url)) &&&&&assert_match&/Example&domains/,&response.body &&&end &end end VCRVCR github.com/vcr/vcr
  25. 25. mocky.iomocky.io
  26. 26. frisby.jsfrisby.js
  27. 27. aspecaspec github.com/songkick/aspec # no users have pending notifications GET /users/with-pending-notifications 200 application/json [] # users with events on their calendar have pending notifications POST /users/764/metro-areas/999 204 POST /users/764/artists/123 204 POST /events/5?artist_ids=123&metro_area_id=999 204 POST /events/5/enqueue-notifications 204 GET /users/with-pending-notifications 200 application/json [[764, "ep"]] # users are unique in the response POST /users/764/artists/123 204 POST /users/764/artists/456 204 POST /users/764/metro-areas/999 204 POST /events/5?artist_ids=123,456&metro_area_id=999 204 POST /events/5/enqueue-notifications 204 GET /users/with-pending-notifications 200 application/json [[764, "ep"]]
  28. 28. service'"http://localhost:4567"'do 'def'responds_with_json_where '''JSON.parse(response.body) 'end 'resource'"/lolz"'do '''get'do '''''it'{'responds_with.status':ok'} '''''it'{'responds_with_json_where['lolz'].must_be_instance_of'A '''''with_query("q=monorail")'do '''''''it'"only'lists'lolz'that'match'the'query"'do '''''''''responds_with_json_where['lolz'].wont_be_empty '''''''''responds_with_json_where['lolz'].each'do'|lol| '''''''''''lol['title'].must_match'/monorail/ '''''''''end '''''''end '''''end HyperSpecHyperSpec
  29. 29. THANK YOUTHANK YOU API Podcast: trafficandweather.iotrafficandweather.io Try Runscope Free: runscope.comrunscope.com

×