Every time you open a weather app, pay with a card, or see recommendations on YouTube — an API is at work. But what exactly is it?
What Is an API
Official Definition
API (Application Programming Interface) is a set of rules by which one program can ask another for data or functionality.
Simply put: an API is a contract between two programs that defines how they communicate.
The Restaurant Analogy
Think of a restaurant:
- You are your program
- The kitchen is the server with data (a database, business logic)
- The waiter is the API
You don’t walk into the kitchen yourself — that would be chaotic and unsafe. You tell the waiter: “Bring me the soup.” The waiter goes to the kitchen and brings back the dish. You don’t need to know how to cook it.
APIs work the same way: your program doesn’t reach directly into the server’s database. It sends a request through the API — and gets back a ready-made response.
What This Looks Like Technically
Your code Server
│ │
│── GET /jokes/random ────▶│
│ │ processes the request
│◀── {"value": "..."} ────│
│ │
- Your code sends a request to an address
- The server receives the request and prepares a response
- The response arrives in JSON format
Why APIs Exist
Without APIs:
- Every weather app would have to collect data on its own
- Every site would have to build its own authentication system from scratch
- Maps would have to be redrawn for every application
With APIs:
- Thousands of apps share the same weather data
- Google, GitHub, and Facebook provide authentication to any site
- Google Maps can be embedded in any application
APIs in Real Life
| What you do | Which API is working |
|---|---|
| Check the weather | OpenWeatherMap API |
| Pay by card | Stripe / payment processor API |
| Sign in with Google | Google OAuth API |
| View a map | Google Maps API |
| Share a post | Twitter/VK API |
| Talk to ChatGPT | OpenAI API |
Types of APIs
REST API — the most common. Works over HTTP, returns JSON. This is what we study in this course.
GraphQL — you request exactly the fields you need, nothing more.
WebSocket — bidirectional real-time communication (chat apps, games).
gRPC — a fast protocol for server-to-server communication.
In this course we work with REST APIs — the industry standard.
Public vs Private APIs
Public APIs are open to all developers. Examples:
- chucknorris.io — Chuck Norris jokes (free, no key required)
- OpenWeatherMap — weather data (free, requires a key)
- NASA API — space data (free, requires a key)
- GitHub API — repository data (partially free)
Private APIs are used internally within a company — for example, the API between the frontend and backend of your own project.
Summary
An API is the official way to get data or functionality from another program. You only need to know “what to ask for” and “what you’ll get back” — the kitchen’s internals are none of your concern.
💬 Comments (0)
No comments yet
Be the first to share your opinion about this article!