
























To understand what an API is and why it's useful to you, we first need to look at something you do dozens of times a day: loading a website in your web browser.
Welcome to the first part of our guide to understanding APIs!
If you’ve ever felt like the tech world speaks a completely different language, you are not alone. Terms like "API," "HTTP," and "JSON" get thrown around constantly, but at their core, they represent incredibly simple concepts.
To understand what an API is and why it's useful to you, we first need to look at something you do dozens of times a day: loading a website in your web browser.
Every time you type a website address (like google.com) into your browser and hit Enter, you are kicking off a high-speed digital conversation.
This conversation is built on a framework called HTTP (Hypertext Transfer Protocol), which is really just a fancy term for "the rules of the internet's postal service."
This conversation always happens in two distinct steps:
Your web browser (the Client) sends a digital letter across the internet to a massive computer where the website lives (the Server). This letter says: "Hey, someone just asked to look at your homepage. Can you send it over?"
The server receives the letter, processes it, and sends a package back across the internet to your laptop or phone (and therefore your browser). This package is the Response, and it contains all the raw ingredients needed to build that website on your screen.
When the server sends its response, it doesn't send a fully formed, beautiful webpage. It sends a package of raw materials.
If you could peak inside that digital package, you would find three main types of files:
Your web browser is essentially a highly advanced translator. It takes this package of raw ingredients, reads the instructions, and instantly builds the visual page you see on your screen.
As humans, we rely entirely on the browser's translation to make sense of information. We don't read the raw code; we read the design.
When you look at a Google search result page, your brain instantly decodes the information based on visual cues:

We need layouts, spacing, fonts & colours to help us sort through data and find what we are looking for.
If you took away the design and just looked at the raw code, it would take you ages to find a single phone number or headline.

Now, let's look at this from a different perspective. What if you want a computer program (like a spreadsheet, a tracking tool, or an automation app) to read a Google search result for you?
A computer won't pay attention to a sleek logo. Using the Helvetica font won't help it read more clearly. Furthermore, it won't intuitively understand which piece of text is more important than another simply by the colour used, or the fact that it has a red border around it.
In fact, all of that layout and design code just gets in the machine's way, when it comes to understanding information. For a computer, trying to extract information from a standard webpage is like trying to read a book where someone has pasted random magazine cutouts and glitter all over the words.
Machines don't need a User Interface or UI (a design built for human eyes). They need an Application Programming Interface. An API.
💡 REMEMBER: you can think of an API is simply a version of a website that strips away all the visual fluff (the CSS, the logos, the layout instructions) and delivers only the raw, organised data.
Now that you know how a browser requests & receives information, and why humans need visual designs to understand it, we can look at how machines do the exact same thing using a text format called JSON.
In Part 2, we will pull back the curtain on JSON, show you how it organises data into digital filing cabinets, and teach you how to read it without breaking a sweat!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。