API Stands for Application Programming Interface. APIs have a set of rules that allow different software applications to communicate with each other, generally letting them exchange data and perform operations simultaneously.
APIs are important because they allow different software systems to work together, combining their functionalities. They help developers to create new applications quickly by using existing APIs, so we don’t have to start from scratch. While Learning APIs we need some basic knowledge of HTTP.

HTTP(Hypertext Transfer Protocol) :

HTTP is the most common protocol used to access APIs on web. Http serves as the communication between Client and Server where the API hosted. It involves making HTTP requests and receiving HTTP responses.

HTTP Requests: Application sends requests to API Server. This Request includes below methods to perform action, along with any necessary data or parameters :
1. GET–> Retrive data from server
2. POST –> Sends new request to server
3. PUT –> Updates the existing data on the server
4. DELETE –> delete data from the server

HTTP Response: API Server process the request and send back an response. This response includes status code indicating the result:
Ex:
1. 200 for success
2. 404 for not found
3. 500 for Internal server error

Different Types of APIs:
1. REST(Representational State Transfer) APIs
2. SOAP(Simple Object Access Protocol) APIs
3. GraphQL APIs
4. gRPC (gRPC Remote Procedure Calls) APIs

REST APIs: REST APIs uses HTTP Methods (GET,POST,UPDATE,DELETE) to intract with resources. Its having Multiple endpoints. With each endpoint corresponding to a different functionality.
EX: http://localhost:3000/products

GraphQL APIs: GraphQL is a query language for APIs that allows requesting exactly the data needed from a server. It uses a single endpoint, making it efficient and flexible for both developers and clients.
Queries and Mutations are used for data request and responses in Graphql.
EX: http://localhost:3000/graphql

Queries: Fetch the data from server, It allows specifying the exact data needed and returns that data in the response.
Ex:
query GetAllUsers {  
getAllUsers {
         id   
user_name
     }
}
Mutations: Used to modify or update data on the server, such as creating, updating, or deleting data.
Ex:
mutation AddUser {
addUser(user_name: “John”) {
message
user {
id
user_name
}
}
}



Leave a Reply