If you look up the term API, you'll probably find a number of definitions—some of which are rather difficult to understand.
But the key underlying idea is in the name—Application Programming Interface.
An API is an interface.
It's something that has been created to help two different systems interact with one another.
A key idea to remember is that API functionality is defined independently of the actual implementation of the provider.
Essentially, you don't need to understand the entirety of the application implementation in order to interact with it through the API.
1- It doesn't expose the implementation to those who shouldn't have access to it.
2- The API provides a standard way of accessing the application.
3- It makes it much easier to understand how to access the application's data.
When you got to a bank, the bank teller acts as an intermediary or interface between you and the bank vault.
And this is the same type of relationship we see in client-server communication.
The user or client makes a request to the API server, which parses the requests, queries the database, formats a response, and then sends it back.
1- The client sends a request to the API server.
2- The API server parses that request.
3- Assuming the request is formatted correctly, the server queries the database for the information or performs the action in the request.
4- The server formats the response and sends it back to the client.
5- The client renders the response according to its implementation.
Internet Protocol (IP) is the protocol for sending data from one computer to another across the internet.
Each computer must have a unique IP address that identifies it from all other computers connected to the internet.
- Transmission Control Protocol (TCP) is used for data transmission.
- Hypertext Transmission Protocol (HTTP) is used for transmitting text and hyperlinks.
- File Transfer Protocol (FTP) is used to transfer files between server and client
- REST stands for Representational State Transfer, which is an architectural style introduced by Roy Fielding in 2000.
- Uniform Interface: Every rest architecture must have a standardized way of accessing and processing data resources.
This includes unique resource identifiers (i.e., unique URLs) and self-descriptive messages in the server response that describe how to process the representation (for instance JSON vs XML) of the data resource.
Stateless: Every client request is self-contained in that the server doesn't need to store any application data in order to respond to subsequent requests.
Client-Server: There must be both a client and server in the architecture.
Cacheable & Layered System: Caching and layering increase networking.
- It might appear easier to design a server that isn't stateless.
- There is a reason why RESTful web servers are not allowed to remember anything about the previous requests that the user has sent.
- In short, stateless servers make your applications scalable.