𝗗𝗮𝘆 𝟱 of #100DaysOfCode: 𝗧𝗿𝗶𝗴𝗴𝗲𝗿𝗶𝗻𝗴 𝘆𝗼𝘂𝗿 𝗳𝗶𝗿𝘀𝘁 𝗔𝗣𝗜
What is an API?
An API (Application Programming Interface) is a set of rules and protocols that allow different software applications to communicate and interact with each other.
In other words, An API is like the person in the middle that links the server side with the client side.
Take the famous restaurant example, where the waiter is the person in the middle between the customer and the chef.
As a customer, you cannot directly enter the restaurant’s kitchen and tell the chef what you want to order, but you have to mention your order to the waiter and the waiter goes and mentions to the chef what you want.
As a chef, you cannot go outside your kitchen and serve the food directly to the customer, but you can call the waiter to deliver the food instead.
So, the customer acts as the front-end or the client side, the chef acts as the server side and the waiter acts as the API that connects the client side with the server side.
𝗦𝗼, 𝗵𝗼𝘄 𝗰𝗮𝗻 𝘄𝗲 𝘁𝗲𝘀𝘁 𝗔𝗣𝗜𝘀?
We can test APIs through the website/ mobile application itself by checking the API response in the console or through a backend API testing and automation platform such as Postman or Swagger.
To test on Postman, you should do the following:
add the API you need to test
select HTTP Method
Add the needed authentication and attributes
A JSON Response and status =200 shows if the API is triggered successfully
Selecting HTTP method, depends on the action that the endpoint should do:
𝗚𝗘𝗧: Retrieve data from a server at the specified resource.
𝗣𝗢𝗦𝗧: Submit data to be processed to a specified resource.
𝗣𝗨𝗧: Update or create a resource at the specified resource.
𝗗𝗘𝗟𝗘𝗧𝗘: Delete the specified resource.
𝗣𝗔𝗧𝗖𝗛: Apply partial modifications to a resource.
𝗢𝗣𝗧𝗜𝗢𝗡𝗦: Describe the communication options for the target resource.