Metadata-Version: 2.5
Name: reverse-api-engineer
Version: 0.16.0
Summary: The agent that turns websites into APIs.
Project-URL: Homepage, https://reverseapi.dev
Project-URL: Documentation, https://reverseapi.dev/docs
Project-URL: Repository, https://github.com/kalil0321/reverse-api-engineer
Project-URL: Issues, https://github.com/kalil0321/reverse-api-engineer/issues
Project-URL: Changelog, https://github.com/kalil0321/reverse-api-engineer/blob/main/CHANGELOG.md
Author-email: Kalil <kalil0321@users.noreply.github.com>
License: MIT
License-File: LICENSE
Keywords: agent,ai,api,api-client,browser-automation,claude,claude-code,code-generation,codegen,har,llm,mcp,openapi,playwright,python,reverse-engineering,scraping,typescript,web-scraping
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: aiohttp>=3.14.4
Requires-Dist: anyio>=4.14.2
Requires-Dist: certifi>=2026.10.19
Requires-Dist: claude-agent-sdk>=0.2.174
Requires-Dist: click>=8.3.3
Requires-Dist: cryptography>=50.0.0
Requires-Dist: httpx2>=2.12.0
Requires-Dist: markdown-it-py>=2.2.0
Requires-Dist: multidict>=6.9.1
Requires-Dist: opentelemetry-api>=1.45.1
Requires-Dist: prompt-toolkit>=3.0.40
Requires-Dist: pygments>=2.20.0
Requires-Dist: pyjwt>=2.15.0
Requires-Dist: python-multipart>=0.0.31
Requires-Dist: questionary>=2.0.0
Requires-Dist: requests>=2.33.0
Requires-Dist: rich>=13.0.0
Requires-Dist: setproctitle>=1.3.0
Requires-Dist: starlette>=1.3.1
Requires-Dist: urllib3>=2.8.0
Requires-Dist: watchdog>=3.0.0
Provides-Extra: codex
Requires-Dist: openai-codex<1,>=0.167.1; extra == 'codex'
Provides-Extra: copilot
Requires-Dist: github-copilot-sdk<2,>=1.0.26; extra == 'copilot'
Provides-Extra: manual
Requires-Dist: playwright-stealth>=1.0.0; extra == 'manual'
Requires-Dist: playwright>=1.64.1; extra == 'manual'
Description-Content-Type: text/markdown

<div align="center">
  <img src="https://raw.githubusercontent.com/kalil0321/reverse-api-engineer/main/assets/reverse-api-banner.png" alt="Reverse API Engineer Banner">
  <br><br>
  <a href="https://pypi.org/project/reverse-api-engineer/"><img src="https://img.shields.io/pypi/v/reverse-api-engineer?style=flat&color=e50d75&labelColor=1f1f1f" alt="PyPI"></a>
  <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.11+-e50d75?style=flat&labelColor=1f1f1f" alt="Python"></a>
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-e50d75?style=flat&labelColor=1f1f1f" alt="License"></a>
  <br>

[![Greptile: The War on Bugs](https://www.greptile.com/badge.svg)](https://www.greptile.com/?utm_source=oss_badge&utm_medium=readme&utm_campaign=greptile_for_open_source)

</div>

# Reverse API Engineer

> **Turn websites into APIs.** Browse (or let an agent browse), and get a clean, typed client for the endpoints the site actually uses.

<p align="center">
  <img src="https://raw.githubusercontent.com/kalil0321/reverse-api-engineer/main/assets/rae-agent-steam.gif" alt="Agent mode turning Steam's charts page into an API client">
  <br>
  <em>Agent mode</em>
</p>

---

## How it works

1. You give it a website and a goal ("fetch all Apple jobs").
2. A browser visits the site, either driven by you or by an AI agent.
3. Network traffic is captured to a HAR file.
4. Your configured model reads the traffic and writes a working API client in Python, JavaScript, TypeScript, Go, Java, C#, PHP, Ruby, C, or PowerShell.

No more manually opening DevTools, copying cURL commands, and gluing together a client.

## Install

```bash
uv tool install reverse-api-engineer   # or: pip install reverse-api-engineer
```

The secured cryptography dependency no longer supports Intel macOS or 32-bit Windows. Use Linux (including on Intel hardware), Apple Silicon macOS, or 64-bit Windows. Installing on the retired platforms may attempt an unsupported source build requiring Rust and OpenSSL development tools; this is not a supported installation path. Do not downgrade cryptography to restore old wheels. See the [upstream platform changes](https://cryptography.io/en/latest/changelog/#v49-0-0).

Agent mode (the default) captures through `npx`-launched browser tooling —
browser MCP servers (Playwright or Chrome DevTools) or the Vercel `agent-browser`
CLI — and needs no extra Python packages. **Manual mode** drives a local
Playwright browser, which ships in the optional `[manual]` extra:

```bash
uv tool install "reverse-api-engineer[manual]"   # or: pip install "reverse-api-engineer[manual]"
playwright install chromium
```

### Use it from your coding agent

Install the skill so Claude Code, Codex, Cursor, OpenCode and other agents know how to drive the CLI:

```bash
npx skills add kalil0321/reverse-api-engineer
```

Then ask your agent for what you need, for example "get me a typed client for the job search on this careers page". The skill lives in [`skills/reverse-api-engineer`](skills/reverse-api-engineer/SKILL.md).

## Quick start

```bash
reverse-api-engineer
> fetch all apple jobs from their careers page

# Browser opens. Navigate, interact, close when done.
# → ./scripts/apple_jobs_api/  (api_client.py, README.md, example_usage.py)
```

Cycle modes with **Shift+Tab**:

| Mode | What it does |
|------|--------------|
| `manual` | You drive the browser; AI generates the client from captured traffic. |
| `agent` | An AI agent drives capture autonomously (Playwright or Chrome MCP, or Vercel agent-browser CLI). |
| `engineer` | Re-run generation on a previous capture (`engineer <run_id>`). In the session it works on your latest run with a HAR, named above the input; `/engineer` picks another. Needs a HAR, so it works on `auto`, `agent-browser` and manual runs, not chrome-mcp runs. |

Agent mode providers:
- **chrome-mcp** (default for new configs; an existing `config.json` keeps its provider): drives your real Chrome so you keep existing sessions/cookies. Needs Node.js 20.19+; headed runs also need Chrome 146+ open with auto-connect enabled at `chrome://inspect/#remote-debugging`, and someone at the machine to accept Chrome's connection prompt when the run starts. For headed runs, rae checks before launching that Chrome's remote debugging port is reachable (not the Chrome or Node version) and stops with setup steps if it isn't; `agent --dry-run` shows the same check. Headless runs skip it. `--headless` starts a separate headless Chrome without your sessions. No HAR file is saved, so `engineer <run_id>` cannot regenerate these runs; run `agent` again instead.
- **auto**: Playwright MCP, records a HAR and needs no Chrome setup.
- **agent-browser**: [Vercel agent-browser](https://github.com/vercel-labs/agent-browser) **CLI** (not a Reverse API Engineer browser MCP server). At session start RAE uses whatever `agent-browser` is already on `PATH`, otherwise runs **`npm install -g <pin>`** (same pin as config / `RAE_AGENT_BROWSER_PACKAGE`), prints a yellow notice, validates with **`--help`**, and only then falls back to **`npx -y <pin>`** if npm cannot install. Prompts embed the resolved shell prefix alongside **`skills get core --full`**, **`skills list`**, HAR phases, cloud notes from `agent_browser_notes`. Tune with `agent_browser_npx_package` (optional), env `RAE_AGENT_BROWSER_*`. First Chromium fetch: **`agent-browser install`** (add `--with-deps` on trimmed Linux).


Optional sanity checks:

```bash
agent-browser doctor --offline --quick || true
agent-browser skills list >/dev/null
```

## Configuration

Settings live in `~/.reverse-api/config.json` and can be edited via `/settings` in the CLI:

```json
{
  "agent_provider": "chrome-mcp",
  "agent_browser_npx_package": "agent-browser@0",
  "agent_browser_notes": "",
  "claude_code_model": "claude-sonnet-4-6",
  "claude_setting_sources": [],
  "ollama_auto_start": true,
  "ollama_base_url": "http://127.0.0.1:11434",
  "opencode_auto_start": true,
  "opencode_base_url": "http://127.0.0.1:4096",
  "opencode_model": "big-pickle",
  "hermes_max_turns": null,
  "hermes_model": null,
  "hermes_provider": null,
  "opencode_npx_package": "opencode-ai@latest",
  "opencode_provider": "opencode",
  "copilot_model": "gpt-5",
  "codex_model": null,
  "codex_effort": null,
  "codex_home": null,
  "cursor_model": "composer-2.5",
  "output_dir": null,
  "output_language": "python",
  "real_time_sync": true,
  "sdk": "claude"
}
```

- **Models**: Sonnet 5.5, Opus 5.5 (most capable), Opus 4.6 and Haiku 5.5 (fastest). Sonnet 4.6 stays the default until you choose another; it and Haiku 4.5 are still accepted in config and by `--model`. For OpenCode see [models.dev](https://models.dev).
- **SDK**: `claude` (default), `opencode`, `codex` (OpenAI Codex), `cursor`, `copilot` (GitHub Copilot), or `hermes`.
- **Hermes**: engineers a saved capture through the [`hermes` CLI](https://hermes-agent.nousresearch.com/docs) instead of an SDK. It needs Hermes Agent v2026.9.21 or later from the official installer (the PyPI package is older): `curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash` on macOS, Linux and WSL2, `iex (irm https://hermes-agent.nousresearch.com/install.ps1)` in PowerShell on Windows. It needs no API key in rae: the model, the provider and the authentication are your own Hermes configuration. `hermes_model` and `hermes_provider` override which model that configuration runs; leaving them `null` uses whatever Hermes already selects. `hermes_max_turns` overrides the turn cap from your Hermes config. Runs start with `--ignore-rules`, so an `AGENTS.md` or `CLAUDE.md` in the workspace cannot steer the run. Cost is estimated from the token counts the CLI reports, and stays at 0 for a model with no known price. It covers `engineer` only: while `sdk` is `hermes` the `agent` command stops before opening a browser, so capture with `claude`, `opencode`, `copilot` or `cursor`, then switch `sdk` back to `hermes` to engineer that run. `agent --dry-run` reports the same thing.
- **Claude settings isolation**: Claude sessions don't load your Claude Code settings files, `CLAUDE.md`, hooks, plugins, permission rules or MCP servers, so your personal setup doesn't steer the agent. Organization-managed policy still applies, and Claude Code still reads its own state such as `~/.claude.json` and auto memory. If `~/.claude/settings.json` provides your authentication (`apiKeyHelper`, or Bedrock, Vertex or proxy variables under `env`), set `claude_setting_sources` to the layers to load, e.g. `["user"]` or `["user", "project", "local"]`. Each layer you list is loaded in full, including its hooks, plugins, permission rules and MCP servers.
- **OpenCode setup**: with `sdk: "opencode"`, RAE reuses an existing server or downloads/starts `opencode-ai@latest` through `npx`; a global OpenCode installation is not required. Fresh configurations default to the free `opencode/big-pickle` model. `/settings` shows a loading list, then offers a searchable **opencode provider / model** list populated from the server's connected, tool-capable catalog and marks free OpenCode options. Before creating a session, RAE validates the saved pair again and suggests currently available free models when configuration is invalid. Compatible older servers are reused with a version warning. Node.js 20+ is required for automatic startup. Password-protected servers use `OPENCODE_SERVER_PASSWORD` and optional `OPENCODE_SERVER_USERNAME`. Override startup with `OPENCODE_BASE_URL`, `RAE_OPENCODE_PACKAGE`, or `RAE_OPENCODE_AUTO_START=0`.
- **Codex setup**: install with `uv tool install "reverse-api-engineer[codex]"` (it brings its own Codex runtime) and sign in once with `codex login` or the Codex app. RAE runs Codex in its own home, `~/.reverse-api/codex`, whose `auth.json` links to your Codex sign-in, so your Codex `config.toml`, MCP servers, hooks, skills and `AGENTS.md`, and the apps connected to your ChatGPT account, don't steer the agent and RAE's runs stay out of your Codex history. Set `codex_home` (for example `"~/.codex"`) to run in a Codex home as it is, with all of its setup; that is also how to share a sign-in kept in the system keyring, or on Windows without permission to create symbolic links. `codex_model: null` uses your account's default model; `/settings` lists the models your account offers. `codex_effort: null` uses the model's default reasoning effort; `/effort` lists the levels the model offers. Like the other backends, the agent runs without Codex's sandbox or approval prompts.
- **Ollama through OpenCode**: choose provider `ollama` in `/settings`; RAE starts an installed Ollama daemon if needed, lists only installed models with tool calling and 64k+ context, and supplies OpenCode's provider config inline. Models are never downloaded silently. Override with `RAE_OLLAMA_BASE_URL` or `RAE_OLLAMA_AUTO_START=0`.
- **Output language**: `python`, `javascript`, `typescript`, `go`, `java`, `csharp`, `php`, `ruby`, `c`, or `powershell`. C needs a POSIX toolchain (`cc`, libcurl headers) — macOS/Linux, or WSL/MSYS2 on Windows. PowerShell needs `pwsh` 7+ (PowerShell Core, not Windows PowerShell 5.1). Its runner executes the generated `Example.ps1` beside `api_client.psm1`; argument overrides are not supported. Edit the example or import the module to call its exported functions with your own arguments.

## CLI

`reverse-api-engineer` opens a full-screen session; `agent` and `engineer` open it too when run in a terminal, and stay plain with `--json` or `--no-interactive`. Type `/` for the commands:
- `/model`, `/effort`, `/mode`: switch the model, how hard it thinks, and the mode (also Shift+Tab, ctrl+e).
- `/engineer [run_id]`: the run engineer mode works on, by default the latest with a HAR.
- `/settings`: SDK, agent provider, models, output and sync, changed in place in the session.
- `/history`: past runs with their details, to resume or re-engineer.
- `/resume [run_id]`: show a past run's conversation as it was and continue it where it stopped, on any SDK. Works for agent and engineer runs from this version on, which save their SDK session.
- `/output` (ctrl+o): everything from the session, unfolded. `/open`: the latest client.
- `/help` (or `/commands`): what rae does, its modes, commands and keys.
- `/new`, `/clear`, `/exit` (or `/quit`).

Scriptable subcommands (pipe to `jq`):

```bash
reverse-api-engineer agent --prompt "capture the public jobs api" \
  --url https://example.com/jobs --json | jq

reverse-api-engineer list --json
reverse-api-engineer show <run_id> --json
reverse-api-engineer run <run_id> --file api_client.py \
  --no-interactive --auto-install -- --org acme
```

Pass `--no-interactive` (and/or `--json`) to skip prompts. With `--json`, stdout is one JSON document and logs go to stderr.

### `agent --json` schema

| Field            | Type                | Notes                                                                  |
|------------------|---------------------|------------------------------------------------------------------------|
| `schema_version` | `int`               | Currently `1`.                                                         |
| `status`         | `"ok"` \| `"error"` | Top-level result.                                                      |
| `run_id`         | `string` \| `null`  | Use with `show` / `engineer` / `run`.                                  |
| `prompt`         | `string`            |                                                                        |
| `url`            | `string` \| `null`  |                                                                        |
| `mode`           | `string` \| `null`  | `"auto"`, `"chrome-mcp"`, or `"agent-browser"`.                                        |
| `har_path`       | `string` \| `null`  | Captured HAR.                                                          |
| `script_path`    | `string` \| `null`  | Generated client; exists whenever `status` is `"ok"`.                 |
| `usage`          | `object`            | `{input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, total_cost_usd}`, each present only when the SDK reports it, plus the SDK's own usage under `raw`. |
| `error`          | `string` \| `null`  | When `status == "error"`.                                              |

### Exit codes

| Code | Meaning |
|------|---------|
| `0` | Success. |
| `1` | Runtime error. |
| `2` | Missing required arg under `--no-interactive` / `--json`. |

For `run`, the exit code is the underlying script's return code on success, `1` if no script was found, or non-zero if `--no-interactive` would have had to prompt.

### Debugging agent failures

Set the `RAE_DEBUG` environment variable to `1` to print the Python traceback
for unexpected agent capture failures to stderr. Normal error messages remain
concise by default, and `--json` / `--json-stream` stdout remains machine-readable.

## Output locations

- `~/.reverse-api/runs/scripts/{run_id}/`: permanent storage
- `./scripts/{descriptive_name}/`: local copy with a readable name

## Caveats

- Generated code runs locally via Claude Code, so review before executing.
- Sites with aggressive bot detection may block capture or require manual interaction.

## Development

```bash
git clone https://github.com/kalil0321/reverse-api-engineer.git
cd reverse-api-engineer
uv sync
uv run reverse-api-engineer
```

Build: `./scripts/clean_build.sh`. Requires Python 3.11+ and an API key for agent mode. Manual mode additionally needs the `[manual]` extra plus `playwright install chromium`.

## License

MIT. See [LICENSE](LICENSE).
