Skip to main content

Command Palette

Search for a command to run...

All about APIs

Published
2 min read

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:-

  1. SOAP API :- more secure, slow and heavy, less code

  2. 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:-

  1. An Endpoint- the touchpoint between API and another system

  2. Method- specifies what a client must do to make a request or defines the response that the client receives in return

  3. 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.

  4. Header- HTTP headers refer to the metadata associated with the request and the response

  5. Parameter- it refers to the different variables in a URL pathway

  6. Status code- indicates the status of the sent response

API Methods:-

  1. GET

  2. PUT

  3. PATCH

  4. POST

  5. DELETE

Status Code:-

  1. 1xx: tells transfer protocol-level information

  2. 2xx: success

  3. 3xx: redirection

  4. 4xx: Client error

  5. 5xx: Server error

Ways to keep APIs safe:

  1. Password hash

  2. HTTPS

  3. API key

  4. OAuth

  5. Timestamp and parameter validation

How is an API made:-

  1. Route

  2. Controller

  3. Models