The internet has become a vital tool globally for plenty of us in day-to-day life. We online shop, order food, book travels, and share content with our friends and family on social platforms. Yet many of us never stop to think about how all of this is made possible.
What does API really mean?
How do applications get access to databases? How do they present the right information we seek with our gadgets?
You may have come across the acronym API. Now, it may seem like a complicated phrase or form of technology, but what does API really mean?
API or “Application Programming Interface” works as a messenger between the provider and us. (Further explain who “us” is). API receives requests and delivers it to the provider and then back to us with a response.
Picture this analogy. API acts as the waiter in a restaurant, with the kitchen acting as the provider. The waiter takes the order, which he delivers to the kitchen. The kitchen then prepares the order, and comes back to us with food which is a response to the initial response. In fact, you don’t know exactly how the restaurant prepares that food, which is fine because you don’t need to. This is exactly how API works.
From a technical view, API is a program of instructions that is a standard to access a web-based software application or service.
API is what makes communication between applications and providers possible.
Some API examples:
How are we able to check the weather with our devices so easily and accurately? How are we provided exact data based on our requirements? There are many weather stations globally, which are able to, using API technology, acts as an interface between Apps and millions of endpoints around the world. These apps take our requests to providers, obtaining the exact data from available databases and right back to us.
Another example is trip booking. There are many different factors involved in booking vacations including things like airfare tickets, hotels, etc… We are able to run apps on our mobile devices and select the time, destination and send it through the internet. API takes in these requests, then runs them through different databases to find information on flights, hotels and anything else we may need to know about our desired destination. With all this information at our disposal, we can decide and select a suitable offer. Before API and integrated applications, all this had to be done over the phone!
In terms of publishing policies, APIs can divide 4 types:
- Open or Public API: Public APIs are open and available to be used by any outside developer or business with minimal restrictions.
For instance, Facebook’s open API has made it possible to create an account on an external site/app using your Facebook credentials. Google Maps is another example of an open API that can be used in Internet Taxi or other video games in need of dynamic, live-time maps.
- Partner API: A partner API, is only available to specifically selected and authorized outside developers or API consumers. These is are used to facilitate business-to-business activities
Partner APIs are similar to open APIs but with some restrictions implemented by business partners.
They are used for specific purposes, such as providing access to a paid-services.
- Private or Internal API: Private APIs are provided to developers for in-house personnel to increase productivity as well as better communication of computer systems. They are used within companies to share resources.
Web developers in organizations may use these APIs to integrate corporate IT systems or applications. Using internal APIs has several advantages including security as well as access control of the system.
For example, interactions between different parts of a company like the HR and finance department is possible by internal API.
- Composite API: Composite API is as the name implies, which is a combination of two or more APIs to generate specific information for specific requests.
In some cases, one API couldn’t generate all of the required information so we need a combination between some APIs.
Travel booking is an example of a composite API that uses data from several databases (Transportation system data that includes airway, train, bus, hotel reservations, climate information to check the weather in destinations to manage the trip program).
API Protocols and Architectures:
The purpose of API protocol is to standardize data exchange between web services.
There are different types of API protocols, but we will review 3 main types of them; REST, SOAP and RPC.
REST (Representational State Transfer) is the most popular approach to API protocols.
REST responds to a client/server approach that separates the front and back ends of the API, and provides significant flexibility in development and implementation. REST is a “stateless approach,” which means the API saves no data between inquiries. REST supports caching, which stores responses for slow or non-time-sensitive APIs. REST APIs, usually called “REST-ful APIs,” also can communicate directly or operate through intermediate systems such as API gateways and load balancers.
RPC (Remote Procedure Call) protocol is a simple way to send multiple parameters and receive results. RPC APIs include executable actions or processes, while REST APIs mainly exchange data or resources such as documents. RPC can incorporate two different languages, JSON and XML, for coding; these APIs are dubbed JSON-RPC and XML-RPC, respectively.
SOAP (Simple Object Access Protocol) is mostly used with enterprise web-based software to ensure high security of transmitted data. SOAP is a messaging standard defined by the World Wide Web Consortium and used broadly to create web APIs, usually with XML formats. SOAP supports a wide range of communication protocols found across the internet, such as HTTP, SMTP and TCP. SOAP is also extensible and style-independent, which allows developers to write SOAP APIs in varied ways besides affixing features while functioning easily. The SOAP approach defines how the SOAP message is processed, determines the features and modules included, and decides the communication protocol(s) supported and the construction of SOAP messages.
There are situations where you need to develop your own custom API to provide all specific requirements, in this case we call it Custom API which can be developed by companies who are specialized in Firmware Developments and understand the low level code down to electronic chips.
API is an alternative to the user interface. Just as users can send a command to hardware or send a message to software by just a click of a button, API is a tool that allows applications and providers to communicate with each other, sending and receiving commands.
APIs are everywhere and without them, collaboration between small components of hardware and software systems would not be possible.
APIs are behind the scenes of all applications, although we cannot see them, but every time we run an application, we call on them to perform for us and they come back to us in a few seconds with the required information! They are essential in the modern web and act as an Unsung hero!
Author: Sara (Fakhri) Siahkar IoT Specialist @ Arshon Technology Inc.