What is REST API?

lumenwrites
Digital Mind
Published in
2 min readMar 6, 2017

(explained in 5 minutes or less)

API stands for Application Programming Interface. Basically, it’s something that allows different programs to interact with each other.

For the most part, when we talk about APIs on the web, we mean REST APIs. REST stands for “Representational state transfer”. REST is an underlying architecture, designed with the purpose to make the calls between computers simple.

It works the same way all websites do — the client sends a request to the server, and receives a response. The response is simply some data in JSON format, which makes it easy to use and interpret. For example if you want to get a list of posts from my blog, you can go to this url:

http://api.digitalmind.io/api/v1/posts/

and you will receive a response that looks like this:

HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
"results": [
{
"title": "What is Recursion?",
"slug": "what-is-recursion-68e8f",
"body": "(post body is here...)",
"tags": [
"simply-explained"
]
},
.... (more posts here)
]
}

Basically it allows you to receive any data in both human- and machine-readable format.

This API can be used by anyone who wants to create, for example, an iOS or Android app for reading my blog, or for anyone who wants to write a script that would analyze my posts.

Many major sites, like Facebook or Twitter have an open API that allows developers to write applications and bots that can interact with them. You can not only read the data with it, but write it as well — you have probably seen many posts written by bots or by AutoModerators on reddit.

There are many other great and useful examples of APIs. Google Maps allows you to enter a city and receive it’s GPS coordinates, openweathermap.org allows you to receive the weather data about any point in the world, etc.

Finally, a lot of modern websites use this kind of APIs to fetch and render their own data. Instead of returning you the content in html form immediately, they send you a bunch of javascript code which then gets content from the API and renders it into your browser. That allows people to create all sorts of cool and interactive single page apps.

--

--