Life without API– Is it possible?
API – Application Programming Interface
An API allows your application to interact with an external service using a simple set of commands. It allows developers to add specific functionalities to their applications and can speed up the development process.
Most of the applications we use in our day to day life rely on APIs. During winter, first thing in the morning as soon as I wake up, I check for the weather in iphone app to ensure that my kids are wearing layered dresses for school. From weather forecast, API goes on and on like to order food through any application, searching nearby exits while traveling etc. Life without using API is simply not possible nowadays.
Let’s take an example of I-Exit application. I am on the way by road to Atlanta and would like to refill the gas (of course with the better price). I check in I-exit for the nearby exit which has gas stations along with the price and take exit accordingly. How do I – Exit get the current price? Is someone go and check and update the price? No way. It’s not possible at all.
This is where API comes into picture. Someone might have already built an application to get the current gas price in each area and I-Exit gets data from the already built application. I-Exit doesn’t need to develop any new application for this which saves time for the developers to speed up their development process. This interface is called as Application Programming Interface.
Types of API’s
There are various types of API’s based on release polices and use cases.
Types of API based on Release Policy
Open APIs – Open APIs are generally for public and there are minimal restrictions to use.
Partner APIs –APIs exposed to the strategic business partners. They are not available publicly and need specific entitlement to access them.
Internal APIs – Internal to application and are not exposed.
Composite APIs – Allow developers to access several endpoints in one call.
Types of API based on Use Cases
Representational state transfer (REST) is an architectural style and approach for communications purpose that is often used in various web services development.
Generally, Client request has been sent to the server and the server sends the response in a structured format either XML or JSON format. JSON format is basically a format of an object where the object values are returned to the user and XML format follows a hierarchical data structure. The only issue is we need to use lot of methods to get information from the server even if the data is returned in the simple format like JSON or XML. This is where, REST API comes into picture. REST API creates an object on the server side and returns the value (state) of the object in response to the client request. That is why it is called as Representational State Transfer API.
Features of REST API
· Simpler than SOAP
· Proper documentation
· Shows proper login information error messages
Principles of REST API
The main six principles of REST API were outlined in a dissertation by Roy Fielding back in 2000.
Methods of REST API
We use HTTP method to Create Read Update and Delete the resource (the data which client is looking for).
Simple Objects Access Protocol (SOAP) API is a standard communication protocol system and designed to create, recover, update and delete records like accounts, passwords, leads, and custom objects. It permits processes using different operating systems like Linux and Windows to communicate via HTTP and its XML. SOAP APIs take the advantages of making web based protocols such as HTTP and its XML that are already operating the all operating systems that are why its developers can easily manipulate web services and get responses without caring about language and platforms at all.
A Remote Procedure Call is a specification that allows for remote execution of a function in a different context. RPC extends the notion of local procedure calling but puts it in the context of an HTTP API.
It takes a number of calls to the REST API for it to return the needed staff. So GraphQL was invented to be a game-changer. GraphQL is a syntax that describes how to make a precise data request. Implementing GraphQL is worth it for an application’s data model with a lot of complex entities referencing each other.