Hello! Welcome to your first lesson on the journey to mastering APIs.
This course is designed to take you from the fundamentals of how the web works all the way to building and consuming your own APIs with Python. Since you're starting as a beginner, we'll build your knowledge from the ground up, ensuring you have a solid foundation at every step.
Today's lesson focuses on the most fundamental concept of the web: the client-server model. Understanding this is crucial because APIs are just a specific way for clients and servers to communicate. By the end of this lesson, you will be able to explain what clients and servers are and describe the step-by-step process a browser uses to communicate with a server to fetch a webpage.
The Big Idea: Clients and Servers
At its heart, the internet works like a massive, distributed library. You (or your applications) need some information, and somewhere out there is a computer that has it. The client-server model is the architectural pattern that organizes this exchange.
- A client is the one who asks for information. Your web browser (like Chrome or Firefox) is a perfect example of a client.
- A server is the one who holds the information and provides it upon request. When you visit a website, you are requesting files from a web server.
This interaction is called a request-response cycle. The client sends a request, and the server sends a response. It's a two-way street, but the client always initiates the conversation.
The image below shows a simple visualization of this process.

To get a clearer definition of these roles, let's watch a short video.
The Client Server Model | Clients and Servers
This video from The TechCave provides a concise explanation of the client-server model, clarifying the distinction between a client machine (like your laptop) and a client program (like a browser), and what a server really is.
Please watch the video from the beginning until timestamp 03:54. Focus on how it defines a 'client' and a 'server' and the primary role of each.
As the video explained, a client isn't just your physical device; it's the software making the request, like a web browser. Similarly, a server isn't just a powerful computer; it's the specialized software running on that computer, designed to "serve" responses to requests 24/7.
How a Browser Communicates with a Server
So, what actually happens when you type google.com into your browser and press Enter? It might seem instantaneous, but a rapid, multi-step communication process is happening behind the scenes.
Let's watch a video that breaks down this entire journey.
What happens when you type a URL into your browser?
This excellent video from ByteByteGo walks through the entire sequence of events that takes place when you request a URL in your browser. It covers key concepts like DNS, TCP, and HTTP.
Watch the video from 00:14 to 05:10. Pay close attention to the sequence of steps: DNS lookup, establishing a TCP connection, and sending the HTTP request.
Let's recap the key steps from the video. This is the core process for almost all web traffic, including API calls.
-
You Enter a URL: You provide the browser with an address, like
https://www.google.com. The browser parses this to understand the protocol (https), the domain (www.google.com), and the path (which is empty in this case, meaning the homepage). -
DNS Lookup: Computers on the internet find each other using numerical IP addresses (e.g.,
142.250.189.238), not human-friendly domain names. The browser uses the Domain Name System (DNS)—often called "the phone book of the internet"—to look up the domainwww.google.comand find its corresponding IP address. -
TCP Connection: Once the browser has the server's IP address, it opens a direct connection to that server using the Transmission Control Protocol (TCP). You can think of this as establishing a reliable phone line between the client and the server before starting a conversation.
-
HTTP Request: With the connection open, the browser sends a message to the server called an HTTP Request. This message asks the server for the specific resources needed to display the page (e.g., "GET me the main HTML file for the homepage").
-
Server Processing & HTTP Response: The server receives the request, finds the requested files (HTML, CSS, JavaScript, images), and sends them back to the browser inside an HTTP Response.
-
Browser Renders the Page: The browser receives the files in the response and starts rendering the webpage, assembling the HTML structure, applying CSS styles, and running JavaScript code to make the page interactive.
A Real-World Example
To solidify these concepts, let's read a short article that walks through this entire flow using the example of watching a YouTube video. It does a great job of labeling which actions happen on your machine (client-side) and which happen on YouTube's computers (server-side).
Client Side vs. Server Side in Web Development: A Beginner's Guide
This article from Fullstack Foundations will reinforce what we've just learned by applying it to a familiar activity: loading YouTube. It clearly distinguishes between client-side and server-side actions.
Please read the sections 'What is the client-server model?', 'An Example of a Client/Server Interaction', and the final 'Summary'. This will reinforce the roles of the client and server and walk you through a step-by-step example.
From Web Browsing to APIs
This client-server communication model is not just for browsers. It's the foundation for how most modern applications work, and it's exactly how APIs function.
When we start writing Python code to interact with an API:
- Your Python script will act as the client.
- It will send an HTTP request to an API endpoint (which is just a specific URL on a server).
- The API server will process that request and send back a response, usually containing data in a format called JSON instead of a full HTML webpage.
The fundamental principles are identical, which is why we started here.
Conclusion
Great job completing your first lesson! You've taken a significant step toward understanding how the web and APIs work.
Here are the key takeaways from today:
- The web operates on a client-server model, where a client requests information and a server provides it.
- This communication happens in a request-response cycle.
- When you visit a website, your browser follows a clear process: it finds the server's IP address using DNS, establishes a TCP connection, and sends an HTTP request.
- The server sends back an HTTP response containing the files needed for the browser to render the page.
- This same model is the foundation for how APIs work.
In our next lesson, we will dive deeper into the "language" of this communication: HTTP. You'll learn what it is, its role in web communication, and the different types of messages clients can send to servers.