Lecture 20: What is an API?
Imagine you’re at a restaurant. You have a menu with a list of dishes you can order, along with a description of each dish. When you decide what you want, you tell the server, and the server goes to the kitchen to tell the cooks what to make. The cooks prepare your meal, and the server brings it back to you.
In this scenario, think of:
- The kitchen as a system that does a particular task (like a software application).
- The menu as the API (Application Programming Interface).
- Your order (what you want the system to do) as the request.
- The dish that’s brought to you as the response.
So, an API is like a menu that tells you what requests you can make to a software system. It’s a set of rules that lets different software applications or components communicate with each other. When you use an API, you’re essentially sending a request to a system (like ordering a dish) and getting a response back (like the dish served to you).
For example, if you’ve ever used a weather app on your phone, that app probably used an API to get weather data from a service.
Here are some key points about APIs:
- Interface: API stands for Application Programming Interface. It’s an interface, meaning it’s a way for different pieces of software to interact with each other.
- Requests and Responses: You send a request to an API to do something or get some data, and it sends back a response.
- Methods: APIs have different methods or actions you can take, like getting data (
GET
), sending data (POST
), updating data (PUT
), or deleting data (DELETE
). - Data Formats: APIs often use standard data formats like JSON or XML for the exchange of information.
In short, APIs are like messengers or translators that let different software systems talk to each other, request actions, and share data. They are fundamental in creating interconnected systems and applications in the world of computing.
Resources
-
Big list of publicly available free APIs that do not require authentication via API keys:
https://mixedanalytics.com/blog/list-actually-free-open-no-auth-needed-apis/ -
Another big list: https://github.com/public-api-lists/public-api-lists