Chapter 1: How Modern Applications Really Work

1. How modern applications really work

You're going to see APIs in action in the next ten minutes. Every app on your phone is having dozens of these conversations right now, with weather servers, music platforms, and payment processors. This chapter shows you what's happening underneath, then teaches you the language those conversations speak.

An API (Application Programming Interface) is a service running on a server that your application can talk to by sending requests over the internet. When you ask it "give me the weather for London," it sends back structured data in response. It's the interface that lets your code access another company's data or functionality: Spotify's music, Google's maps, Stripe's payment processing, all without needing to build those complex systems yourself.

Right now, as you're reading this, your phone or computer is having hundreds of these conversations. Your weather app is asking a server "What's the temperature in London right now?" Your banking app is checking "What's my current account balance?" Your music app is requesting "Play this song for me." The responses come back in milliseconds, so you perceive it all as seamless, but underneath the surface it's constant communication between your device and distant servers.

You're scrolling through Instagram on your phone. You see photos from friends in Tokyo, weather updates from your hometown, a news article someone shared, and an ad for shoes you looked at yesterday. Your phone isn't storing millions of photos, real-time weather data for every city on Earth, or constantly updated news from thousands of sources. That would be impossible. Instead, when you open Instagram, your phone sends a quiet request over the internet: "Show me the latest posts for this user." Instagram's servers respond with exactly the data you need, at that exact moment. When you scroll, another request goes out. When you like a photo, your phone sends another. The server confirms each one.

Understanding APIs transforms how you build software. Instead of creating everything from scratch, you can ask existing services to do the heavy lifting. Want to send SMS messages? Use Twilio's API. Process payments? Stripe's API. Show maps? Google Maps API. Get weather data? OpenWeatherMap's API. The most powerful applications are built by connecting existing services through APIs, not by reinventing every wheel.

See APIs in action right now

Before any theory, watch APIs working in real time. This takes two minutes and changes how you see every website you visit.

Step 1: open your browser's developer tools

In Chrome or Edge, press F12 on Windows or Cmd+Option+I on Mac. Firefox is the same. In Safari, you may need to enable developer features first under Safari → Settings → Advanced → Show features for web developers (or Preferences on older macOS), then press Cmd+Option+I.

Step 2: click the Network tab

You'll see a panel that's either empty or showing some activity. This is your window into every request your browser makes.

Step 3: visit a news site

Go to nytimes.com, bbc.com, or any major news website. Keep the developer tools open.

Step 4: watch the requests fly

Dozens, sometimes hundreds, of lines will appear in the Network tab. Each line is a request your browser is making, fetching articles, loading images, checking for new comments, pulling in advertisements. Click on any line that says "json" or "api" in its name.

Look at the Response or Preview section. You're seeing the actual data the API sent back, probably a structured format with fields like "title," "author," "timestamp," and "content." This is the raw information that gets turned into the beautiful page you see.

Modern news sites, social apps, and dashboards typically make dozens of API requests behind the scenes. What you saw in the Network tab is the norm, not the exception. Instead of downloading one complete page and being done, your browser often keeps fetching data through APIs and assembling it into what you see. Your browser is the client and the API runs on a server: this client-server split is how much of the modern internet works.

Leave those developer tools open as you browse for a few minutes. Watch X, Reddit, YouTube. Every interaction triggers new API requests. You're seeing the invisible infrastructure that powers the internet. And soon, you'll know how to build it yourself.

What this chapter does

This chapter is the conceptual foundation. No code yet, no Python yet, no installs. Just the mental models you need before everything else in the book makes sense.

What you'll learn
  • What an API actually is, and why so many modern apps depend on them
  • How to spot live API traffic in your browser's developer tools
  • The request-response pattern that powers all web communication
  • The components of an HTTP request: methods, URLs, headers, parameters
  • What REST means and why it's the dominant style for modern APIs
  • How JSON encodes data so any programming language can read it
  • How HTTP status codes signal success and failure
What you'll do
  • devtools_walkthrough — watch live API traffic on a major news site
  • restaurant_analogy — map kitchen, waiter, menu onto client, server, API
  • api_vs_library — pin down the difference between three commonly-confused terms
  • annotated_http_message — read an API URL, request, and response piece by piece
  • read_status_codes — recognise 200, 404, 500 in the wild and know what they mean

Next, we'll trace the request-response cycle through a few apps you used today and see why none of them could exist without APIs.