APIs and Types of APIs
APIs and Types of APIs
API - API stands for Application Programming Interface .In basic terms API’s are a set of functions and procedures that allow for the creation of an application that access data and features of other applications, services or operating systems. It can also be referred to as a contract between an information provider and information user.
In other words if you want to interact with a computer or system to retrieve information or perform a function , an API helps you communicate what you want to the system , so it can understand and fulfill your request.
Good API’s make it easier to develop computer programs by providing all the building blocks , which are then put together by the programmer.
An API is not a code or a server , it is code that governs the access points for the server .
There are four main types of WEB API’s
Open API’s : These APIs are publicly available and are also known as Public APIs . There is no restriction to accessing these APIs
Partner APIs : These APIs are not publicly available . A developer needs specific rights or licenses to accesses these type of APIs
Internal APIs : Internal APIs are also known as Private APIs . These are usually designed for internal use within the company .
Composite APIs : This type of APIs combines different data and service APIs .Its main uses are to speed up the process of execution and improve the listeners in the web interface.
Here I will talk about two of the main web service APIs
REST API - Representational State Transfer also known as RESTful API .REST is a set of architectural constraints not a protocol or a standard . API developers can implement REST in a variety of ways. When a client request is made via a RESTful API it transfers a representation of a state of the resource to the requester or endpoint .
This information is delivered in one of the many formats via HTTP
JSON (Java script object notation)
JSON is the most generally popular programming language to use , because it is readable by both humans and machines .
Image copied from medium.com
SOAP - SOAP or Simple Object Access Protocol is a web communication protocol designed for Microsoft Back in 1998.Nowadays it is mostly used to expose web services and transmit data over HTTP/HTTPs
SOAP , Unlike REST API supports XML data format only and strongly follows preset standards as messaging structures and a set of encoding rules .
Though Most web data exchange happens over REST,SOAP is not disappearing anytime soon as it is highly standardized, allows for automation in some cases and is more secure .
SOAP Message Structure
As mentioned above Soap works with XML only. XML is not the only reason why Soap is considered heavy compared to REST.IT is also because the way Soap messages are composed .
SOAP API requests and responses look like an enveloped message that consists of four elements where each element has a specific function.