As we all know, almost all the user data is stored in some database in a remote server. When a user requests data, the app (mostly named as a client) will request the server for data, the server will process the input and will give the response based on the given input. Then the app process the data received and represents it to users in an entertaining way. All the above is happening via API.

API

What is an API?

API is shortened form of Application Programming Interface. The API is the middle man between two applications, that the data can be changed between each other. In the above example, the server is a web application, the client may be a web app or mobile app, or desktop app.

Types of API

Open API – As name explains, these APIs are exposed publicly. Everyone can consume the exposed APIs E.g.: https://www.yelp.com/
Partner API – APIs that are exposed with persons who accept their terms and conditions.
Private API – Its an internal API, where is not exposed to external apps

Why API?

Implementing APIs will offer more benefits to the developers and the organization. It allows only definite users to access the data. The data transfer will be quick, easy, and can be effectively done. Here are the details
Security Since the start of the electronic era, security is most important for which everyone concerns about. If the system is implemented with API, the back end is added with a layer of security. On sending a request, minimal information is passed to the API server, the API server passes it to the DB server and sends the result to the client. It minimizes the risk of your backend being exposed to all users.
Brisky and Simple The term "Brisky" explains the speed. With help of APIs, we request minimal data and get the exact data we require in the response.

Where to implement APIs

As we saw earlier, API is another layer of security to the backend system. If there is a client-server architecture, it is recommended to use APIs to store and retrieve the data.  

Who gets used of APIs?

If there is a web application that has different endpoints like Web, Android, iOS, or desktop apps. And these are intended to access the same data here comes API in the picture. So, the API acts as a common interface for all the endpoints. The backend will not be exposed to any other endpoints, other than the API.  

Advantages of API

To summarize API(Application Programming Interface) is a simple, robust, and the fastest way of communicating with the backend server to store and retrieve the data. The product/organization has numerous advantages of implementing API service to the application.
  1. Client-server architecture
  2. The stateless connection between client and server
  3. Layered architecture
  4. Uniform interface for all endpoint clients

How APIs work?

If you have been using APIs you must have heard about SOAP and REST. REST is most commonly used in APIs nowadays due to its features. And JSON is the most commonly used data transfer programming language.

REST vs SOAP

SOAP – Simple Object Access Protocol, which is a strongly coupled messaging framework. It depends on XML and schemas. REST – Representational State Transfer is an architectural design, and it is not a protocol or standard. It can deliver the data in several formats like XML, XTL, YAML, JSON (the most commonly used programming language)  
 
REST SOAP
Definition REST is a set of architectural principles adapted by lightweight web services and mobile applications SOAP is a standard protocol which was designed to communicate between two applications
Protocol It uses HTTP SOAP itself is a protocol
Data Formats supported CSV, JSON, XML, YAML only XML
Statefulness REST is a stateless SOAP can be of stateful or stateless
Caching Supports caching of data Not supports caching of data
Security Less secure More secure compared to REST
Access methods HTTP GET, POST, PUT, DELETE HTTP POST

HTTP Requests

An HTTP request is a request made to the server by the client, which means the client is requesting the server for some resources. Each request will contain the HTTP method, requesting a resource, HTTP version, host address, and other information about the client connection. This whole part is named as the Request message header. The request may also contain some additional information sent to the server. This part is known as the Request message body.  
Refer to Table 2-1, for the structure of the HTTP request.  
 
GET /blog HTTP/1.1 host: www.genixtec.com Accept: image/jpeg, */* Request Line Request Message Header
Request Header
Blank line to separate header and body
Pageid=100&autor=manigandan Request Message Body
Table 2‑1HTTP Request
 
The request made to server should be of like GET, POST, PUT, DELETE, HEAD, CONNECT, OPTIONS, TRACE. Here most commonly used HTTP methods are GET, POST, PUT, DELETE.  
 
HTTP Method Description
GET To request a resource from the server
POST To store/send data to the server
PUT To store/update a resource to the server
DELETE To delete a resource from the server
HEAD To request header part data
CONNECT To establish intermediary connection between origin and target
OPTIONS To check the functionalities of the server
TRACE To request the changes done by the intermediaries
Table 2‑2HTTP Methods

HTTP Response

The HTTP response is the response sent from the server to the client, which means the server processed the HTTP request from the client and responds with the requested resource. Each response will be having a response code, server information, response headers, response message body.  
Refer to Table 2-3 for the HTTP response message.  
 
HTTP/1.1 200 OK Status Line
Date: Sat, 28 Aug 2021 19:13:42 GMT Connection: keep-alive Server: Apache/1.3.27 Response Header
Blank line to separate header and body
Message Body
Table 2‑3HTTP Response Message
 
The HTTP response codes have unique meaning, here the over view of the HTTP response codes.  
 
Response code Description
1xx Information purpose.
2xx Request handled successfully
3xx Request is redirected
4xx Client sent wrong request to the server
5xx Client request cannot be processed or server side error
Table 2‑4 HTTP Response Codes

JSON

JavaScript Object Notation(JSON) is a lightweight open standard file format and data interchange format that uses human-readable text to store or transmit the data. JSON is a written key-value pair format.  
 

JSON syntax:

Table 2‑5JSON syntax
 
  • Data should always between curly braces
  • Key should be always string and should be written inside double-quotes.
  • Value can be either a string, a number, a JSON object, an array, a Boolean, or null. Refer to Table 2-4 for JSON syntax.
Our flagship products DrCare247, Karesmart, RyderPlus are authenticated with OAuth. We exposed APIs to our mobile app development team and our partners who consume the APIs to build world-class products.