The Internet & APIs
How programs exchange data without ever meeting in person.
Every time you open a website, your computer sends a precisely formatted letter to another computer that might be sitting in a data center thousands of kilometers away — and gets a reply in under a second. How does your browser know where to send that letter? And how does the response find its way back?
The answer lies in three ideas that power every app, every cloud service, and every AI chatbot. By the end of this article, you will understand what happens between pressing Enter and seeing a web page — and why the exact same mechanism also powers AI services.
Client and Server: The Restaurant Model
Definition
Client, Server, and HTTP
Analogy
Definition
Where the restaurant analogy breaks: a web server handles thousands of clients simultaneously — no physical restaurant can do that. A server can itself become a client when it fetches data from other servers (microservices). And the network is unreliable: data packets can be lost, delayed, or arrive out of order — a human waiter rarely drops the plate.
Note
What happens when you type google.com?
- 1. DNS resolution: your browser asks for the IP address of google.com~50 ms
- 2. TCP connection: browser and server establish a reliable connection~30 ms handshake; with HTTPS, TLS encryption is negotiated next; with the newer HTTP/3, which Google uses, the QUIC protocol does both in a single step over UDP
- 3. HTTP request: the browser sends a GET request to the server
- 4. Server processing: Google's server generates the response page~200 ms
- 5. HTTP response: the server sends back HTML, CSS, and JavaScript
- 6. Rendering: the browser assembles the page and displays it — all in under 500 ms
Caution
Common Misconception: Internet = Web
The internet and the web are not the same thing. The internet is the global network infrastructure — cables, routers, protocols. The web (World Wide Web) is just one of many applications running on the internet, alongside email, file transfer (FTP), streaming, and much more.
Addresses: IP and DNS
Definition
IP Address, DNS, and Port
Analogy
Definition
IPv4 Addresses
4.3 B
Sounds like a lot — but not enough for every device on Earth
DNS Lookup
~50 ms
Time for a full name resolution without cache
HTTPS Port
443
The standard port for encrypted websites
Think of DNS as a phone book chain: your browser first checks its local cache, then asks your internet provider, which asks a root server, which points to the .com server, which knows the IP address of google.com. The result is cached so the next lookup is faster.
Where the analogy breaks: real phone books are static publications updated yearly. DNS records can change within minutes (controlled via Time-to-Live, or TTL). Also, DNS queries are active network requests to live servers — not passive lookups in a printed book.
Note
DNS Resolution: Step by Step
- 1. Browser checks the local DNS cache — maybe this site was visited before
- 2. If not cached: request goes to the ISP's recursive resolver
- 3. The resolver asks a root server: who handles .com?
- 4. The .com TLD server responds: Google uses these nameservers
- 5. Google's authoritative nameserver returns the IP addresse.g., 142.250.x.x
- 6. The resolver caches the result with TTL and forwards it to the browser
Ports are like extension numbers in a phone system: the IP address is the building's main number, the port is the extension to the right desk. Port 80 is HTTP, port 443 is HTTPS (encrypted), port 22 is SSH (secure remote access). A server can offer many services simultaneously — each listens on a different port.
Caution
Common Misconception: My IP address identifies me personally
Most home internet connections have a dynamic IP address that changes regularly. Additionally, many devices often share a single public IP address (via NAT). Your IP address is neither permanent nor directly traceable to you by websites — though your internet provider can link it to your connection, which is why it legally counts as personal data in the EU (European Court of Justice, 2016). It is more like the current phone number of a hotel room.
APIs: The Menu for Machines
Definition
API, REST, and JSON
Analogy
Definition
Where the menu analogy breaks: API responses can be deeply nested data structures with hundreds of fields — far more complex than a single dish. APIs often require authentication (API keys, tokens) — no restaurant demands an ID check before ordering. And APIs enforce rate limits (e.g., 100 requests per minute) — a concept with no dining equivalent.
The server delivers HTML code with colors, images, and layout. The browser renders the visible page. Optimized for human eyes.
The server delivers structured JSON data: {"temp": 18, "condition": "cloudy"}. A program processes the data further. Optimized for machines.
A concrete example: a weather API call looks like this: GET https://api.example-weather.com/current?city=Berlin with an API key in the header. The response comes as JSON: {"temp": 18, "unit": "celsius", "condition": "cloudy"}. No colors, no images — just the raw data that any program can process.
Here is the exciting part: an AI API call follows the exact same pattern. Instead of a city, you send a prompt: POST https://api.example-ai.com/chat with {"prompt": "What is DNS?"} — and the response comes as {"response": "DNS stands for..."}. Same HTTP, same JSON, different kitchen: instead of a database, a neural network processes the request.
Caution
Common Misconception: APIs are only for programmers
Every app on your smartphone uses APIs behind the scenes, even if you never see them. The weather widget calls a weather API, the transit app queries a transportation API, and chat notifications arrive via a messaging API. APIs are the invisible infrastructure on which most digital services are built.
HTTP speaks a small vocabulary: GET means 'read something', POST means 'send/create something', PUT means 'replace something', DELETE means 'remove something'. These four cover the fundamental operations (read, create, update, delete). There are more methods, too: PATCH means 'change part of something', and since June 2026 QUERY means 'search for something' — the search data travels inside the request, and nothing changes on the server.
Status codes are the server's short answers: 2xx means success (200 OK = all good), 4xx means 'you made a mistake' (404 Not Found = page does not exist, 403 Forbidden = no access), 5xx means 'the server has a problem' (500 Internal Server Error). Next time you see '404', you will know exactly what that number means.
A weather API works like this: the client sends a city name, the server queries its database, and returns the temperature as JSON. An AI API works identically: the client sends a prompt text, the server runs a neural network, and returns the generated text as JSON.
The HTTP layer is identical in both cases — only the server-side processing differs. Whether it is a database query or a neural network: to your code, it looks the same. You will encounter this pattern again and again in later articles when you fetch models from Hugging Face or use AI tools via their APIs.
Interactive: The Journey of an HTTP Request
Click "Play" and follow step by step what happens when your browser calls an API — from entering the URL to receiving the JSON response.
Click "Play" to see the process step by step.
Every website, every app, and every AI application uses HTTP requests in the background. Once you understand how a request is structured and what steps it goes through, you can use APIs deliberately, find errors more quickly, and understand how modern software communicates.
Note
Key Takeaways
- The internet follows a simple pattern: a client sends a request, a server sends back a response — this is true for websites, weather apps, and AI chatbots alike.
- DNS is the internet's phone book: it translates human-readable names like google.com into numeric IP addresses that routers use to deliver data packets.
- An API is a standardized interface that lets programs talk to other programs. Every app on your phone uses APIs behind the scenes.
- JSON is the universal packaging format for API data: structured, human-readable, and understood by every programming language.
- The cloud is not a mystical place — it is data centers full of servers that expose APIs, following the same client-server principles as any website.
Check
Quiz: Internet & APIs
What is the role of DNS on the internet?
Select one answer
1. What is the role of DNS on the internet?
2. You type google.com in the browser but get the error message "DNS resolution failed." What does this mean?
3. A weather app shows the current temperature for Berlin. What is most likely happening behind the scenes?
4. Both websites and APIs use HTTP. What is the key difference?
Check
Comprehension Check
Can you explain this in your own words? Tick what you've got.
0 of 3 done