API basics for beginners: What are APIs and how do they work?
Let’s be honest! We all have seen those reels on Instagram which explains about “What are APIs?” and found it interesting. But never went back to read about it in detail. Don’t worry! I have got you covered. So, let goo…
What is an API exactly?
API stands for Application Programming Interface. APIs are widely used in today’s web and mobile applications, they enable third-party developers to access the functionality and data of a system, and it also enables the integration of different systems and platforms.
In short, an API specifies how software components should interact.
Finding it overwhelming??? Don’t be! Let me explain with an example.
An API is like a waiter in a restaurant. Imagine you are sitting in a restaurant and you want to order food. Instead of going into the kitchen and preparing the food yourself, you ask the waiter to do it for you. In this case, waiter is the API.
Sounds weird, I know! Let me tell explain more. I’m not done yet.
So, you (customer) send a request to the waiter (API) by looking at the menu (API documentation) and telling the waiter what you want to order (request). The waiter then goes to the kitchen (server) and gets the food (response) and brings it back to you.
Just like in the restaurant example, when you want to use a service or get information from a website, you send a request to the API, which then goes to the server and gets the information you requested, and sends it back to you.
For example, when you open a weather app on your phone, the app sends a request to a weather API to get the current weather information for your location. The weather API then goes to the server, gets the information, and sends it back to the app to be displayed on your phone.
APIs work by making requests to a server, and the server then responds with the requested information. APIs use different types of requests to access or change data on a server. Here are few of them.
HTTP Request methods
- GET: Retrieves information from a server. This is the most common type of request and is used to retrieve data from a server.
- POST: Submits information to a server. This type of request is used to submit data to a server, such as when filling out a form online.
- PUT: Updates information on a server. This type of request is used to update existing data on a server.
- DELETE: Deletes information from a server. This type of request is used to delete data from a server.
- PATCH: Partially updates information on a server. This type of request is used to partially update existing data on a server.
- HEAD: Retrieves the header information from a server. This type of request is used to retrieve the header information from a server, such as the status code and content type.
In summary, an API is a set of rules and protocols that allow different software systems to communicate with each other. It enables developers to access and use the functionality and data of a system, without having to understand its internal structure.
BONUS POINT: Check out my API based projects.
https://nexus-six.vercel.app/
https://clicomm.vercel.app/
https://blaze-silk.vercel.app/
https://quotebuzz.vercel.app/
https://miss-minute.vercel.app/
https://github.com/boradesanket13/d3-daily-dev-digest/
Thats all for now. I hope you learned something from this blog. Feel free to hit me on Twitter! Also, do check out my repositories on GitHub and don’t hesitate to reach out to me if you would like to work on any of my existing projects or think I would be a good fit in your project.😁