Hello folks!! You as a developer, programmer or one who have interest to work in technical fields might have heard of this small but very useful three word acronym – Application Programming Interfaces or in short APIs
First of all, let’s understand the intent behind this article. In general, we have observed that most of the developers, especially students, hear about APIs through “word of mouth” during hackathons or some related events etc and just use some common APIs (indeed which is very good) only for sake of project building but what they don’t understand is what actually APIs are? How do APIs work? Why are they so useful and what are their functions? If one gets stuck while implementing APIs in making projects, then what should one do? What are different kinds of APIs with some examples? We will answer all these flaws that are necessary to know before implementing APIs while building projects in this article.
What are APIs?
Have you ever wondered or thought about why while making payments on apps like Zomato, Swiggy, Amazon, Flipkart etc, you are redirected to different portals like Razorpay, PayTm, PayPal, Juspay etc without sharing all their data? It is made possible only with APIs.
APIs help to communicate, exchange and leverage each other’s data between the tech systems out there. APIs include majorly three types of elements which are as follows :-
1. Procedures (also known as Routines) :-
Procedures refer to the specific tasks or functions a program performs. For example, Twitter provides a Standard Search API for developers to explore data for analytical purposes.
2. Protocols :-
The protocol is the format or can say set of rules used to communicate data between different applications. APIs are a set of these protocols or definitions used for building and integrating application softwares.
3. Tools :-
Tools can be assumed as a set of building blocks – the components needed to construct new programs and architecture. APIs give you flexibility to simplify design, administration, use and provide opportunities for further innovation.
As the name suggests, API acts as an interface to how software interacts with programmed applications. We are increasingly moving towards “API Economy” or better we can say API-centric world. To support the fact, Forrester estimates that nearly 40 percent of US-based enterprises will implement a solution to handle the increasing management requirements surrounding the proliferation of APIs across the organization. There are APIs for almost everything like weather, finance, social messaging, payments, security and authentication, even for Bitcoin etc. Want to know more about increasing and rapid trends in API Technology? Read this.
How do APIs work?
You might have seen the meme/image below on social media, but you might not have understood what this is? Or is it really relevant?
So, let me explain to you the working of an API in a simple manner with this example. We can broadly classify a restaurant architecture as : chefs (backend), customer(frontend) and waiter(API). The customer (frontend) orders (requests sent) food to waiter (API) and waiter transfers that order to chefs (backend), as a result, chefs cook and deliver accordingly (take loading time) and thus waiter serves (gives response) to customer (user).
As we have highlighted the term “requests”. The four most common types of requests are:-
• GET: The client makes a GET request to retrieve some piece of information from the server.
• POST: The client makes a POST request to add a new piece of information to the server.
• PUT: The client makes a PUT request to edit some piece of existing information on the server.
• DELETE: The client makes a DELETE request to delete some piece of information on the server.
Secondly, we have marked the term “response” and let’s see what status code represents different responses from API. If the user gets data (successful response from API), the HTTPS Status Code will be 200. Otherwise, if there is any error, it will be one of the 400 status codes.
Following are the general status codes:
100 – Informative
200 – Success
300 – Redirection
400 – Client Error ( 404 is one of them)
500 – Server Error
Types of APIs:
APIs can be classified on following basis of:-
• use cases
• release policy
APIs by Use Cases:-
Database APIs : These APIs make the communication between an application and a database management system easier. For example, Firebase is a mobile web application platform that lets developers sync, create, update, delete (CRUD) and store data in realtime in a simple manner, without writing server-side code.
Operating systems APIs : Operating systems also have APIs, for example, Windows API , Linux Kernel User-Space API, Apple (MacO & iOS) etc.
Remote APIs : These APIs interact through a communications network, and generally in most cases it is the internet. Therefore, APIs are usually designed based on web standards or specifically can say Web API. But that doesn’t mean at all that “all remote APIs are web APIs.” The most commonly used remote APIs are Web APIs because they send requests from a web application and responses from servers using HTTP (Hypertext Transfer Protocol). Developers make use of such web APIs in the development of apps or sites, increasing their functionality and making them more practical for the user, like integrating a login method via Facebook or Google, or a very famous example of adding maps using Google Map API.
APIs by Release Policy:-
Private APIs: These APIs are mainly used inside one’s organization, integrating them in systems and apps used by their employees and improving internal operations. Even though, if they appear open to the public, the interface remains available only for those within the organization, which has complete control over the API. For practice purposes, you can learn & implement it here.
Partner APIs: These APIs are shared with one or more business partners. An agreement is made between said partner and the
publisher. A partner API also adds value to the service and opens up a channel for up-selling. Example: Shopify Partner API.
Public APIs: These APIs are freely available for any third-party developers. These types of APIs don’t need to have a close relationship between the user and the publisher, can increase the revenue stream, can help reach larger audiences and build traffic, and can support a lot of innovations and a variety of business initiatives. Basically, an open source version of APIs. You can find most of the public APIs here and can use them for your very next project :).
APIs by Interests:-
SOAP APIs: SOAP or Simple Object Access Protocol APIs are web communication protocols and are used for exchanging information and structured data over HTTP/HTTPS. SOAP supports the XML data format only.
As defined in Roy Fielding’s dissertation “Architectural Styles and the Design of Network-based Software Architectures,” APIs are RESTful as long as they align with the following 6 guiding constraints of a RESTful system:
● Client-server architecture: REST architecture is composed of clients, servers, and resources, and it handles requests through HTTP.
● Statelessness: No client content is stored on the server between requests. Information about the
session state is, instead, held with the client.
● Cache: Caching can eliminate the need for some client-server interactions.
● Layered system: Client-server interactions can be mediated by additional layers. These layers could offer additional features like load balancing, shared caches, or security.
● Code on demand (optional): Servers can extend the functionality of a client by transferring executable code.
● Uniform interface: This constraint is core to the design of RESTful APIs and includes 4 facets:
○ Resource identification in requests: Resources are identified in requests and are separate from
the representations returned to the client.
○ Resource manipulation through
Clients receive files that represent resources.
These representations must have enough
information to allow modification or deletion.
○ Self-descriptive messages: Each message
returned to a client contains enough information to describe how the client should process the
○ Hypermedia as the engine of application state: After accessing a resource, the REST client
should be able to discover through hyperlinks about all other actions that are currently available.
These constraints may seem like a lot but they’re much simpler than a prescribed protocol as in SOAP. That’s why RESTful APIs are becoming more prevalent than SOAP.
Unlike SOAP, REST isn’t limited in using XML, one can obtain the information in different formats like JSON, XML, CSV, plain text, HTML etc which are parsed easier based on the language you’re using for your application.
Moreover, a new type of API standard namely GraphQL is nowadays emerging. It is a query language and server-side runtime and can be an alternative to REST.
In order to conclude the article, I would say that you can build your own custom API, REST APIs for different purposes using different tech-stacks like ReactJs, Strapi, Node.js, Python etc and even can monetize them !! For your reference, you can visit our website.
Till then keep sharing, keep learning !!
4 thoughts on “AAA – ALL ABOUT APIs”
A big thank you for your article.Really looking forward to read more. Keep writing.
whoah this blog is wonderful i really like reading your articles. Keep up the great paintings! You realize, a lot of people are hunting round for this info, you could help them greatly.
I have read so many posts about the blogger lovers however this post is really a good piece of writing, keep it up
You actually make it seem so easy with your presentation but I find this topic to be really something that I think I would never understand. It seems too complex and very broad for me. I’m looking forward for your next post, I?ll try to get the hang of it!