This topic explain how APIs enable computer to computer communications. Start learning CCNA 200-301 for free right now!!
Video – APIs
Data formats shared between smart devices often use an Application Programming Interface (API). As you will learn in this topic, an API is software that allows other applications to access its data or services.
Click play in the video to learn about APIs.
The API Concept
APIs are found almost everywhere. Amazon Web Services, Facebook, and home automation devices such as thermostats, refrigerators, and wireless lighting systems, all use APIs. They are also used for building programmable network automation.
An API is software that allows other applications to access its data or services. It is a set of rules describing how one application can interact with another, and the instructions to allow the interaction to occur. The user sends an API request to a server asking for specific information and receives an API response in return from the server along with the requested information.
An API is similar to a waiter in a restaurant, as shown in the following figure. A customer in a restaurant would like to have some food delivered to the table. The food is in the kitchen where it is cooked and prepared. The waiter is the messenger, similar to an API. The waiter (the API) is the person who takes the customer’s order (the request) and tells the kitchen what to do. When the food is ready, the waiter will then deliver the food (the response) back to the customer.
Previously, you saw an API request to a server which returned the current latitude and longitude of the International Space Station. This was an API that Open Notify provides to access data from a web browser at National Aeronautics and Space Administration (NASA).
An API Example
To really understand how APIs can be used to provide data and services, we will look at two options for booking airline reservations. The first option uses the web site of a specific airline, as shown in the figure. Using the airline’s web site, the user enters the information to make a reservation request. The web site interacts directly with the airline’s own database and provides the user with information matching the user’s request.
Instead of using an individual airline web site which has direct access to its own information, there is a second option. Users can use a travel site to access this same information, not only from a specific airline but a variety of airlines. In this case, the user enters in similar reservation information. The travel service web site interacts with the various airline databases using APIs provided by each airline. The travel service uses each airline API to request information from that specific airline, and then it displays the information from all the airlines on the its web page, as shown in the figure.
The API acts as a kind of messenger between the requesting application and the application on the server that provides the data or service. The message from the requesting application to the server where the data resides is known as an API call.
Open, Internal, and Partner APIs
An important consideration when developing an API is the distinction between open, internal, and partner APIs:
- Open APIs or Public APIs – These APIs are publicly available and can be used with no restrictions. The International Space Station API is an example of a Public API. Because these APIs are public, many API providers, such as Google Maps, require the user to get a free key, or token, prior to using the API. This is to help control the number of API requests they receive and process. Search the internet for a list of public APIs.
- Internal or Private APIs – These are APIs that are used by an organization or company to access data and services for internal use only. An example of an internal API is allowing authorized salespeople access to internal sales data on their mobile devices.
- Partner APIs – These are APIs that are used between a company and its business partners or contractors to facilitate business between them. The business partner must have a license or other form of permission to use the API. A travel service using an airline’s API is an example of a partner API.
Types of Web Service APIs
A web service is a service that is available over the internet, using the World Wide Web. There are four types of web service APIs:
- Simple Object Access Protocol (SOAP)
- Representational State Transfer (REST)
- eXtensible Markup Language-Remote Procedure Call (XML-RPC)
|Data Format||XML||JSON, XML, YAML, and others||XML||JSON|
|Strengths||Well-established||Flexible formatting and most widely used||Well-established, simplicity||Simplicity|
SOAP is a messaging protocol for exchanging XML-structured information, most often over HTTP or Simple Mail Transfer Protocol (SMTP). Designed by Microsoft in 1998, SOAP APIs are considered slow to parse, complex, and rigid.
This led to the development of a simpler REST API framework which does not require XML. REST uses HTTP, is less verbose, and is easier to use than SOAP. REST refers to the style of software architecture and has become popular due to its performance, scalability, simplicity, and reliability.
REST is the most widely used web service API, accounting for over 80% of all the API types used. REST will be further discussed in this module.
RPC is when one system requests that another system executes some code and returns the information. This is done without having to understand the details of the network. This works much like a REST API but there are differences dealing with formatting and flexibility. XML-RPC is a protocol developed prior to SOAP, and later evolved into what became SOAP. JSON-RPC is a very simple protocol and similar to XML-RPC.
Ready to go! Keep visiting our networking course blog, give Like to our fanpage; and you will find more tools and concepts that will make you a networking professional.