You might have heard people talking about something called an API which stands for Application Programming Interface. This article explains what is an API , types of api architecture, and how does api work with example in the real world.
Contents :
What is an API ?
API is the acronym for Application Programming Interface, which is a software program that allows two applications to talk to each other (mainly for exchanging data).
How Does API Work Example

To learn more about what is an api and how does it work, let’s start by describing a very basic example. For this situation we have one client application which is also going to be a website–now said website wants to include an authentication method for some pages on their site.
There are two ways to implement authentication mechanism which are as follows :
- Method – I : Building an authentication system from scratch – it will include features like signing up, logging in, and resetting passwords.
- Method – II : Using an API that has already been built, like Google’s sign-in API, It provides all the features you need – logins, registrations, forgotten passwords…
Our goal is to understand how does API Works, So we will consider the Method – II
Google Sign-in API provides a unique key to each website, which allows Google to track any unauthorized actions made by our client application.
Now, let us understand how Google SignIn API fulfilling our requirement. Firstly, Our website will trigger the google SignIn API with a unique key that was assigned to it, Now google SignIn API will check whether the request is valid or not if it is valid then it will accept the request and interact with the Google database and then send a response back to our website i.e., client_application.
Types of API Architectures :
An API architecture is made up of a set of rules that all APIs should follow, which are typically guidelines for what data an API shares with clients and how it sends/receives information.
The following are the most popular API architectures in use today :
REST API :
REST, which stands for representational state transfer, has become an increasingly popular way to develop web APIs these days. REST is scalable, lightweight, and easy to use – three features that make it great for creating an API.
The following are some of the guidelines which are followed when transferring data between a server and its requestor (client)
- Client-Server Separation : All client-server interactions must be in the form of a request from the client, and the server should accept that request and send a response back to the client, ( Imp: Servers can’t request and clients can’t respond )
- Uniform Interface: All requests and responses must use HTTP as the communication protocol and by default Server responses are in the format of JSON( JavaScript Object Notation ).
- Stateless: Each client-server interaction is independent of every other interaction. The server stores no data from client requests and remembers nothing from past interactions.
- Cacheable: Server responses should indicate whether a provided resource can be cached by the client and for how long.
By following these guidelines, REST APIs can be used for quick, easy, secure data transfers, making them a popular choice among developers.
SOAP :
- SOAP stands for Simple Object Access Protocol which is used for transmitting data across networks.
- SOAP is standardized by the World Wide Web Consortium (W3C) and utilizes XML to encode information.
- SOAP strictly defines how messages should be sent and what must be included in them. This makes SOAP APIs more secure than REST APIs.
- For this reason, SOAP is used internally for data transfers that require high security and one more advantage of SOAP is that it works over any communication protocol (not just HTTP, as is the case with REST).
RPC :
- RPC stands for Remote Procedural Call
- RPC protocol is the most straightforward of the three architectures. Unlike REST and SOAP which facilitate the transfer of data, RPC APIs invoke processes. In other words, they execute scripts on a server.
- RPC APIs can handle either JSON (a JSON-RPC protocol) or XML (an XML-RPC protocol) in their calls. XML is more secure than JSON, Though the RPC protocol is strict, it’s a relatively simple and easy way to execute code on remote networks
If you have any questions or suggestions, please feel free to leave a comment below.