Hashing? Why? How?

Hashing is the process of converting an input of any length into a fixed sized value using a mathematical function. The algorithm changes the message to be hashed, which is called the input into its…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




What is a RESTful API?

API generally stands for Application Programming Interface. It’s a very broad term though. There various kind of APIs. There are API in your computer operating system, your mobile phone also in refrigerators and so on. But in here we are going to specifically talk about Web APIs.

Web API is basically a contract between one piece of software and another piece of software. Usually consists of a structured request and a structured response. One software asks for some information formatted in a certain way and another software says I will give you this data in that format.

To understand this concept easily we can see the analogy below:

Here the customer is a piece of software who asks for some certain meal to the waiter. In another corner the chef is another piece of software. S/He processes the meal in the way the customer wants. And the waiter bring it back to the customer. So we can say the customer is the client side software. Who asks for something in a certain manner. And the chef works as the server. And the waiter in the API.

Let’s look another analogy on how web API works:

Web API analogy 2

If we consider the toy above as a certain API, it is designed to take certain shapes. So the user has to shape them as triangle, circle or a square. Otherwise it won’t accept it. Same for the web API. If the user doesn’t format request in a certain manner it won’t accept it and will provide some kind of error message.

Now let’s talk about REST. REST stands for Representational State Transfer. It’s actually an architectural style for designing network applications. It’s almost always HTTP(Foundation of the communication of the internet. Every time we are browsing a web page, it’s making a http request to a server somewhere ). Relies on stateless, client-server protocol.

REST was made to treat the objects on the server side as resources that can be created, updated or deleted. An ideal example of a server side object can be a blog post. We can create a post but a POST request, delete it with a DELETE request. As we already know REST uses HTTP protocol and process data in certain ways like JSON, it can be used by any programming language. How awesome is that?

So now we can combine. API is a messenger and REST lets us use HTTP protocol to format those messages.

So now, what is a RESTful API. RESTful API and REST API are actually the same.

Now that we know about the REST API, lets talk about the HTTP methods and requests that can be made to a server through HTTP.

There are also some other HTTP methods that are less used:

The URI/URL where api/service can be accessed by a client application.

The endpoints that we mentioned above, id we can get data by such URI or URL without any authentication then they are public API. But sometimes we need some kind of authentication of some requests.
An easy example can be seen below:

Use your username there and BOOm . You can see you user details in your response body.
Github permits certain amount of API requests per hour for free. If you pass the limit, you will have to authenticate yourself following the steps in the link above.

I hope you enjoyed this blog. If you want to read more of my blogs than you can follow me on here in medium.

I am Anurag. Working professionally as a Software Engineer since 2014. I often write blogs on the questions I often see people asking and find important. In my free time, I like to develop web and mobile apps that simple and useful. You can connect with me here:

Happy Coding 😀

Good Luck

Add a comment

Related posts:

THE EFFECT of Human Cell Growth Factors on hair growth

Thousands of rands of hard earned cash is spent on restoration of hair growth. The frustration of this unwanted phenomenon is experienced by men and women of all ages. Currently, only low level…

Growing Up With South Indian Parents

My parents moved to America from the southern part of India over 30 years ago. My Sister and I were born in America in the Metro Detroit area. And that has been the cause of many arguments and…

Escrever

Escrever sempre foi uma paixão de há muito tempo, a ideia de colocar as minhas ideias, os meus pensamentos ou as minhas histórias em algum local de partilha, sempre foi um objectivo pessoal. Sempre…