> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Browser to API

> Generate an OpenAPI 3.1 document, a JavaScript client, and a coverage report from HTTP traffic captured during a browser workflow.

The `browser-to-api` skill turns traffic from a browser workflow into a draft OpenAPI 3.1 document. Use it to understand the endpoints a website calls, inspect request and response shapes, or document an API that has no published specification.

It analyzes a [Browser trace](/integrations/skills/browser-trace) capture offline. It doesn't capture traffic itself.

## Install

You need Node.js 18+ and a Browser trace run directory. Neither skill's analysis scripts need a separate dependency install. To create a new remote capture, you also need the Browse CLI and `BROWSERBASE_API_KEY`.

```bash theme={null}
npx skills add browserbase/skills --skill browser-trace --skill browser-to-api
npm install -g browse
```

## Capture and discover endpoints

Replace the URL and workflow below with the site and actions you want to document:

```text theme={null}
Use browser-trace and browser-to-api to document the product search flow
at https://app.example.com. Capture a search, a filter change, and opening
a product. Enable browse network capture on the same session so the
analysis has response bodies, and copy the bodies into the trace directory
before ending capture. Generate the API spec and open its HTML report.
List coverage gaps and release the browser session when finished.
```

The trace supplies request and response events. `browse network on` adds response bodies, which your agent copies into `<run>/cdp/network/bodies/` before another capture can reuse the directory. Without those bodies, the generated spec lacks response-body schemas.

## Analyze an existing trace

Ask your agent to run `scripts/discover.mjs` from the installed `browser-to-api` skill directory with `--run` pointing to your trace. For example, from that skill directory:

```bash theme={null}
node scripts/discover.mjs --run /absolute/path/to/.o11y/product-search
```

Use `--origins` to focus on relevant API hosts, `--bodies` for a separate body capture directory, and `--redact` for additional sensitive header names or JSON keys.

## Review the output

The skill writes an `api-spec/` directory inside the run:

| File | Purpose |
| - | - |
| `index.html` | Interactive report with operations, examples, and client usage. |
| `openapi.yaml` and `openapi.json` | OpenAPI 3.1 documents. |
| `client.mjs` | Generated JavaScript fetch client. |
| `report.md` | Coverage summary and request examples. |
| `confidence.json` | Per-endpoint confidence and path normalization flags. |

Coverage only includes the flows you exercised. Schemas infer shapes from samples; they don't establish the server's contract. Review ambiguous paths and missing response bodies, then capture additional flows as needed. Default redaction is best-effort, so inspect reports and samples before sharing them.

## Further reading

<CardGroup cols={2}>
  <Card title="Browser trace" icon="magnifying-glass" href="/integrations/skills/browser-trace">
    Capture the browser workflow that feeds API discovery.
  </Card>

  <Card title="Skill source" icon="github" href="https://github.com/browserbase/skills/tree/main/skills/browser-to-api">
    View discovery flags, inference rules, and output formats.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.