0Pricing
Vibe Coding · 课时

什么是 API

理解请求和响应。

什么是 API 是 CoddyKit 上的免费 Vibe Coding 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Vibe Coding 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Vibe Coding 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Why APIs Matter

An API (Application Programming Interface) is how one program talks to another. Instead of rebuilding maps, payments, or weather data yourself, you call someone else's service and get the answer back.

When you build software with an AI assistant, most real features come from connecting to third-party APIs. Learning to think in APIs lets you assemble powerful apps quickly.

A Restaurant Analogy

Think of an API like a restaurant menu. You don't go into the kitchen and cook. You read the menu, place an order with the waiter, and food arrives.

The menu is the API documentation, your order is the request, and the dish is the response. You never see how the kitchen works inside, only what it promises to deliver.

Requests and Responses

Every API interaction has two halves: a request you send and a response you receive. The request says what you want; the response carries the data or a status.

You can ask your AI assistant to explain this flow for any service you plan to use, so you know exactly what to send and what comes back.

Explain how a request and response work for the OpenWeatherMap API.
Show me one example request and what the response looks like.

Endpoints Are Addresses

An endpoint is a specific URL where the API listens for one kind of request. A weather service might have one endpoint for current conditions and another for forecasts.

Each endpoint does a focused job. Knowing which endpoint to hit is half the battle when integrating any external service into your app.

HTTP Methods

APIs use HTTP methods to signal intent. GET fetches data, POST creates something, PUT or PATCH updates, and DELETE removes. The method tells the server what action you mean.

When unsure, ask your assistant which method an endpoint expects. Picking the wrong one is a common beginner mistake that returns confusing errors.

For the GitHub API, which HTTP method do I use to create a new issue,
and which one do I use to just read existing issues?

JSON: The Common Language

Most modern APIs speak JSON, a lightweight text format of keys and values. A weather response might include "temp": 21 and "city": "Paris".

JSON is easy for both humans and code to read. Your AI assistant can turn a raw JSON response into clean variables your app actually uses.

Here is a JSON response from a weather API.
Show me how to pull out the temperature and city name in JavaScript.

API Keys: Your ID Badge

Many APIs require an API key, a unique string that identifies and authorizes you. It is like an ID badge that lets you through the door and tracks your usage.

Keys are secret. Never paste them into public code or share them in chat. We will cover safe handling in a later lesson.

Rate Limits

APIs limit how many requests you can make in a time window, called a rate limit. Free tiers might allow 60 calls per minute, paid tiers far more.

Hitting the limit returns an error, not your data. Ask your assistant to check a service's limits before you build features that call it in a loop.

What are the free-tier rate limits for the TheMovieDB API,
and how should I structure my app to stay under them?

Status Codes Tell a Story

Every response carries a status code. 200 means success, 401 means unauthorized, 404 means not found, and 429 means too many requests.

These numbers are your fastest debugging clue. When something breaks, the status code usually points straight at the cause before you read any error text.

Public vs Private APIs

Some APIs are public and free, like many weather or quote services. Others are private, needing accounts, billing, or approval, like payment and messaging platforms.

Knowing which kind you face shapes your setup. Ask your assistant to compare options so you start with the simplest service that meets your need.

I want to add quotes to my app. Suggest three free, no-signup APIs
and compare their ease of use for a beginner.

Thinking in Integrations

Building with AI is mostly about wiring services together. A trip planner might combine a maps API, a weather API, and a currency API into one screen.

Once you see features as integrations, you describe the outcome to your assistant and let it handle the plumbing of requests, parsing, and display.

Quick Check

Test your understanding of API basics.

Recap

An API lets your app borrow another service's powers through requests and responses. You hit endpoints with HTTP methods, send and receive JSON, and identify yourself with keys.

Status codes and rate limits guide your debugging. Next, you will learn to read API docs quickly with help from your AI assistant.

常见问题解答

「什么是 API」课时是免费的吗?

是的 — 「什么是 API」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Vibe Coding 课程的其余内容,请升级到 CoddyKit PRO。 Vibe Coding 课程共包含 4 节课。

「什么是 API」这节课中我会学到什么?

理解请求和响应。 你通过在浏览器中直接运行的动手代码来练习 Vibe Coding,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Vibe Coding 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Vibe Coding 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。

「什么是 API」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Vibe Coding 课中编写并运行代码吗?

能。每节 Vibe Coding 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 什么是 API
  2. 使用人工智能阅读 API 文档
  3. 发起您的第一次 API 调用
  4. 处理密钥和错误
← 返回 Vibe Coding