get-api-docs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Get API Docs via chub

通过chub获取API文档

When you need documentation for a library or API, fetch it with the
chub
CLI rather than guessing from training data. This gives you the current, correct API.
当你需要某个库或API的文档时,请使用
chub
CLI工具获取,而非依赖训练数据猜测。这样能为你提供当前最新、准确的API信息。

Step 1 — Find the right doc ID

步骤1 — 找到正确的文档ID

bash
chub search "<library name>" --json
Pick the best-matching
id
from the results (e.g.
openai/chat
,
anthropic/sdk
,
stripe/api
). If nothing matches, try a broader term.
bash
chub search "<library name>" --json
从结果中选择最匹配的
id
(例如
openai/chat
anthropic/sdk
stripe/api
)。如果没有匹配结果,尝试使用更宽泛的关键词。

Step 2 — Fetch the docs

步骤2 — 获取文档

bash
chub get <id> --lang py    # or --lang js, --lang ts
Omit
--lang
if the doc has only one language variant — it will be auto-selected.
bash
chub get <id> --lang py    # 或 --lang js、--lang ts
如果文档只有一种语言版本,可以省略
--lang
参数,工具会自动选择。

Step 3 — Use the docs

步骤3 — 使用文档

Read the fetched content and use it to write accurate code or answer the question. Do not rely on memorized API shapes — use what the docs say.
阅读获取到的内容,并据此编写准确的代码或回答问题。不要依赖记忆中的API结构,以文档中的内容为准。

Step 4 — Annotate what you learned

步骤4 — 记录你学到的内容

After completing the task, if you discovered something not in the doc — a gotcha, workaround, version quirk, or project-specific detail — save it so future sessions start smarter:
bash
chub annotate <id> "Webhook verification requires raw body — do not parse before verifying"
Annotations are local, persist across sessions, and appear automatically on future
chub get
calls. Keep notes concise and actionable. Don't repeat what's already in the doc.
完成任务后,如果你发现文档中没有提到的内容——比如注意事项、解决方案、版本特性或项目特定细节,请保存这些信息,以便后续会话能更高效地开展:
bash
chub annotate <id> "Webhook verification requires raw body — do not parse before verifying"
注释内容仅保存在本地,会跨会话持久化,且在后续调用
chub get
时自动显示。请保持注释简洁且具有可操作性,不要重复文档中已有的内容。

Step 5 — Give feedback

步骤5 — 反馈评价

Rate the doc so authors can improve it. Ask the user before sending.
bash
chub feedback <id> up                        # doc worked well
chub feedback <id> down --label outdated     # doc needs updating
Available labels:
outdated
,
inaccurate
,
incomplete
,
wrong-examples
,
wrong-version
,
poorly-structured
,
accurate
,
well-structured
,
helpful
,
good-examples
.
对文档进行评分,帮助作者优化文档。评分前请先询问用户。
bash
chub feedback <id> up                        # 文档使用体验良好
chub feedback <id> down --label outdated     # 文档需要更新
可用标签包括:
outdated
inaccurate
incomplete
wrong-examples
wrong-version
poorly-structured
accurate
well-structured
helpful
good-examples

Quick reference

速查参考

GoalCommand
List everything
chub search
Find a doc
chub search "stripe"
Exact id detail
chub search stripe/api
Fetch Python docs
chub get stripe/api --lang py
Fetch JS docs
chub get openai/chat --lang js
Save to file
chub get anthropic/sdk --lang py -o docs.md
Fetch multiple
chub get openai/chat stripe/api --lang py
Save a note
chub annotate stripe/api "needs raw body"
List notes
chub annotate --list
Rate a doc
chub feedback stripe/api up
目标命令
列出所有可用文档
chub search
查找特定文档
chub search "stripe"
查看精确ID的详情
chub search stripe/api
获取Python版文档
chub get stripe/api --lang py
获取JS版文档
chub get openai/chat --lang js
保存到文件
chub get anthropic/sdk --lang py -o docs.md
获取多个文档
chub get openai/chat stripe/api --lang py
保存注释
chub annotate stripe/api "needs raw body"
列出所有注释
chub annotate --list
为文档评分
chub feedback stripe/api up

Notes

注意事项

  • chub search
    with no query lists everything available
  • IDs are
    <author>/<name>
    — confirm the ID from search before fetching
  • If multiple languages exist and you don't pass
    --lang
    , chub will tell you which are available
  • 不带查询参数的
    chub search
    会列出所有可用文档
  • 文档ID格式为
    <作者>/<名称>
    ——请在获取前通过搜索确认ID
  • 如果文档存在多语言版本且未传入
    --lang
    参数,chub会告知你可用的语言选项