APIs and their terminologies
hello readers, an article after a long time. Myself Shivani Y. - frontend developer helping you to know more about APIs and their terms.
I bet you have heard the term APIs many times before. It doesn't matter whether you are a frontend developer or a backend developer - APIs gonna stuck forever with you from the phase of development to understanding the business ideas better.
I will be stating some real-life examples and projects that I have worked on over the months solely based on APIs.
APIs are the building blocks for app creation integrations.
APIs [ acronym for Application Programming Interfaces] - a set of rules or we can say protocols explaining how computers and applications should communicate with one another. Imagine APIs - as a layer between an application and the web server that processes data transfer between the system.
How does an API work?
Imagine you want to place an order on any e-commerce website and while processing that, understand the underlying working of APIs -
You are a client - searching for a cool pair of sneakers - you initiate an API call to retrieve the information - this is called a request. This request is processed from your application to the web server via API's URI (Uniform Resource Identifier) and includes a request verb, headers and sometimes a request body - all including your request for cool pair of sneakers.
After you make a valid request that can be accepted by APIs. They generate a call to the external program or web server.
The server sends a response ( which usually you see as 404, 504, 200 & so on) to the API with the requested information about your cool pair of sneakers.
The API transfers the data to the initial requesting application, which gives you the results after hitting the enter on the search button.
That's how APIs work for all your searches and orders.
Let's move forward with the types of APIs and API protocols.
Types of APIs
Open Source APIs -
These APIs can be accessed via HTTP protocols, which we will discuss later in this article. Also known as public APIs.
Partner APIs -
These are open or exposed to some partners. To access these APIs you need to complete some onboarding process to get the access and credentials to work or use them further.
Internal APIs -
These APIs remain hidden from external users. These are private APIs - only accessible to the company members, intended to use for improved productivity and communication across different internal development teams.
Composite APIs -
These APIs are combined with multiple data and services APIs. These services allow developers to access several endpoints in a single call. Composite APIs are useful in microservices architecture where performing a single task may require information from several sources.
Types of API protocols
There are many API protocols but the most used & loved API protocol - is REST.
REST (Representational State Transfer) is a set of web API architecture principles, which means there are no official standards (unlike those with a protocol). To be a REST API (also known as a RESTful API), the interface must adhere to certain architectural constraints. It’s possible to build RESTful APIs with SOAP protocols, but the two standards are usually viewed as competing specifications.
or
REST is a stateless architecture that generally runs over HTTP. The REST style is resource-based (nouns) which have their own unique URI, and operations on those resources are limited to HTTP verbs (GET, POST, PUT, and DELETE).
Other protocols -
SOAP (Simple Object Access Protocol) is an API protocol built with XML, enabling users to send and receive data through SMTP and HTTP.
XML-RPC is a protocol that relies on a specific format of XML to transfer data, whereas SOAP uses a proprietary XML format. XML-RPC is older than SOAP, but much simpler, and relatively lightweight in that it uses minimum bandwidth.
JSON-RPC is a protocol similar to XML-RPC, as they are both remote procedure calls (RPCs), but this one uses JSON instead of XML format to transfer data. Both protocols are simple. While calls may contain multiple parameters, they only expect one result.
APIs Terminologies
Moving forward with APIs terminologies -
Access & Secret Keys
A client needs some credentials to access the APIs and these keys are tokens which are necessary to make API calls.
Cache
The cache is a software or hardware component that stores data so users can access and retrieve that data faster. Cached data might be the result of a copy of certain data stored elsewhere. Cache reads data and retrieves it faster than you would otherwise.
HTTP protocols
HTTP defines a set of request methods to indicate the desired action to be performed for a given resource. To send a request there's generally a verb associated with it.
GET
Uses only to retrieve the data. Just like your search - you just needed the result with cool pair of sneakers.
HEAD
The head method asks for a response identical to a GET request, but without the response body.
POST
The POST method is used for changes in the state or side effects on the server.
Just like placing the order - there's the change in the state and side effects on the server leading to the next process.
PUT
The PUT method replaces all current representations of the target resource with the request payload.
DELETE
The DELETE method deletes the specified resource.
PATCH
The PATCH method applies partial modifications to a resource.
Request Payload
The payload of an API is the data you are interested in sending to the server when you make an API request. Simply put, it is the body of your HTTP request and response message.
Just like your cool pair of sneakers now with more details - brand, colour, gender and so on, which are often on the server received as the parameters for the API calls.
Paths
Paths are the resource URLs the API developers choose to expose their API. Each path can have a GET/PUT/POST/DELETE HTTP action defined. Paths can have defined parameters.
JSON
(JavaScript Object Notation) - much like the data in the object. Lightweight interchanging data format.
Endpoint
An endpoint is the end of a communication channel. When APIs interact with other systems, each touchpoint of interaction is considered an endpoint.
API Integration
In simple terms, API integration connects two or more applications to exchange data between them and connect to the outside world.
Parameters
Parameters are special types of variables used in computer programming to pass information between procedures and functions. An argument to a function is referred to as a parameter. Adding three numbers, for example, may require three parameters.
These are the basic terms you should know as a developer & human when you are studying APIs.
I will be writing an article about how APIs are useful for business & growth and can be led as a product in an industry with some use cases. Stay tuned !!!
- hope this article helped you in some ways achieve your goal to understand the APIs.
Thank you 🤖