api-anything README

项目的 README,来自 github.com/goodnight000/api-anything。合并为一个 markdown 文件:README.md。

API Anything. The web, as an API for agents. One agent learns a site's API; every other agent gets it for free.

Give your agent an API for websites that don't have one.
Learn a read once from the site's own traffic. Call it as JSON from MCP, the CLI, or your code.

npm Shared catalog: live CI License: MIT Node ≥ 22.13

Quick start · Example · Benchmarks · Integrations · Docs

Look up a book rating, search for flights, or check who's talking about your project without driving a browser for each read. API Anything ships 114 sites and 323 read operations. It uses plain HTTP when it can, falls back to the browser when needed, and can repair an operation when a site changes. Calls run on your machine, not through the shared catalog.

Quick start

Try a read. All you need is Node 22.13 or newer. No browser, account, or API key for this call.

npx -y api-anything call hacker-news search query=sqlite --fields title,url --max-tier 1
{"ok":true,"class":"ok","tier":1,"data":[
  {"title":"Hosting SQLite databases on GitHub Pages or any static file hoster",
   "url":"https://phiresky.github.io/blog/2021/hosting-sqlite-databases-on-github-pages/"},
  ...]}

tier: 1 means plain HTTP, with no browser. --fields keeps only what you ask for. If a call fails, it returns a reason and a next step.

Connect your agent.

npx -y api-anything setup

Pick your client, restart it, and ask “What does Goodreads rate Piranesi?” Setup supports Claude Code, Codex, Cursor, Claude Desktop, Gemini CLI, and VS Code; use --agents hermes for Hermes. Use --local-only to skip the shared catalog. Setup for every client · Install instructions for your agent

Who's talking about your project

examples/mentions.mjs checks Hacker News, Reddit, YouTube, GitHub, and Mastodon in one run and combines the links into a feed. It makes six read calls, all capped at plain HTTP. If one source is unavailable, the script reports it and keeps the answers from the others.

On November 22, all five runs found 46 DuckDB mentions. The whole process took 1.56–1.89 s per run. Five calls answered over plain HTTP; Reddit reported blocked each time. Rerun details

npm ci
node examples/mentions.mjs duckdb --json

Terminal capture from the November 6 DuckDB search, showing how the script reports each source

Watch the November 6 recording

Performance

60% less time for a fresh CLI read. On November 22, we reran the local benchmarks on current main against the revisions before the latency passes.

Local workload Before Current
First CLI read, including Node startup 574 ms 227 ms
Recognize a rate limit and return 4.59 s, misclassified 14 ms, with retry timing
Stop learning on an unresolved challenge 36.0 s, two browser runs 18.0 s, one browser run
Five-read batch, one field requested per item 3,355 JSON characters 60 JSON characters

These are localhost fixtures: the first read includes process startup, and the batch measures output size, not model tokens or a faster site. Reproduction, baselines, and raw results

The race

In earlier same-agent comparisons, both setups answered every scored question correctly. The times below include the agent's entire run, not just the website call.

Task Browser agent Agent with API Anything
Google Flights, 1 date (Sep 28) 12.9 s 8.4 s
Google Flights, 5 dates (Sep 28) 41.6 s 21.1 s
Netflix, 3 episodes (Oct 31) 22.3 s 9.6 s
IKEA, 5 store addresses (Oct 31) 31.4 s 18.1 s

Historical 2026 medians, five runs per task and setup, all with Claude Opus 5.5. These are not current-build timings. Watch the Google Flights race · Agent timing, tokens, and cost

How it works

How API Anything works. 1, Learn: the browser loads the page for two example inputs; what changed becomes a slot, and cookies become references. 2, Call: tier 1 sends plain HTTP with Node fetch; if the site blocks that, tier 2 fetches from inside a browser page; as a last resort for reads, tier 3 runs the page and reads its response. Every result carries class, write, retry and nextCall. 3, Repair: when a request drifts, re-learn it, replay it, and save it only if the replay succeeds.

The whole idea in 49 seconds · replay, fallback and repair · design

Use it anywhere

The same operations work from an agent, a script, or an app.

Use it from Start here
MCP Set up your agent or connect an agent framework
CLI Call operations or batch reads as JSONL
TypeScript import { call } from "api-anything", or use the call-only host API
Python Use the Python client with typed operations or framework adapters
HTTP Run a local server with REST, OpenAPI, and MCP over HTTP

Teach it a new site

If the catalog doesn't have the read you need, give learn_site a page URL template and three values: two to learn from and a third to check the result. From a shell:

api-anything learn 'https://lobste.rs/domains/{domain}' \
  --args domain=github.com --args2 domain=arxiv.org --args3 domain=youtube.com

For pages that need clicks or typing, the agent skill walks the agent through proposing and building an operation after you approve. Learning, step by step · Watch a read get learned and reused

The shared catalog

The agent internet loop. 1 Ask: an agent needs a website. 2 Find: search the shared catalog. 3 Learn: from the site's own requests, if nobody shared it. 4 Share: cookies and tokens stripped. 5 Verify: other installs' calls vote. 6 Repair: one fix reaches everyone. Like reCAPTCHA, which digitized books from words people typed anyway, API Anything turns the web into APIs from calls agents make anyway.

Search the shared catalog for learned operations or a site's own MCP server or OpenAPI document. Opt in to sharing to contribute public reads and repairs. Other installs verify shared operations before they go live. The bundled sites work without reaching the catalog and cover selected features, not whole sites. How the catalog verifies and promotes operations

Safety and what leaves your machine

What leaves your machine

A search sends its words, domain or URL to the catalog, which keeps no search words. With sharing on, operations learned from public pages are shared, and so are repairs and reports (the version, the outcome, the tier and the time; never your arguments or data). An operation learned signed in goes only after you say yes, or once 3 installs on 3 networks learned the identical thing. Background verification of new operations is a separate question, and its default is no. With sharing off, or with --local-only, nothing is shared or reported. In full, with what the gate checks

Limits

It knows only the operations someone taught it, and the catalog is young. An operation that works for others can still fail for you (another region, a block on your network: Reddit challenges plain HTTP from many). There's no CAPTCHA solving; a challenge that doesn't clear is reported as blocked. Read each site's terms: you're responsible for how you use it. All limits

Help build it

Opt in to sharing to help verify and repair the operations you use. Learn a site that agents requested on the catalog homepage, or contribute a bundled site spec.

Docs

doc what's in it
Setup for agents install, connect each client, learning, timeouts, troubleshooting
Reference the CLI and library, results, creating operations, repair, logging in, safety, sites, limits
HTTP server · Python api-anything serve; the Python package
Frameworks · Agent hosts MCP from agent frameworks; the call-only host API
Design · Catalog the authoritative spec and its reasons; how the catalog promotes, stores and trusts
Benchmark · Demos how every number here was measured; recorded runs with transcripts and tapes
Contributing · MIT license add a site spec, run the checks

Who made this

API Anything is made by Charles Zheng, who also builds Forth. Say hi on X or LinkedIn.

Star History

Star History Chart

api-anything (goodnight000/api-anything)

正在搜索数据库…

这是什么?API Anything 会观察网站自身前端发出的请求,学习其中哪些部分是你的输入,并把它保存为一个操作。之后,你的代理可以通过 MCP、CLI 或 TypeScript 调用这个操作,直接拿回纯 JSON,而不用驱动无头浏览器。
这是托管 API,还是我自己运行的东西?它是一个本地工具:一个 CLI 加上一个 MCP 服务器,在你自己的机器上运行,使用你的网络和浏览器会话,而不是托管服务。
如何安装并把它连接到我的编程代理?把安装代码片段粘贴到 Claude Code、Codex 或其他编程代理中;它会检查 Node 22.13+,构建并安装 api-anything 命令,然后自行接上 MCP 服务器和技能。你也可以手动添加,使用 “codex mcp add api-anything -- api-anything mcp” 或 “claude mcp add --scope user api-anything -- api-anything mcp”。
我需要先装好 Chrome 或 Node 吗?需要——构建和运行它必须有 Node 22.13+;Google Chrome 只在创建新操作时需要,并在普通 HTTP 调用被拦截时作为回退手段。
如果网站改版导致已保存的操作失效怎么办?它会重新学习这个请求,并且只在重放成功后才保存新版本;如果仍然失败,你会收到一个错误,而不是别人的数据。它不解决验证码,所以如果网站向真实 Chrome 发起挑战,你得手动通过。
它在 Windows 上和 macOS、Linux 上表现一样吗?在 macOS 和 Linux 上,Cookie 导入支持 Chrome、Arc、Brave、Edge、Chromium 和 Firefox 的配置文件(Linux 上密钥环加密的 Cookie 除外);在 Windows 上,登录只会打开一个 Chrome 窗口,而不是导入 Cookie。
我的登录会话和凭据存在哪里?凭据保存在 ~/.api-anything 中,已保存的操作只持有 Cookie 和令牌的引用,从不保存实际值,因此会话刷新后无需重新学习即可继续使用。
开箱即用内置了哪些网站和操作?它内置了覆盖 9 个网站的 22 个读取操作,包括 Google Flights、Hacker News、X、Instagram、YouTube、Airbnb、Amazon、LinkedIn 和 Goodreads。
它比代理驱动浏览器快多少?在 Google Flights 基准测试中,同一个代理出结果快 1.5-2 倍,读取的 token 约为一半,成本相同或更低;在 Goodreads 上,它用 30.5 秒回答了 5 本书的问题,而驱动浏览器的代理需要 182.5 秒。
它是怎么自学一个新网站的?你给它一个带占位符的页面 URL 和两个示例输入;无头 Chrome 会为每个示例加载页面,发生变化的部分成为参数,其余部分成为模板,全程不使用 LLM。
它能向网站写入吗,比如发送 LinkedIn 消息?内置操作中没有写入操作。写入需要 --allow-writes 标志,而且只在本地测试夹具上测过,尚未在 LinkedIn 等真实网站上测试。
大小
16.7 MB
星标
4.1K
更新
提交Nov 27
时长
2个月
提交 · 90 天