What the Heck is ReSTful API ?

Avatar
Posted by Sarthak Shrivastava
3 months ago

What the Heck is ReSTful API ?

Why you need Api and why you need Rest concept to create API.

What is Restful api.
If this is your questions then you are on correct article.

Why need API

We are living in a world of Internet and we have many devices to access internet, which ranging from Desktop, Tables and Mobile.

Mobile is now becoming our new world, and this world (internet) works on a protocol called HTTP (Hypertext Transfer Protocol).

Think about protocol as the Rules with which our internet work.

Initially Internet was design to share information between any two computer situated apart, but we are living in 2017 this means we want our Machines to talk to other Machine.

Why need Machine talking

We know that IoT is the Future.But if you don’t know what is IoT, it means Internet of Things.

Let me simplify this,

In future you will have your house that can communicate with any other thing, this means you can remotely open or close your house’s door/window or even start or stop AC/Geezer. Even a simple toaster can be included in IoT.

All this means every machine need to share data with other machines and this is exactly we want.

But how we make machines to talk ?

Here Comes our Friend API

We know that soul of every machine is its software, this means we need softwares to talk to each other and to do so we need API

API stands for Application Programming Interface.

I think you know what Interface means, this means connecting two things and this is our main purpose

But what an API can do for us.

API allows two software programs to communicate with each other and this is cool.

What are the types of API

There are basically three types of API

Local

Web

Programe

But lets only focus on Web API.

What WEB API can do for use ?

Suppose you have an Mobile App and you want your user to have weather information, but obviously your phone does’t have a sensor to sense weather information.

But even if they have, they can only sense the weather information of place where your mobile is situated, but not for every city in the world.

For this you can find many websites which provide weather information of every city of the world, but the problem is how we can get data from that website to our App.

This awesome work can only done by using Web Api.

This website gives weather of London, but its totally human readable, but how can a machine ( or App ) can get this data.

For this you need to get data via API. Here is the data looks like for a Web Api.

Think about API as a waiter who takes order from you and go to kitchen and come back with whatever you have requested.

Similarly, Web API takes request from one Machine and go to server and come back with the data in a JSON format just like this.

But how can we start

Actually we know that there are many developer in this world with knowledge of lots of languages, so we need an structural way to create WEB API for machines so that there will be a standard or a system that every one can follow. So here comes our another Friend called “REST”.

What is REST ?

It stands for REpresentational State Transfer. But what it is ? So firstly, its not a Web Service. Its a concept, design or simply an Architecture.

What is Architecture ?

The word Architecture means :

The art or practice of designing and constructing buildings.
So with Rest is also TRUE, we are going to build our API in an structural or Proper way.

It defines how you have to create an API and what will be its structure. When a machine request something from a server, the Server return data in various formats like XML, JSON etc. (but most famous is JSON )

JSON is JavaScript Object Notation, in which you provide data in object format which any language can easily parse and retrieve information.

REST Basics

In a restful way you have to provide data with various request methods.

Like, to read information you send GET request, like wise for write POST, for editing PUT, and to destroy DELETE.

All these request transfer via the same platform called HTTP, this exactly means that the way human interact with machines via Browsers, that same way is used by machines and which results in reducing the work of creating a new platform for transferring data between machines.

Web Service

I have told you that REST is not a web Service, but what exactly a web service means.

Web Service is the Collection of protocols and standards used for exchanging data between any platform
So all this means an API created by using ReST architecture is called “ ReSTful API

Thus a Restful API is a WebService

Conclusion

  1. To have communication between machines we need API
  2. Web API are the machine readable form of your webpage ( even many websites are consuming their own API )
  3. They need a standard which we call “ ReST ”

Thanks for reading, Keep Learning.

Subscribe to my Youtube Channel or like on Facebook