你天天用API,但99%的人理解错了它的本质 (English)
你天天用API,但99%的人理解错了它的本质 (English)
Generated: 2026-06-22 07:12:38
---
Okay, let me fact-check and polish this for you, removing the AI tone and making it read more like an old programmer chatting with you.
---
You Don't Understand APIs at All! But After Reading This, You'll Know More Than 90% of People
Last month, I was leading a team to refactor an old project when a new intern timidly came over and asked, "Hey, what exactly is an API? I keep seeing 'call the interface' in the docs—are 'interface' and 'API' the same thing?"
I was stunned on the spot.
I've been coding for ten years, interviewed dozens of candidates, and mentored over a hundred newbies... but I'd never seriously thought about how to explain API to someone who knows nothing about it. In that moment, I realized: We throw this word around every day, but most people have never truly understood it.
---
First, a Scenario You've Definitely Experienced
You want to slack off on a weekend and avoid cleaning. So you hire a housekeeper for 200 bucks.
The housekeeper arrives and asks, "Where's the trash can? Where's the mop?"
You point to the kitchen corner. She gets to work—wiping windows, mopping floors, tidying the sofa. Half an hour later, the place is spotless.
See, in this scenario, the cleaning company provides a service—cleaning. You don't need to know what brand of cleaner she uses, or whether she wipes the windows first or mops the floor. You just provide the necessary info (where the trash can is) and wait for the result.
That's exactly what an API does!
In code, it looks like this:
def do_clean(trash_can):
wipe_window()
wipe_floor()
# You don't need to know how it's implemented inside
You just call do_clean, pass a parameter, and it handles the rest.
But here's the key point—you might think, "But I can see the housekeeper working, I know she's wiping windows and mopping floors." In most cases, though, you never see the implementation details of an API, and you don't need to. You only care about the result, not the process.
This brings us to the core essence of an API: a contract between programs.
---
Contract Thinking: 99% of People Get It Wrong
I've tested dozens of APIs—weather, stocks, OCR, AI large models... Every one has documentation that clearly states: what you send, what you get back, and what happens if something goes wrong.
That's a contract! Not technology—a contract!
Speaking of which, I have to tell you about a mistake I made, so you remember this lesson.
Last year, I integrated a payment API. The docs clearly said: "Amount parameter unit: cents." I didn't read carefully and passed 100—thinking I'd pay 100 bucks. Instead, it deducted 1 dollar.
Guess what? I was furious, ready to curse someone out. But when I looked back at the docs—the contract was crystal clear. I didn't follow it. Who's to blame? Me!
An API contract usually includes three things:
- Input rules: What parameters you need to pass and their format.
- Output format: What kind of result you'll get.
- Error handling: What information is returned if something goes wrong.
In short, an API is a "contract" signed between two programs. You follow the contract, it fulfills its part. It's that simple, and that strict.
---
What Does an API Actually Look Like? Don't Be Fooled by the Surface
Many people think an API is just a function. And yes, often APIs do come in the form of functions.
For example, when you use Python's requests.get(), that's an API. You pass a URL, it sends an HTTP request, and returns a response.
But APIs aren't limited to functions. A complete Web API usually includes:
- Endpoint: A URL, like
https://api.weather.com/current - Parameters: The data you need to send, like a city name
- API Key: Authentication to prove you have permission to call it
- Response format: Usually JSON, like
{"temperature": 25, "humidity": 60}
Last year, I built a weather forecast app and used the QWeather API. The code looked something like this:
import requests
url = "https://devapi.qweather.com/v7/weather/now"
params = {
"location": "Beijing",
"key": "Your API Key"
}
response = requests.get(url, params=params)
data = response.json()
print(f"Current temperature: {data['now']['temp']}°C")
Just a few lines, and you get real-time weather data. Pretty cool, right?
---
Why Should a Non-Technical Person Understand APIs Too?
Interestingly, I've noticed that many non-technical product managers, operations folks, and even bosses are starting to care about APIs.
Why? Because the AI era is here!
I've tested OpenAI's API, Baidu's ERNIE Bot API, iFlytek's Spark API. These large model APIs all work similarly: you send a piece of text, and it returns a piece of text. That simple.
But the possibilities behind it are endless! I've seen someone use OpenAI's API to build an automatic weekly report tool—it scrapes tasks from JIRA every day and lets GPT organize them into a report. The whole process just calls two APIs: one JIRA API to get data, and one OpenAI API to generate text.
In short, modern software development is like building with LEGO blocks. You don't need to reinvent the wheel; just piece together APIs that others have already built.
A counterintuitive truth: APIs aren't just for programmers—they're the universal language of the digital world. Just like you don't need to understand how an engine works to drive a car, you don't need to understand low-level code to create value with APIs.
---
What Do You Need to Prepare for Your First API Call? Here's a Checklist
If you've never called an API before, don't panic! In 2015, when I first called the Weibo API, the documentation was terrible, and it took me an entire afternoon to get it working. Now it's much better—most API docs have Chinese versions, and there are SDKs you can use directly.
What you need:
- Find the docs: Every API has its own documentation, usually on the official website. For example, Amap API docs, WeChat Pay API docs.
- Get a key: Most APIs require you to register an account and apply for an API Key. This is like a key—never leak it!
- Look at examples: Docs usually include code examples. Just copy and modify them.
- Testing tools: I recommend Postman or Apifox—visual tools for calling APIs, easy to debug.
---
My Take: APIs Are Changing Everything
Ten years ago, APIs were exclusive tools for programmers. Today, APIs are the infrastructure of the digital world.
Think about it: WeChat can send red packets, book taxis, order food—not because WeChat built all those features itself, but because it calls the APIs of payment, ride-hailing, and food delivery platforms. WeChat is like an "aggregator" that pieces together various APIs.
What about the future? I predict APIs will become more and more "democratized." There are already low-code platforms where you can drag and drop to call APIs. In a few years, even a regular business person might be able to build their own automated workflows using APIs.
The essence of APIs has never changed: enabling different programs to talk to each other, and letting developers avoid reinventing the wheel.
---
Finally, here's a sentence worth screenshotting:
**An API isn't technology—it's a promise. You follow the rules, and it delivers the result. The world runs on these promises.**
Cael Lee
Full-stack developer with 8+ years of experience. Currently building AI-powered developer tools. I've tested 20+ AI API providers and coding assistants.