MARJ
SIGN IN
VIL2checked 2d ago

What an API Is and How to Call One

A working script that fetches live data from a real public API and does something with it
Before this

⚠️ Version note: the specific public APIs named here occasionally change their endpoints or add key requirements. The concepts — request, response, JSON, status codes — are stable across the entire web. Last checked: 24 July 2026. If an example API has changed, the swap-in note at each step tells you what to look for.

The word is everywhere and nobody defines it

"Just use the API." "They opened up their API." "The app talks to the backend API." You've heard it a hundred times, and it's usually said as if you already know what it means.

Here's the whole thing, in one image: an API is a waiter.

You (a program) sit at a table. The kitchen (someone else's server, database, service) has what you want but you can't walk in. So there's a menu of things you're allowed to ask for, you place a specific order with the waiter, and the waiter brings back exactly what you asked for, on a plate, in a standard format. You never see the kitchen. You don't need to.

That's an API — an Application Programming Interface. It's a defined set of requests one program is allowed to make to another, and the responses it'll get back. It's how your weather app gets the weather, how a site logs you in "with Google", how an AI tool talks to a model. Once you can call one, a huge amount of what looked like magic becomes "oh — it just asked another program."

This lesson gets you from "I've heard the word" to "I wrote a script that fetches live data." It's the gateway to AI-15 (calling an AI from your own code), TC-13 (building a real project), and most of modern programming.

What you'll have at the end

  • A real mental model: request → response, in a standard format
  • The four things every request has, and the status codes that tell you what happened
  • A working script pulling live data from a public API and using it

Prerequisite: TC-04. You'll write Python, use a list and a loop, and read a dictionary — all from that lesson.


Step 01

Request and response, in the browser (6 min)

You've been calling APIs for years without knowing it. Every web page is a request and a response.

Try this — paste it into your browser's address bar:

https://api.github.com/users/torvalds

You'll get back a screen of text in { curly braces }. That's an API response. You made a request (asked GitHub for a user), and it sent back structured data about that user. No app, no library — a URL in a browser is a request.

The two halves, always:

  • Request — you ask for something at a specific address.
  • Response — you get back data, in a standard format (almost always JSON — step 3).

✅ Check: you pasted the URL and got back a block of { } data. Change torvalds to your own GitHub username (or anyone's) and watch the response change.

If it moved: any public "who is this user" style API works. If GitHub's has changed, search "free public API no key" — api.github.com, pokeapi.co, and open government data APIs are reliable.


Members

The rest of this walkthrough is for members

Behind this: the full step-by-step, the exercise with a verifiable output, and the downloadable cheatsheet. Everything you've read above stays free, always.

$7.99/mo · 7-day free trialWeekly $2.99Yearly $59
See plansCancel in two clicks. No dark patterns.
Mark it when you've got the output in hand.

← All Technical Foundations lessons