返回资讯中心
外部精选
软件工程
#开发者实时流

Agent's Internet

Your agent learns a site's own request once, then calls it like an API and gets JSON back.

Hacker News 最新goodnight0002026/10/27 · 今天30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Your agent learns a site's own request once, then calls it like an API and gets JSON back.

Plain HTTP first, a browser only when the site insists, no LLM to learn it, and a repair when the site changes.

Quick start · How it works · Agents · Teach a site · Results · Sites · Docs

The whole idea in 49 seconds · MP4 with sharper text

Same agent, same prompt, started together. Left: it drives headless Chrome. Right: it calls API Anything's Google Flights operation.

1.5 to 2× sooner · about half the tokens · the same cost or less · 20 of 20 answers correct

Claude Opus 5.5 in Claude Code, 2026-09-28. Shown at 3× speed with no cuts; the timers show real elapsed time. MP4 · how it was recorded

One site, one model, a few dozen runs. Method, raw numbers and limits.

  1. Paste this into Claude Code, Codex or another coding agent:

The agent checks for Node 22.13+, builds and installs the api-anything command, makes one call to prove it works, then connects the MCP server and the skill to itself.

  1. Restart the agent and ask it something:

api-anything call hacker-news search query=sqlite

{"ok":true,"class":"ok","tier":1,"data":[ {"title":"Hosting SQLite databases on GitHub Pages or any static file hoster", ...}, ...], "ms":185}

tier: 1 means one plain HTTP request, with no browser and no account. A failure says what happened (class), why (reason) and what to do next (next).

npx -y api-anything setup (Node 22.13+) connects the MCP server, and the skill where the agent takes skills, to Claude Code, Codex, Cursor and Claude Desktop, and asks whether to help build the shared catalog. --dry-run prints what it would change. For an agent installing it

To build from a clone instead (don't use npm install -g github:...: it fails under npm 11):

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

Then connect your agent:

claude mcp add --scope user api-anything -- api-anything mcp # Claude Code codex mcp add api-anything -- api-anything mcp # Codex api-anything mcp --print-config # any other client

To try one read with no install: npx -y github:goodnight000/api-anything call hacker-news search query=sqlite.

A Chromium browser is needed only to teach new sites and for the browser tiers: Google Chrome by default, or Brave, Edge, Chromium, Vivaldi or Arc. API_ANYTHING_BROWSER names any other. Setup details.

Learn. A headless browser loads the page once for each of two example inputs. The part of the request that changed becomes a slot. Cookies and tokens become references to a local store.

Call. Fill the slots and send the request with Node's fetch. If the site blocks that, fetch from inside a browser page. As a last resort for a read, run the page and read its own response.

Repair. When the answer stops fitting (a rotated id, a moved field), re-learn the request and save it only after a replay works. Otherwise the call returns an error, never someone else's data.

Replay, fallback and repair in detail · design

No LLM to learn

Two example inputs. What changed becomes a parameter; the rest is kept byte for byte.

Plain HTTP, no browser

Tier 1 is one request from Node: typically 0.1 to 0.4 s for a Hacker News search, 1.2 s for a Google Flights page.

Repairs itself

A drifted request is re-learned, and saved only after a replay with your inputs works.

Honest about writes

Off unless allowed, sent once, a repeat refused, and applied only when a read finds it.

Your sessions, never in a spec

Specs hold references like cookie:ct0. Logins come from the browser you already use.

Share and pull specs

Pull what someone else learned. Publish yours to the shared catalog, after the same checks.

Use it from your agent, the CLI or code

Over MCP, an agent calls operations. It doesn't need a shell for that.

Each answer is JSON text, and an object answer is also sent as structuredContent. To create operations, an agent needs a shell and the skill.

--print-config prints the add command for Claude Code, Codex, Gemini CLI and VS Code, and the JSON entry for Cursor and Claude Desktop. It uses absolute paths, because a client started from the Dock or a menu may not get your shell's PATH:

api-anything mcp --print-config # reads only api-anything mcp --print-config --allow-writes # also serve call_write_operation

--sites also serves each operation of the sites you name as a tool of its own, with its args as a JSON Schema, so the agent skips the list_operations step. Each op costs about 200 tokens of tool list, so it's opt-in:

api-anything mcp --sites goodreads,hacker-news # goodreads__searchBooks, ...

A tool call still running after about 25 s (a sign-in window, a long repair) answers class: "pending" with a job, and keeps running. get_job waits for it and never runs it again. The same call made while it runs joins it, so a second login doesn't open a second window, and a write still in flight is never sent beside itself.

api-anything sites # the sites you can call api-anything ops goodreads # params, returns and caveats api-anything call goodreads searchBooks q=piranesi # JSON out; a failure exits nonzero api-anything call google-flights search origin=SFO destination=NYC date=2026-12-01 --max-tier 1 api-anything call goodreads getBook bookId=50202953 --dry # the request, credentials redacted

api-anything <command> --help explains each command. Reference.

import { call } from "api-anything";

const r = await call("goodreads", "searchBooks", { q: "piranesi" }); if (r.ok) console.log(r.tier, r.data); else console.log(r.class, r.reason, r.next, r.retry);

// a write needs allowWrites at every entry point await call("my-site", "postComment", { text: "Ship it" }, { allowWrites: true });

examples/reading-list.mjs builds a five-book table from Goodreads with no model and no browser. In another project, install the packed tarball from your clone (npm install /path/to/api-anything-0.1.0.tgz).

Whether sharing is on or off, a search goes to the catalog: the words, domain or URL your agent passes to find_sites, and the name of a shared site it calls before this machine has it.

With sharing on, this is what leaves your machine:

A new operation is a candidate until installs other than its uploader report it working from different networks; then it is served as live. Operations that write, that needed a login, or that send to another site's host are never promoted by reports. With sharing off (api-anything setup --no-share), nothing is shared or reported, and the catalog still works for reads. How the catalog works

Give it the page URL with a placeholder, and two example inputs:

api-anything add hn-demo links
--trigger 'https://news.ycombinator.com/from?site={domain}'
--example domain=github.com --example2 domain=github.io --match path=/from
--html '{"items":"tr.athing","fields":{"title":".titleline > a","url":".titleline > a@href"}}'

api-anything call hn-demo links domain=arxiv.org # 30 arxiv.org stories, tier 1

The browser loads the page once per example. The part of the request that changed with the input becomes a parameter. You, or your agent, pick the request and the fields; API Anything builds the template without an LLM. If example 2 gets example 1's data, the op is marked unproven: the server may not read that param at all.

Watch it learn and call, 25 s recording →

Tell an agent what you want from a site. The skill has it:

Goodreads has had no public API since 2020. One run took 6.3 minutes and $1.19 and produced search, book details, an author's books and reviews.

Tested on unseen books. 30 books nobody used while building it. For the 29 the search found, every checked field matched the page Chrome rendered. All 146 calls went over plain HTTP.

Against a browser agent. 5 books in 30.5 s instead of 182.5 s. One book cost a third as much.

No agent at all. A plain script builds the same five-book table in 16 s.

How it was explored, tested and compared

Someone may have learned the site already. search looks through the shared catalog by what you need, a domain or a URL, and pull fetches a site, checked against the shared rules first:

api-anything search book ratings # or goodreads.com, or a page's URL api-anything pull goodreads api-anything call goodreads searchBooks q=piranesi

To share one, prove it, then publish it:

api-anything check hn-demo links domain=arxiv.org --expect result # confirmed on the site api-anything verify hn-demo # pass, fail or inconclusive api-anything publish hn-demo # preview only api-anything publish hn-demo --yes # upload, signed by this install

What the gate checks

publish previews exactly what each upload sends, every host the op sends to, and anything that may be yours, such as an email or an account id. Nothing is sent until --yes.

It refuses a spec holding a live cookie or session value, a provider API key, an op whose recorded checks fail, and an op marked unproven.

An upload carries what the client proved. A new op is a candidate until other installs confirm it, and one that needed a login or writes is reviewed first (how the catalog works).

A param can declare an enum, a min or a max. A call outside them is input, and nothing is sent.

A pulled spec is someone else's: its writes still need --allow-writes, and it runs with your session.

Results you can act on

Every call answers in fields, so an agent or a script can act without parsing prose.

Against the local test site the suite uses. No write operation is bundled.

api-anything login linkedin

login imports that site's cookies from a browser profile you're already signed in to, so there's usually no password to type. If several profiles are signed in, it asks which one. If none can be imported, it opens a window to sign in by hand. A spec holds references to cookies and tokens, never their values, so a refreshed session works without re-learning anything.

25 read operations across 10 sites. They cover selected features, not whole sites. api-anything ops <site> lists each op's params and caveats.

dominos-au came in through publish from a contributor; its last two ops were learned signed in. goodreads was built by the explorer above.

It's a local tool, not a hosted API. It uses your machine, your network and your sessions.

It knows only the operations it was taught, not every feature of every site.

learn_site learns from one page load per value, from a URL template. A site whose data appears only after clicks or typing, or only on in-app navigation, needs the CLI's capture and add with --steps or --soft-from. It learns reads only.

A shared operation is someone else's work. Candidates are served marked as such until other installs confirm them, and an operation that worked for others can still fail for you (a different region, a block on your network).

Repair can fail. There's no CAPTCHA solving: if a site challenges real Chrome, you clear it by hand, and a challenge that doesn't clear is reported as blocked.

verify proves an op only as far as its examples and checks go: a few cases a human confirmed, not a test suite.

No write operations are bundled, and writes are tested only against a local fixture. A 2xx doesn't prove a message was delivered: only a write op with a readback that finds it says applied.

Paging hands back the site's own next cursor when the answer has one. Numbered pages get no hint.

Read each site's terms. You're responsible for how you use it.

All limits

doc what's in it

Setup for agents install, connect each client, timeouts, troubleshooting

Reference creating operations, replay and repair, logging in, safety, limits

Design the authoritative spec, and the reasons behind it

Catalog the shared catalog: promotion, reports, what it stores and what it leaves open

Benchmark · explorer how every number on this page was measured

Demos recorded terminal runs, with transcripts and tapes

Contributing add a site spec, run the checks

MIT licensed.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →