draft: falsein this .mdx file once ready to be published.
The first question arises, why do we need API? There are two sides to an API. Let's take an example of a Twitter application. You press a button to tweet and your tweet is live. So you pressing the button is the one side, it calls the API to make changes in the backend, it is the other side of the API. So basically there’s a developer who wrote the application and they need the API because they’re trying to connect to a big service that has got millions of users and has all sorts of complexity in the backend to make it scalable. What would be the alternative to calling a couple of Twitter APIs? Well, you’ll have to build your own social network that’ll have to run on your device and all of them have to be on your phone. Obviously, that’s not possible. So developers need APIs because we have moved beyond libraries and now we’re calling services over the internet and feeding the application.
Now, why does the provider need an API? Companies have figured out that if they have API they can expose their backend in a much secure way. Developers who’re using their APIs can use their services in a much easier way and provide a better user experience.
APIs exist in two different ways is Transactional APIs and Data API. Let’s take the same example of Twitter API. Data API comes into play when you’re fetching any data like-profile data, while Transactional API comes into play when you’re posting a tweet.
So API has created a bridge between different platforms and the backend of the application. Which results in seamless integration and performs CRUD operations on the application.
API lets you transfer data in a much faster and cheaper way. Over 80% of data on the internet is transferred through APIs. Do you know why? It’s because API is the fastest and cheapest method to transfer the data. Earlier, we used to share files and folders which were neither scalable nor secured. If many people tried to access the same data simultaneously, the server used to crash most of the time, or else you’ll have to switch to a powerful server which resulted in high cost.
This was completely removed when APIs were introduced. API usually transfers the data in JSON form which is one of the most efficient methods to transfer the data. This not only resulted in faster than the traditional method but also reduced the cost of the servers as it was using fewer resources which also helped the server to handle multiple requests at a time.
In the tech industry, data security is the most important point. You might bear the server cost but compromising with the security is a big no. Companies spend millions of dollars just making their application more secure. Previously it was very easy to attack the system with DDOS, brute force, and other methods and hack into the system. Before APIs, the developers had to expose their complete backend to let other developers integrate their services. This resulted in the exposure of user data to unauthenticated users also.
This was one of the most difficult tasks and because of the same reason, the applications could not be integrated with the 3rd party backend or even the 1st party had to struggle.
When API came into play, it introduced a lot of authentication methods like Oauth, HMAC, etc. This allowed developers to transfer the data in a secured manner and only access the data which is allocated to the user.
Scalability was one of the topmost issues of the traditional method. You literally had to buy a server and replicate the data. This took a lot of effort, and sometimes there were cases when the users were getting old data. The API resolved this issue much efficiently. API helped the developers to scale their systems by providing multiple models for scaling the system.
In this model, the data is brought to a central data store which is part of the API platform, and this store is bidirectionally connected with the backend system asynchronously. So whenever an API endpoint is called, it directly hits the data store and performs the required operations.
In this setup, the API endpoints directly communicate with the backend system or any 3rd party API and there’s no data store here. Here the endpoint is directly responsible for all the operations and calculations. This ensures that the data which is being fetched is updated. While in the centralized model the datastore had to maintain an asynchronous connection with the backend to get the updated data.
In this setup, the API maintains a cache where the data is stored and whenever there’s a change in the backend updates the data store.
Companies started to shift to APIs after 2003 when they saw how API can be used to benefit their company. Companies like Salesforce, Facebook, Amazon, Twitter, etc opened their doors for developers to integrate their services into 3rd party applications through API. In 2003, Delicious launched its API for sharing, storing, and discovering web bookmarks. In 2004, Flickr launched its first API to share and embed their photos. In 2006, Facebook launched its first API to share photos, profile information, etc.
Real-time transfer of data became important to improve the user experience. In order to transfer the data fast, the developers shifted to API. Where the data became compact in size and easy to transfer. It was asynchronous and bi-directional which means if the data is updated on one end, the change will be reflected on the other end too. This helped a lot of analytics applications like Google Analytics where you know, you can check who is visiting your website in real-time or Facebook where you can send messages from your mobile application and the receiver using the web version will receive the message instantly.
When new applications were made, the developers had to keep the stack on a single platform. They didn’t have any other option at that time. To integrate another application, they had to develop everything from scratch since they didn’t have all in one data format. With the introduction of JSON, XML, CSV, etc the transfer of data becomes easier.
API natively uses JSON data type to transfer the data. This JSON can be understood by both client-side languages as well as server-side languages as they have got libraries to decode the JSON. Now it doesn’t matter on which platform your backend is built, the API will act as a layer that will handle the request and transfer the data. Even from the terminal, you can make API requests.
When the Apple iPhone was launched it came with an app store same as the case with Android. This allowed developers to create mobile applications and launch them in stores. This attracted a lot of investors towards API driven applications. Companies like Google Maps launched their APIs that can be integrated with any application. One of the biggest examples is Uber, their business is heavily dependent on Google Maps API. Instagram also launched its iPhone application and shifted towards Android and other platforms. All of this was only possible using APIs.
This testing was made possible by WebDriver APIs. These APIs, help your code to communicate with the browser and perform different tasks on the browser. People also use these APIs to automate data scraping, download files, etc.
There are different libraries available to make your task easier and communicate through WebDriver APIs like Selenium and Puppeteer.
There’s a lot of advancements ongoing in APIs. Almost 90% of developers use the API and almost every application is dependent on API. REST API is the most popular form of API, you can also use SOAP as well as GraphQL. GraphQL is another method of creating efficient APIs. You can check out our article on GraphQL.
There are new business models that use event-driven API. They’re a kind of architecture where events are defined at the technical as well as business level. These events can be triggered by API and webhooks.
Another improvement is being made on the standardization of the API. Communities like OpenAPI have defined some standards which are accepted broadly by the REST APIs.
We have covered a lot about APIs in this article. Over the past decade, developers have accepted the APIs and they’re completely dependent on them. We have covered how API has helped the tech industry to become more advanced. The API is not only being used in the tech industry only but also in the education sector, health sector, and other sectors as well. In case we have missed anything here, please let us know in the comment section.