# API Anything

> Turns a website's own internal requests into JSON operations an agent can call

- Category: Data & Labeling / Web Scraping & Crawling
- Language: TypeScript
- Licence: MIT
- Repository: https://github.com/goodnight000/api-anything
- Canonical page: https://ai-tldr.dev/tools/api-anything/

## In short

API Anything is an MIT-licensed TypeScript tool for giving an AI agent an API to websites that do not offer one. It sits in the Web Scraping & Crawling category of the Data & Labeling tools and is open-source, written in TypeScript and licensed MIT. To get started: make a first call.

## Overview

API Anything is an MIT-licensed TypeScript tool for giving an AI agent an API to websites that do not offer one. Instead of having an agent drive a browser click by click, it learns the request a site's own frontend sends to fetch its data, saves it as a named operation, and from then on calls that operation directly and returns JSON. Operations are exposed through an MCP server, a CLI (including JSONL batches), a TypeScript library, a Python client and a local HTTP server with REST, OpenAPI and MCP endpoints.

The work happens in three steps. To learn, a headless browser loads the page for two example inputs; the values that changed between the two requests become parameters, the rest is kept as is, and cookies are stored as references rather than values — no LLM is involved. To call, the request goes out over plain HTTP with Node's fetch first, falls back to a fetch from inside a browser page when the site blocks that, and as a last resort for reads runs the page and reads its response. To repair, when an answer stops matching the saved shape it tries an updated operation from the catalog or re-learns the request, and keeps the fix only after a successful replay.

Every result carries machine-readable `class`, `write`, `retry` and `nextCall` fields, so an agent can tell a rate limit from a login wall or a drifted page and knows the next step to take. Writes are off unless allowed, sent once, refused if repeated and only reported as applied when a follow-up read confirms them. An opt-in shared catalog lets installs search operations others have learned, with contributed reads and repairs verified by other installs before they go live. The project does not solve CAPTCHAs: an unresolved challenge comes back as `blocked`.

## What it does

- Learns a site's internal request from two example inputs with a headless browser — no LLM, no hand-written scraper
- Three-tier calls: plain HTTP first, a fetch from inside a browser page when blocked, and running the page as a last resort for reads
- Self-repair: a drifted operation is re-learned or swapped for a catalog version and saved only after a successful replay
- Agent-friendly results with `class`, `retry` and `nextCall` fields, `--fields` to cap output and `--changes` to report what is new since the last call
- Guarded writes: off by default, sent once, repeats refused, and confirmed by a read before they are reported as applied
- One `setup` command wires the MCP server into Claude Code, Codex, Cursor, Claude Desktop, Gemini CLI and VS Code; also a CLI, TypeScript and Python library and a local REST/OpenAPI server

## Getting started

API Anything needs Node 22.13 or newer. The first call needs no browser, account or API key; a Chromium browser is needed later for learning new operations and for the browser tier.

1. Make a first call

   Search Hacker News through a bundled operation over plain HTTP and keep only two fields. A working call returns ok: true, tier 1 and a list of stories.

```bash
npx -y api-anything call hacker-news search query=sqlite --fields title,url --max-tier 1
```

2. Connect your agent

   setup finds the agents installed on the machine, asks which to connect and writes the MCP server entry for each. Add --dry-run to preview the changes. In Claude Code you can install it as a plugin instead.

```bash
npx -y api-anything setup

# or, inside Claude Code
/plugin marketplace add goodnight000/api-anything
/plugin install api-anything@api-anything
```

3. Or add the MCP server by hand

   For any other client the server entry is {"command":"npx","args":["-y","api-anything","mcp"]}. Claude Code and Codex have one-line shortcuts.

```bash
claude mcp add --scope user api-anything -- npx -y api-anything mcp
codex mcp add api-anything -- npx -y api-anything mcp
```

4. Teach it a new site

   Give a URL template and example inputs: --args is your own value, --args2 becomes the operation's shared example and --args3 is a holdout used to check the learned operation.

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

5. Use a logged-in site

   For sites that need an account, import an existing session from a browser you choose; operation specs reference the cookies rather than storing their values.

```bash
api-anything login linkedin
```

## When to use it

- Give a coding or research agent structured reads from sites that publish no public API
- Replace a slow click-by-click browser agent with direct JSON calls for repeated lookups
- Track what changed on a page between runs with --changes instead of re-reading everything
- Pull mentions of a project from several sites in one script, as the bundled examples/mentions.mjs does
