API
API stands for Application Programming Interface.
It is a set of rules, protocols, and tools that allow different software applications to
communicate with each other.
APIs define the methods and data formats that developers can use to request and exchange
information between software systems.
For example, the weather bureau’s software system contains daily weather data.
The weather app on your phone “talks” to this system via APIs and shows you daily weather
updates on your phone.
Uses of APIs:
1. Integration: APIs enable different applications to interact and share data, allowing
seamless integration between various software systems.
For example, social media platforms often provide APIs that allow developers to
integrate their apps with features like login using social media credentials, sharing
content, or accessing user data.
2. Development Efficiency: Developers can use APIs to leverage functionalities and
services provided by other applications or platforms.
This saves time and effort by not having to build everything from scratch.
For instance, payment gateway APIs enable e-commerce websites to securely process
payments without handling the payment details themselves.
3. Extensibility: APIs allow developers to extend the functionality of their applications
by integrating third-party services or libraries.
This enables the creation of more versatile and feature-rich software.
4. Access to Data: APIs provide access to data stored in different systems or databases.
This data can be utilized, analyzed, or displayed in various ways by different
applications.
For instance, weather forecast APIs allow developers to integrate weather information
into their apps.
5. Customization: APIs allow customization and tailoring of services according to
specific requirements.
Developers can use APIs to access features and functionalities that suit their
application's needs without having to create everything from scratch.
6. Automation: APIs enable automation by allowing different software systems to
communicate and perform tasks without human intervention.
This is commonly seen in workflow automation or in connecting different IoT devices.
How do APIs work?
API architecture is usually explained in terms of client and server.
The application sending the request is called the client, and the application sending the response
is called the server.
So in the weather example, the bureau’s weather database is the server, and the mobile app is
the client.
There are four different ways that APIs can work depending on when and why they were
created.
SOAP APIs
These APIs use Simple Object Access Protocol.
Client and server exchange messages using XML.
This is a less flexible API that was more popular in the past.
RPC APIs
These APIs are called Remote Procedure Calls.
The client completes a function (or procedure) on the server, and the server sends the output
back to the client.
Websocket APIs
Websocket API is another modern web API development that uses JSON objects to pass data.
A WebSocket API supports two-way communication between client apps and the server.
The server can send callback messages to connected clients, making it more efficient than
REST API.
REST APIs
These are the most popular and flexible APIs found on the web today.
The client sends requests to the server as data.
The server uses this client input to start internal functions and returns output data back to the
client.