Backend Basics • APIs

What Is an API?

Learn how software talks to each other — and why your apps can share data without you lifting a finger.

Scroll to start

What Is an API?

API stands for Application Programming Interface. In plain English: it is a set of rules that lets one piece of software talk to another — without needing to know how the other program works inside.

Think of a restaurant. You (the user) sit at a table. The kitchen (the system) makes the food. The waiter (the API) takes your order and brings it back. You never walk into the kitchen — you just talk to the waiter. An API works the same way.

Without an API

  • App A has to know how App B works internally
  • Changing App B breaks everything connected to it
  • No security — direct access to raw data
  • Developers rebuild the same connections over and over

With an API

  • Apps only agree on how to exchange information
  • Each side can change independently
  • Controlled access — you decide what gets shared
  • One integration works with any app that follows the rules

Why APIs Power the Modern Web

Every time you see content from another service inside an app — a Google Map in a real estate website, a Stripe checkout, a tweet embedded in a news article — that is an API at work. APIs are the reason one app can pull in data from dozens of other services without breaking a sweat.

Without APIs, developers would have to rebuild every integration from scratch. With APIs, you build it once and connect to anything.

Real Example

When you book a flight on Expedia, it does not run its own airline reservation system. It asks airline APIs for seat availability, hotel APIs for packages, and payment APIs to process your card — all in the background, all through APIs.

How an API Request Works
📱
Your App
Sends a request
🌐
Internet
Routes the request
🖥️
API Server
Receives and processes
📦
Response
Data returned as JSON
usually milliseconds_

The Four HTTP Methods

When your app talks to an API, it uses one of four main actions. You have probably seen them before — they are the backbone of how the web moves data.

01
🔍

GET

Reading data. You ask for information and the API sends it back. Like loading a webpage, but for data. A weather app uses GET to pull today's forecast.

02

POST

Creating new data. You send information to be added. Signing up for a new account? The app POSTs your details to create your profile.

03
✏️

PUT / PATCH

Updating existing data. You change something that is already there. Changing your profile picture? That is a PUT or PATCH request.

api-request.sh
# GET — fetch weather data
fetch('https://api.weather.com/v3 forecast?city=Toronto')

# POST — create a new user account
fetch('https://api.mysite.com/users', {
  method: 'POST',
  body: JSON.stringify({ name: 'Alex', email: 'alex@email.com' })
})

# PUT — update a user's profile
fetch('https://api.mysite.com/users/42', {
  method: 'PUT',
  body: JSON.stringify({ name: 'Alex Chen' })
})

A Real API in Action

Imagine you are building a movie app. You do not have your own database of 10,000 movies — instead you use the free TMDB API. Your app sends a GET request, and TMDB sends back a list of movies as JSON.

api-response.json
{
  "page": 1,
  "results": [
    {
      "title": "Dune",
      "year": "2021",
      "rating": 8.5,
      "genre": "Sci-Fi"
    },
    {
      "title": "Everything Everywhere All At Once",
      "year": "2022",
      "rating": 8.9,
      "genre": "Comedy"
    }
  ]
}

Key Insight

JSON — JavaScript Object Notation — is the language APIs use to send data back and forth. It looks like JavaScript objects but works in any language. Once you understand JSON, you understand the language of the web.

Knowledge Check

Test what you learned about APIs.

3 Questions

Question 01

What does API stand for?

Question 02

Which HTTP method is used to retrieve data from an API?

Question 03

What is JSON used for in APIs?

🏆

You crushed it!

Perfect score on APIs.