All about APIs
API stands for application programming interface. It acts as a mediator transporting requests from client to server and response from server to the client (browser).
The different parts of API include
Types of APIs:-
SOAP API :- more secure, slow and heavy, less code
REST API:- less secure(hence requires more layers of security), fast and light, more code, used more widely nowadays.
API consists of the following things:-
An Endpoint- the touchpoint between API and another system
Method- specifies what a client must do to make a request or defines the response that the client receives in return
Body- request body refers to the data sent by client to API, and response body refers to the data sent by the API to the client.
Header- HTTP headers refer to the metadata associated with the request and the response
Parameter- it refers to the different variables in a URL pathway
Status code- indicates the status of the sent response
API Methods:-
GET
PUT
PATCH
POST
DELETE
Status Code:-
1xx: tells transfer protocol-level information
2xx: success
3xx: redirection
4xx: Client error
5xx: Server error
Ways to keep APIs safe:
Password hash
HTTPS
API key
OAuth
Timestamp and parameter validation
How is an API made:-
Route
Controller
Models