API
What is an API?
Since we're talking about REST APIs, our definition of an API will not go beyond the scope of the web.
API stands for Application Programming Interface. An API establishes a connection between programs so they can transfer data.
A program that has an API implies that some parts of its data is exposed for the client to use. The client could be the frontend of the same program or an external program.
In order to get this data, a structured request has to be sent to the API. If the request meets the desired requirements, a response which contains the data gets sent back to where the request was made. This response usually comes in the form of JSON or XML data.
In some cases, you'll need some sort of authorization to gain access to external API data.
Every API has documentation that tells you what data is available and how to structure your request in order to get a valid response.
API Example
Was that confusing?
Imagine visiting a new restaurant. You're there to order food, and since you haven't been there before, you don't exactly know what type of food they serve.
The server then approaches you with a menu so you can pick what you'd like to eat. After making your choice, the server then goes to the kitchen and gets your food.
In this case, the server is the API who is connecting you to the kitchen. The API's documentation is the menu. The request is made when you pick what you'd like to eat, and the response is the food being served.
Recommended by LinkedIn
I hope that helps you understand what an API is and how it works.
What is REST?
REST stands for Representational State Transfer. It is a standard that guides the design and development of processes which enable us to interact with data stored on a web server.
The above definition may not look as complex or "professional" as the ones you come across on the internet, but the goal here is for you to understand the basic purpose of REST APIs.
An API that complies with some or all of the six guiding constraints of REST is considered to be RESTful.
We are able to communicate with servers using the HTTP protocol. With these protocols, we can Create, Read, Update and Delete data – otherwise known as CRUD operations.
But how can we perform these CRUD operations and communicate with data on the server?
We can do this by sending HTTP requests, and that is where REST comes in. REST simplifies the communication process by providing various HTTP methods/operations/verbs which we can use to send requests to the server.
How to communicate with a server using REST APIs
As we discussed in the last section, REST APIs make the communication process with the server easier for us by giving us various HTTP request methods. The most commonly used methods are: