SlideShare utilise les cookies pour améliorer les fonctionnalités et les performances, et également pour vous montrer des publicités pertinentes. Si vous continuez à naviguer sur ce site, vous acceptez l’utilisation de cookies. Consultez nos Conditions d’utilisation et notre Politique de confidentialité.
SlideShare utilise les cookies pour améliorer les fonctionnalités et les performances, et également pour vous montrer des publicités pertinentes. Si vous continuez à naviguer sur ce site, vous acceptez l’utilisation de cookies. Consultez notre Politique de confidentialité et nos Conditions d’utilisation pour en savoir plus.
The act of Consuming a Rest API means to eat it all up, so in context it means to eat it, swallow it up, and digest it leaving any others in the pile exposed.
So it basically just means to use an API.
Here is an overview of what I’ll be going over.
What is DevNet? DevNet is a developer program created 2 years ago. Cisco decided it was time to turn the company from a network company to a software and services company. Our purpose is to create APIs and software to help our partners and customers have better products. We go to programming events and all types of conferences to help promote that we are not a network company. I’m not here to sell anything as we focus on selling internally and to partners and customers. We love giving out swag at events. I didn’t feel like bringing an extra suitcase today, so no swag. We absolutely love getting attention on @CiscoDevNet. A wonderful colleague of mine is amazing at her social media work on all of our DevNet accounts. She gets excited when you tweet at her. Even more excited if you ask for stickers!
Why are API’s so important? Most companies today have several different software’s they need to use, including sales, accounting, CRM, a project management system, etc.
To have the software all work together is becoming a more important thing for both synergy and financial reasons and is making tasks much easier for work processes.
They can also create their own tool to enhance their software, making their customers happier.
As you can see that the amount of API’s out there started with 1 API in 2000 (Ebay) and has exponentially increased over time.
In 2016, there has been more than 50 million API requests made and 30,000 available API’s out there.
From 2015 to 2016, it has doubled in growth from 15,000 to 30,000 and only exponentially increasing.
Okay, so what is an API?
Ready for a lot of examples?
I’ll make it sound easy
An API stands for Application Programming Interface
It’s a way for two pieces of software to talk to each other.
Which brings me to saying that 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 best thought of as a contract provided by one piece of computer software to another.
I will use Yelp as an example. Yelp displays nearby restaurants using the Google Map API by “exposing” some of the program’s internal functions to the outside world in a limited fashion. This makes it possible for applications to share data without requiring developers to share all of their code. APIs simplify all of that by limiting outside program access to a specific set of features by allowing them to request data. Think of it as doors or windows, or even levers. APIs make it possible to use a mix and match of APIs, such as Google API, Facebook API, or Twitter API, and make an entire new app and service. The widespread of API’s for major services is what made the modern web experience possible today.
APIs are often referred to as “an engine of innovation”
Because of API, there are so many cool applications out there that wouldn’t exist no.
REST API versus Web API, if you’ve heard the two terms before.
REST describes a way of interacting with a HTTP server. Not what the server should return in response.
HTTP implements methods (which is also known as verbs) other than GET or POST. It also implements HEAD, which is without the response body, and PUT and DELETE, which I’ll go over a little later.
A REST interface simply makes use of these additional verbs to convey the meaning of the request to the server.
Web services are set of platform independent exposed APIs(functions) which can be used used from remote server over the Internet. So there are 3 different types of web services for providing APIs. The first one is called Remote Procedure Call (RPC). It uses a single URI and gives the responses in a structured format, but lacks the amount of responses it can give out, especially compared to REST. Simple Object Access Protocol (SOAP) is more powerful and preferred by software vendors like Microsoft,.NET, Java Enterprise Edition, and that sort of thing. SOAP is the most used tool and the preferred tool between 2001-2007. Representational State Transfer (REST) is what I’ll be going over since it is the most popular web service to use. Each unique URL is a representational of some object, hence where the acronym REST came from. The results are human readable, and it’s also much light weight compared to other web services. You can find more in depth information about all 3 on tiny.cc/webservices.
Next we will go over web pages, requests, responses, and REST APIs
When you view a web page, it sends a request to the web server, and sends a response back.
So you are making a request and getting a response.
When you send your HTTP request, you are sending a GET request.
You get your response as an HTTP response code, where 200 means good, and everything came back okay.
This is exactly what is happening between your app and their app between an API
Here are some common HTTP status codes that you will get when you request a web page.
When you make a request with an API, you also get a response back with a status code.
Usually you will be hoping for 200 OK.
Using Cisco Spark API as a use case, of course.
To understand a specific API, you must know what the application actually does. Cisco Spark is a collaboration tool, similar to Slack or Glip, that allows you to chat, have meetings, and video chat.
Spark is designed to be a very light weight option so developers can customize it to their company needs.
We are releasing an app marketplace of free plugins so people can download Spark and install plugins that they will actually use, rather than have a tool that has more features than you actually need.
So how do you interact with this particular API? Well, there are methods you can make to request data.
When you are getting data using an API, you make your request.
In this flow chart, you see that your app is asking to make a list of Spark rooms, then the Spark server prepares the data and sends the list of spark rooms back.
And you can have it parsed in any parsing format you want, such as JSON or XML, which are the 2 most popular. Don’t ask which is better to use, since they both have their pros and cons. It really depends on what you are doing in your application.
So your Application would be the API consumer, the request is GET /rooms and the Cisco Spark API is the API Provider.
Then the return result is a HTTP 200 OK.
This is a list of different HTTP routing methods you can use to make a request.
GET --- Can get a list of items, or get an individual item id POST --- Creates an item PUT --- Updates an item DELETE – Delete’s an item
So how do we test these API requests to check if it works first?
When you are working with APIs, you will commonly have API problems that you need to solve. There are a kazillion tools out there. There’s a website that lists out 60 tools you can use to solve your problems, (note: not mental problems), and you can find it at tiny.cc/60tools
Webhook Debugging (RequestBin formerly requestbin.org…) – Inspect requests Webhook Utilities (Torpio…) – Webhook Delivery Platform. BAM! Local Tunneling (ngrok…) – Tunnel to Localhost, weeeeeeeeeeeee API Monitoring (Runscope…) – API monitoring/testing, chained requests/oauth sup. Response Mocking (mocky.io...) – Mock API response, duh! JSON Utilities (JSONFormat...) – Make URL very pretty! OAUTH Utilities (oauth.io...) – Integrate Oauth EZ Peezy! API Directories (APIS.io, ProgrammableWeb...) – Directory of... Ummmm... API Testing (Runscope Radar...) – Test in cloud (not real cloud). Email/Webhook notification for when you’re a failure and suck at APIs Load Testing (loader.io...) – Test with thousands of concurrent connections. Because scaling is important. GUI HTTP Clients (POSTMAN...) – An interface for creating and testing requests and what we are going to go over next!
This is where POSTMAN comes in handy.
I’ll show you how to work with REST API Calls. First, install the Chrome plugin Postman, or you can install it as an individual app on the Mac.
It’s a free tool to forge API Requests and examine responses.
For Mozilla or Safari, you can install a plugin called RESTClient
Let’s understand how Postman is working with the Github API here.
Let’s create an HTTP request to github.com Leave the GET method as is. Enter the URL of the resource. Press the Send button
Postman issues the HTTP call on your behalf, and shows the response by the Github API: Here it shows the response is 200 OK towards the bottom right. The HTML page contents are placed in the Body
Now What? How do you figure out how to use an API?
A great API will have great documentation.
If people cannot figure out how to use your API, then you will not have as many users as you were hoping for. The most popular API’s out there have very well written documentation.
You could have the best API in the world, but if developers cannot figure out how to use it, they will find something else.
For Reviewing the Documentation…
To start learning a new API, you first find the documentation page. You find the API reference and figure out what you want to do. Then you test your API request via Postman because it is fun!
I want to first create a room in Spark and test it through POSTMAN.
Here’s a closer look at the API reference for Rooms.
You can List Rooms, Create a Room, Get Room Details, Update a Room, and Delete a Room.
In this example, I created a title of a room called “PHPCruise Room”.
I knew to use title because of the API documentation.
After clicking on Submit, I opened up my Cisco Spark.
There is now a new room called ”PHPCruise Room” that I created in POSTMAN from an API Call.
You created a room, now how do you post a message to it through an API Request?
To create a message API request you will need to take note of the key generated for the room you created which is your roomID.
Refer to the documentation for creating a message. Test the API Request, which makes magic happen.
So what do we do next? Oh right, we go back to the documentation to find out what HTTP request to make to create a message.
Looks like it is the 2nd one here, so we will use the method POST.
But what about request parameters?
Oh right, that documentation stuff again.
This is the list of parameters you can use for the messages
Let’s use roomId and text as an easy example to demonstrate.
Add the JSON data of the roomId and text to the body.
The roomId is what you received when creating a room.
The text is the message you want. You click Send and it will now post a message to your room. Go ahead and try it when you get home. It’s very easy!
There is one important thing you need to do when you receive a 200 OK HTTP Status. Please take note of this.
You do a dance!
Alright I get it. Now show me something else that’s cool!
How about… applications interacting with a cell phone?
Tropo is a voice/SMS API that compares to Twilio. It was acquired by Cisco over a year ago.
You can find the website at tropo.com.
You can build really cool applications that interact with your phone, or use the Tropo API as an integration to your software.
This is my favorite one to show people because developers seem very excited that this could help improve their software.
I’ll quickly go over how you can create your first application and use the Tropo API.
It can literally take you less than 5 minutes even without developer experience.
First, of course, you’d have to create an account on tropo.com
First you give your App a name. In this one I give it “Tessa’s Texting Service”.
Leave it at default for Development as the App Status, so it is free to use.
Edit your Script and create a name, such as textService.js.
You can select a Country, such as Brazil, and select which Region in the country and click Add.
Replace my phone number with yours of course.
To allow SMS to work on your application, you would need to put in a support ticket to get your account activated for it.
I could also do it for you on my end and activate your account.
You can launch your app by using a token URL into the browser to make a request and fire off your application.
Simply add a question mark after the method call and before putting in the query parameters.
Each query parameter is separated by an & sign.
Magic? I know right? The phone number above is my apps phone number that sent my phone a text message.
You can do it too! It’s that easy. And you may experience this with most API’s with great documentation!
Here are the most used functions with the Tropo API.
You can make calls, answer, log information about a call, say something, ask a question, and record.
You can even do speech to text.
Easy? I know…
The Spark Innovation Fund is a budget that was given to my department where we pay developers to create a startup that we will fund.
The startup that you build stays under your name or your business name.
We want to market our APIs and drive our developer ecosystem. This will only benefit you.
Our budget we were given is 150 Million USD Dollars.
You can learn more about it at developer.ciscospark.com/fund.
Also, don’t forget to tweet at me @tessamero
So, I hope you you feel highly consumed and full from this API talk.
If you are new to APIs and need help getting started, or simply want to try out our Cisco APIs, please do not hesitate to contact me.
Nom Nom: Consuming REST APIs
ZendCon Conference October 2016
Consuming Rest APIs
Follow me on Twitter and/or tweet at me. @tessamero
By Tessa Mero
Nom Nom: Consuming
• 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
• Developer Advocate
• Previously Web Developer
• <3 Free & Open Source
• Community Leader for
Joomla and PHP
• Mother of 2
• I love APIs
• Addicted to Twitter
Who Am I?
Cisco DevNet? Why Am I Here?
• What is DevNet?
• What is the Purpose?
• Why do we go to programming
• Not Selling Anything
• We Like Giving Out Swag
• We Like attention
API Growth from 2000 to 2016
2000 2005 2007 2009 2011 2013 2015 2016
Source: 2016 data from nordicapis.com. 2005-2015 data from
rubenverborgh.github.io and 2000-2004 data from blog.cutter.com
Ready for a lot of
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
APIs are sets of
requirements that govern
how one application can talk
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.
APIs help developers create apps that
benefit the end user.
Yelp asks for Map
returns map data
-- Programmable Web
APIs are often referred to as “an engine of
REST API versus Web API
• No difference at all. It doesn’t give a different
• HTTP implements methods.
• A REST interface simply sends request to server
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
• 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
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
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 a Message
3. Test the API request.
4. Make Magic Happen.
Create Message API Request
say("Don't forget your meeting at 2 p.m. on
5. LAUNCH IT!
You can put your token URL in the browser to
make a request and fire off your app
• 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