ZendCon Conference October 2016
Consuming Rest APIs
Follow me on Twitter and/or tweet at me. @tessamero
By Tessa Mero
Nom ...
CONSUME THE REST APIS!
• Who Am I?
• WHAT ARE APIs
• Requests and Responses
• Intro to APIs
• Playing with Spark API
• Playing with Tropo API
• T...
• Developer Advocate
• Teacher/Mentor
• Previously Web Developer
• <3 Free & Open Source
• Community Leader for
Joomla and...
Cisco DevNet? Why Am I Here?
• What is DevNet?
• What is the Purpose?
• Why do we go to programming
conferences?
• Not Sel...
Why are API’s so important?
API Growth from 2000 to 2016
0
5000
10000
15000
20000
25000
30000
35000
2000 2005 2007 2009 2011 2013 2015 2016
API's
API'...
Okay, What is an API?
Ready for a lot of
examples?
I’ll make it sound easy 
“It’s a way for two pieces of software to
talk to each other”
Application Programming Interface
The API is the User
Interface for software
systems
APIs are sets of
requirements that govern
how one application can talk
to another.
An API is like …
An API (Application Programming Interface) is best thought of as a contract
provided by one piece of comp...
APIs help developers create apps that
benefit the end user.
Yelp asks for Map
Data
Google Maps
returns map data
via API
Us...
Presentation ID
-- Programmable Web
APIs are often referred to as “an engine of
innovation.”
REST API versus Web API
• No difference at all. It doesn’t give a different
output.
• HTTP implements methods.
• A REST in...
Three Types of Web Services for Providing APIs
Remote Procedure Call (RPC) or XML-RPC
• Single URI
• Response is in a Stru...
Requests and Responses
View a Web Page
19Presentation ID
View a Web Page
20Presentation ID
Request
GET /index.htm HTTP/1.1
Response
HTTP 200 OK
<html>
REST APIs use Request and Response too
• 200 OK
• 301 Moved Permanently
• 302 Found
• 307 Temporary Redirect
• 400 Bad Request
• 403 Forbidden
Common HTTP Status...
Using Cisco Spark API as a
Use Case. Of course =P
So how do you interact with
this API?
Get Data using an API
25Presentation ID
Get Data using an API
26Presentation ID
Request
GET /rooms
Response
HTTP 200 OK
{json data}
API Consumer API Provider
Tools to Debug/Test http://tiny.cc/60tools
• Webhook Debugging (RequestBin formerly requestbin.org…)
• Webhook Utilities (...
Postman!!!! =)
Test Your REST API Requests = FUN
method
url
request
headers
status code
response headers
content-type
response
body
query parameters
Now What? How Do You
Figure Out How To Use an
API?
One Word: Documentation
1. First, find the documentation page. If you cannot find it,
then that’s a problem.
2. Find the API Reference.
3. Figure ...
The API Reference!
API Reference: Rooms
Room Created!
PHPCruise Room
Created!
Whoa!!!!
You created a room, now
how do you post a message
to it through an API request?
1. Take Note of Key generated when you created a room,
so now your room has an ID.
2. Refer to documentation for Creating ...
Oh yeah, the documentation….
But what about request
parameters?
Oh yeah, the
documentation!
Create your request parameters in the body.
Feelin’ 200 OK
Oh my gosh I can’t see it what does it say?
One important thing to do
when you receive a 200 OK
HTTP Status:
(Please take note of this)
Alright I get it. Now show me
something else that’s cool!
How About…
Applications Interacting With
a Cell Phone?!
Introducing the Tropo API! IT’S SO MUCH FUNZ
What Can You Do With Tropo?
Create an Application:
Register (anyone can, free)
Click on “My Apps”
Click on “Create New App”
1. Create Name
2. Click on “Edit
Script” and give it
a name. This is:
textService.js
3. Add a Phone Number (Free for Dev)
4. Write some JavaScript
call("+14258791911", {
network:"SMS”
});
say("Don't forget your meeting at 2 p.m. on
Wednesday!");
5. LAUNCH IT!
You can put your token URL in the browser to
make a request and fire off your app
https://api.tropo.com/1.0/...
Magic!
You can do it too!
• call();
• answer();
• _log();
• say();
• ask();
• record();
• Makes a call
• Answers the call (when called)
• Logs the i...
Easy? I know…
Spark Innovation Fund?
$1,000,000 x 150….
I like money too, trust me…
https://developer.ciscospark.com/fund/
Also, don’t forget to tweet at me @tessamero
Thank You
Nom Nom: Consuming REST APIs
Nom Nom: Consuming REST APIs
Nom Nom: Consuming REST APIs
Upcoming SlideShare
Loading in …5
×

Nom Nom: Consuming REST APIs

270 views

Published on

Last Updated Slides for Presentation

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Nom Nom: Consuming REST APIs

  1. 1. ZendCon Conference October 2016 Consuming Rest APIs Follow me on Twitter and/or tweet at me. @tessamero By Tessa Mero Nom Nom: Consuming Rest APIs
  2. 2. CONSUME THE REST APIS!
  3. 3. • Who Am I? • WHAT ARE APIs • Requests and Responses • Intro to APIs • Playing with Spark API • Playing with Tropo API • Taking Knowledge Home With You Overview @tessamero
  4. 4. • Developer Advocate • Teacher/Mentor • Previously Web Developer • <3 Free & Open Source • Community Leader for Joomla and PHP • Mother of 2 • I love APIs • Addicted to Twitter (@tessamero) Who Am I?
  5. 5. Cisco DevNet? Why Am I Here? • What is DevNet? • What is the Purpose? • Why do we go to programming conferences? • Not Selling Anything • We Like Giving Out Swag • We Like attention @ciscodevnet
  6. 6. Why are API’s so important?
  7. 7. API Growth from 2000 to 2016 0 5000 10000 15000 20000 25000 30000 35000 2000 2005 2007 2009 2011 2013 2015 2016 API's API's Source: 2016 data from nordicapis.com. 2005-2015 data from rubenverborgh.github.io and 2000-2004 data from blog.cutter.com
  8. 8. Okay, What is an API?
  9. 9. Ready for a lot of examples? I’ll make it sound easy 
  10. 10. “It’s a way for two pieces of software to talk to each other” Application Programming Interface
  11. 11. The API is the User Interface for software systems
  12. 12. APIs are sets of requirements that govern how one application can talk to another.
  13. 13. An API is like … An API (Application Programming Interface) is best thought of as a contract provided by one piece of computer software to another.
  14. 14. APIs help developers create apps that benefit the end user. Yelp asks for Map Data Google Maps returns map data via API Users sees list of restaurants close to them
  15. 15. Presentation ID -- Programmable Web APIs are often referred to as “an engine of innovation.”
  16. 16. REST API versus Web API • No difference at all. It doesn’t give a different output. • HTTP implements methods. • A REST interface simply sends request to server
  17. 17. Three Types of Web Services for Providing APIs Remote Procedure Call (RPC) or XML-RPC • Single URI • Response is in a Structured Format • Lacks Responses Simple Object Access Protocol (SOAP) • More powerful, preferred by software vendors (MSFT,.NET,Java Entprse Edition, etc) • SOAP most used tool 2001-2007 Representational State Transfer (REST) • Most popular web service • Each unique URL is a representational of some object • Easy to read results • Light Weight – Not much XML markup http://tiny.cc/webservices
  18. 18. Requests and Responses
  19. 19. View a Web Page 19Presentation ID
  20. 20. View a Web Page 20Presentation ID Request GET /index.htm HTTP/1.1 Response HTTP 200 OK <html>
  21. 21. REST APIs use Request and Response too
  22. 22. • 200 OK • 301 Moved Permanently • 302 Found • 307 Temporary Redirect • 400 Bad Request • 403 Forbidden Common HTTP Status Codes • 404 Not Found • 500 Internal Server Error • 550 Permission Denied
  23. 23. Using Cisco Spark API as a Use Case. Of course =P
  24. 24. So how do you interact with this API?
  25. 25. Get Data using an API 25Presentation ID
  26. 26. Get Data using an API 26Presentation ID Request GET /rooms Response HTTP 200 OK {json data} API Consumer API Provider
  27. 27. Tools to Debug/Test http://tiny.cc/60tools • Webhook Debugging (RequestBin formerly requestbin.org…) • Webhook Utilities (Torpio…) • Local Tunneling (ngrok...) • API Monitoring (Runscope...) • Response Mocking (mocky.io...) • JSON Utilities (JSONFormat...) • OAUTH Utilities (oauth.io...) • API Directories (APIS.io, ProgrammableWeb...) • API Testing (Runscope Radar...) • Load Testing (loader.io...) • GUI HTTP Clients (POSTMAN...)
  28. 28. Postman!!!! =)
  29. 29. Test Your REST API Requests = FUN
  30. 30. method url request headers status code response headers content-type response body query parameters
  31. 31. Now What? How Do You Figure Out How To Use an API?
  32. 32. One Word: Documentation
  33. 33. 1. First, find the documentation page. If you cannot find it, then that’s a problem. 2. Find the API Reference. 3. Figure out what you want to do. 4. Test your API request via Postman because it’s fun :P Reviewing the Documentation
  34. 34. The API Reference!
  35. 35. API Reference: Rooms
  36. 36. Room Created!
  37. 37. PHPCruise Room Created! Whoa!!!!
  38. 38. You created a room, now how do you post a message to it through an API request?
  39. 39. 1. Take Note of Key generated when you created a room, so now your room has an ID. 2. Refer to documentation for Creating a Message 3. Test the API request. 4. Make Magic Happen. Create Message API Request
  40. 40. Oh yeah, the documentation….
  41. 41. But what about request parameters?
  42. 42. Oh yeah, the documentation!
  43. 43. Create your request parameters in the body. Feelin’ 200 OK Oh my gosh I can’t see it what does it say?
  44. 44. One important thing to do when you receive a 200 OK HTTP Status: (Please take note of this)
  45. 45. Alright I get it. Now show me something else that’s cool!
  46. 46. How About… Applications Interacting With a Cell Phone?!
  47. 47. Introducing the Tropo API! IT’S SO MUCH FUNZ
  48. 48. What Can You Do With Tropo?
  49. 49. Create an Application: Register (anyone can, free) Click on “My Apps” Click on “Create New App”
  50. 50. 1. Create Name 2. Click on “Edit Script” and give it a name. This is: textService.js
  51. 51. 3. Add a Phone Number (Free for Dev)
  52. 52. 4. Write some JavaScript call("+14258791911", { network:"SMS” }); say("Don't forget your meeting at 2 p.m. on Wednesday!");
  53. 53. 5. LAUNCH IT! You can put your token URL in the browser to make a request and fire off your app https://api.tropo.com/1.0/sessions?action=create&t oken=6c7a56555271337716e76596b6266456254 566e4e625058657133776456d6d7a504f4b4b4133 7a71624c
  54. 54. Magic!
  55. 55. You can do it too!
  56. 56. • call(); • answer(); • _log(); • say(); • ask(); • record(); • Makes a call • Answers the call (when called) • Logs the info about the call • Says something • Says something in a question • Records the call (like voicemail), with certain parameters, you can transcribe caller input too! Other Functions To Use
  57. 57. Easy? I know…
  58. 58. Spark Innovation Fund?
  59. 59. $1,000,000 x 150….
  60. 60. I like money too, trust me… https://developer.ciscospark.com/fund/ Also, don’t forget to tweet at me @tessamero
  61. 61. Thank You

×