跳到主内容
智客 ZICQ

技能库 智客分类:文档办公 browser-to-api

Browser To Api

将一个网站的可观测到的HTTP流量通过分析一个"浏览器-跟踪"捕获器变成一个最佳OpenAPI 3.1 spec. 当用户想从浏览器会话中发现/提取API端点,从网络流量中构建一个OpenAPI doc,或者记录第三方站点的XHR/fetch表面用于客户端集成时使用.

1836 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

通过分析“浏览者追踪”捕获,将网站可观测到的HTTP流量转换为最佳OpenAPI 3.1 spec

何时用

- 用户想要第三方或无文件网站API的 OpenAPI 文档

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Browser to API、When to use、Two-step workflow、1. Capture with `browser-trace` (and optionally bodies via `browse network on`)、Local example against an existing debuggable Chrome target、...drive whatever flows you want covered...。 其中含规范建议的小节:分步指令、输入输出示例。

文件分析

文件分析:除 SKILL.md 外,正文引用了 scripts/start-capture.mjs、scripts/stop-capture.mjs、scripts/bisect-cdp.mjs、scripts/discover.mjs,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Turn a website's observable HTTP traffic into a best-effort OpenAPI 3.1 spec by analyzing a `browser-trace` capture. Use when the user wants to discover/extract API endpoints from a browser session, build an OpenAPI doc from network traffic, or document a third-party site's XHR/fetch surface for client integration.

Browser to APIWhen to useTwo-step workflow1. Capture with `browser-trace` (and optionally bodies via `browse network on`)Local example against an existing debuggable Chrome target...drive whatever flows you want covered...Snapshot the bodies dir BEFORE turning capture off (the temp dir is sharedper-session, so subsequent `browse network on` runs would mix your bodieswith whatever a future capture writes if you skip this step).2. Generate the spec→ .o11y/my-site/api-spec/index.html ← open this.o11y/my-site/api-spec/client.mjs

兼容:Requires Node 18+ and a `browser-trace` run directory (`.o11y/<run>/`) produced by the sibling `browser-trace` skill. The scripts use only the Node standard library — no `npm install` step. `jq` is referenced in docs for ad-hoc querying but is not required by the scripts. · 许可:MIT · allowed-tools:Bash, Read, Grep

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
browser-to-api
description
Turn a website's observable HTTP traffic into a best-effort OpenAPI 3.1 spec by analyzing a `browser-trace` capture. Use when the user wants to discover/extract API endpoints from a browser session, build an OpenAPI doc from network traffic, or document a third-party site's XHR/fetch surface for client integration.
compatibility
Requires Node 18+ and a `browser-trace` run directory (`.o11y/<run>/`) produced by the sibling `browser-trace` skill. The scripts use only the Node standard library — no `npm install` step. `jq` is referenced in docs for ad-hoc querying but is not required by the scripts.
allowed-tools
Bash, Read, Grep实验字段,支持情况取决于客户端;字段声明本身不会授予工具权限。
许可
MIT
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 4
  • scripts/start-capture.mjs
  • scripts/stop-capture.mjs
  • scripts/bisect-cdp.mjs
  • scripts/discover.mjs

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「browser-to-api」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-1dc9922f7c2b4ac6-%E6%B5%8F%E8%A7%88%E5%99%A8%E5%88%B0-Api.html
请存为 .cursor/skills/browser-to-api/SKILL.md 或 .claude/skills/browser-to-api/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/browserbase/skills 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/browserbase/skills' --list

npx skills add 'https://github.com/browserbase/skills' --skill 'browser-to-api'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: browser-to-api description: Turn a website's observable HTTP traffic into a best-effort OpenAPI 3.1 spec by analyzing a `browser-trace` capture. Use when the user wants to discover/extract API endpoints from a browser session, build an OpenAPI doc from network traffic, or document a third-party site's XHR/fetch surface for client integration. compatibility: "Requires Node 18+ and a `browser-trace` run directory (`.o11y//`) produced by the sibling `browser-trace` skill. The scripts use only the Node standard library — no `npm install` step. `jq` is referenced in docs for ad-hoc querying but is not required by the scripts." license: MIT allowed-tools: Bash, Read, Grep --- # Browser to API Replay-driven API discovery. Consume a `browser-trace` capture, pair its CDP request / response events, templatize observed URLs, infer JSON schemas from samples, and emit an **OpenAPI 3.1** document plus a human-readable coverage report. This skill **does not capture traffic**. It is purely offline post-processing on top of `browser-trace`'s `cdp/network/*.jsonl` buckets. The two skills compose: ``` browser-trace → .o11y//cdp/network/{requests,responses}.jsonl browser-to-api → .o11y//api-spec/index.html + openapi.yaml + client.mjs ``` ## When to use - The user wants an OpenAPI document for a third-party or undocumented website API. - The user has a `browser-trace` run and wants endpoints + schemas extracted from it. - The user is building a client/SDK against a site that doesn't publish a spec. - The user wants a coverage report showing which flows would broaden the spec. If the user wants to **capture** traffic, send them to `browser-trace` first. ## Two-step workflow ### 1. Capture with `browser-trace` (and optionally bodies via `browse network on`) ```bash # Local example against an existing debuggable Chrome target TARGET=9222 node ../browser-trace/scripts/start-capture.mjs "$TARGET" my-site browse open about:blank --cdp "$TARGET" browse network on # capture request/response bodies browse open https://example.com # ...drive whatever flows you want covered... # Snapshot the bodies dir BEFORE turning capture off (the temp dir is shared # per-session, so subsequent `browse network on` runs would mix your bodies # with whatever a future capture writes if you skip this step). cp -r "$(browse network path | jq -r .path)" .o11y/my-site/cdp/network/bodies/ browse network off node ../browser-trace/scripts/stop-capture.mjs my-site node ../browser-trace/scripts/bisect-cdp.mjs my-site ``` `browse network on` is **optional but strongly recommended** — without it, the spec has no response-body schemas (the CDP firehose used by `browse cdp` does not embed bodies). With it, both request bodies (already captured by CDP) *and* response bodies are joined into the trace by CDP `requestId`. ### 2. Generate the spec ```bash node scripts/discover.mjs --run .o11y/my-site # → .o11y/my-site/api-spec/index.html ← open this # .o11y/my-site/api-spec/client.mjs # .o11y/my-site/api-spec/openapi.yaml # .o11y/my-site/api-spec/openapi.json # .o11y/my-site/api-spec/report.md # .o11y/my-site/api-spec/confidence.json # .o11y/my-site/api-spec/samples/*.json # .o11y/my-site/api-spec/intermediate/*.jsonl ``` `discover.mjs` auto-detects `/cdp/network/bodies/`. To use a body capture from elsewhere (e.g. didn't snapshot, want the live `browse network` dir), pass `--bodies ` explicitly. ### 3. Open the HTML report After `discover.mjs` finishes, **always open the generated HTML report**: ```bash open .o11y/my-site/api-spec/index.html ``` The report is a self-contained HTML file (no server needed) that shows each discovered operation as an expandable card with variables, client usage, request/response examples, and a generated `client.mjs` snippet at the bottom. This is the primary deliverable — always open it for the user. ## CLI flags | Flag | Required | Meaning | |---|---|---| | `--run ` | yes | Path to a `browser-trace` run directory | | `--out ` | no | Output dir; default `/api-spec/` | | `--bodies ` | no | `browse network` capture dir to join into the trace (auto-detected from `/cdp/network/bodies/` when present) | | `--include ` | no | Only include URLs matching regex (repeatable) | | `--exclude ` | no | Exclude URLs matching regex (repeatable; in addition to defaults) | | `--origins ` | no | Comma-separated origin allow-list (e.g. `api.example.com,example.com`) | | `--format ` | no | Output format. Default `both` | | `--title ` | no | OpenAPI `info.title`. Default derived from primary origin | | `--redact ` | no | Extra header names / JSON keys to redact (comma-separated) | | `--min-samples ` | no | Minimum samples per endpoint to include. Default `1` | | `--stage ` | no | Run only one stage: `load`, `filter`, `normalize`, `infer`, `emit` | ## Output layout ``` /api-spec/ ├── index.html visual report — open this (self-contained, no server) ├── client.mjs zero-dep fetch client with typed functions per operation ├── openapi.yaml machine-readable spec ├── openapi.json mirror ├── report.md markdown summary + curl examples ├── confidence.json per-endpoint confidence + normalization flags ├── samples/ redacted request/response examples │ └── __.json └── intermediate/ pipeline byproducts (paired/filtered/endpoints jsonl) ``` ## What you get from `browse cdp` and `browse network` Two complementary capture sources: | Source | Provides | Limitation | |---|---|---| | `browse cdp` (used by `browser-trace`) | request method/URL/headers/`postData`, response status/headers/mimeType, full event timing | **Does not embed response bodies.** Bodies must be pulled with `Network.getResponseBody`, which the firehose doesn't do. | | `browse network on` (separate command) | request bodies AND response bodies on disk, keyed by CDP `requestId` | Capture dir is shared per `browse` session; snapshot before another `browse network on` overwrites it. | `discover.mjs` will pull bodies from a `browse network` dir if you pass `--bodies ` (or stash them under `/cdp/network/bodies/`, which is auto-detected). The matching is by `requestId` — `browse network` writes that into each `request.json` as `id`, and we join directly. What changes when bodies are present: - ✅ Path templating, query-param schemas, status codes, content-types — same either way. - ✅ Request-body schemas — `postData` from CDP is enough; bodies dir is a nice-to-have for non-`postData` cases. - ✅ **Response-body schemas** — fully inferred from real samples. Without bodies you get `{ description, content: }` skeletons. The report flags every endpoint that has no response-body sample. ## Automatic noise filtering The normalize stage automatically classifies and drops infrastructure noise: - **Tracking / analytics** — paths containing `/track`, `/pixel`, `/beacon`, `/impression`, `/pageview`, `/dag/v*` - **Bot defense** — Akamai (`/akam/`), fingerprint payloads (`sensor_data`), obfuscated multi-segment paths - **Session plumbing** — `/session`, `/authenticate/start`, cookie consent, A/B experiment endpoints - **HTML page renders** — `GET` requests returning `text/html` (the rendered page, not the API) This typically drops 60-80% of captured traffic. The `--include` flag can rescue a false positive. ## GraphQL / multiplexed endpoint decomposition When a single endpoint (like `/dapi/fe/gql`) is called with different `operationName` values, the skill automatically splits it into separate logical operations. Each gets its own: - OpenAPI path entry (e.g. `/dapi/fe/gql [Autocomplete]`) - Request/response schema inferred from only that operation's samples - Curl example and variables table in the report Detection works on body fields (`operationName`, `method`, `action`) and query params (`opname`, `op`). This covers GraphQL (APQ and inline), JSON-RPC, and similar dispatch patterns. ## Limitations - **Coverage is bounded by the captured flow.** Endpoints not exercised in the trace will not appear. The skill cannot prove completeness. - **Schemas are inductive, not contractual.** A field might be optional on the server even if every sample contained it. - **Auth is observed, not specified.** The skill records auth-shaped headers in an `x-observed-auth` extension but won't claim a security scheme. - **Path templating is heuristic.** Numeric / UUID / hex / slug patterns are detected per segment. Ambiguous URLs are flagged in `confidence.json`. - **Redaction is best-effort.** Default redactions cover common credentials, but app-specific secrets may slip through; use `--redact` for known custom headers/keys. ## Best practices 1. **Drive the flows you want documented.** The richer the browser-trace, the richer the spec. 2. **Use `--origins` for noisy sites.** A marketing page hits dozens of analytics hosts; restrict to the API origin you care about. 3. **Inspect `report.md` first.** It has curl-ready examples and response samples for every discovered operation. 4. **Bump `--min-samples` to 2+** when you want only confidently-shaped endpoints in the final doc — drop the long tail. 5. **Pair with `browse network on`** when response-body schemas matter. The CDP firehose alone has request bodies but not response bodies. For pipeline internals and the file format reference, see [REFERENCE.md](REFERENCE.md).

相关技能

文档办公

Ontology

为结构化的代理内存和可堆肥技能所打入的知识图. 在创建/征服实体(Person, project, Task, Evention, Document)时使用,链接相关对象,强制约束,规划多步动作作为图变,或技能需要共享状态时使用. 触发到"记住","我知道什么","链接X到Y",…

文档办公

Nano Pdf

使用纳米-pdf CLI编辑带有自然语言指令的PDF.

文档办公

Word / DOCX

创建,检查,并编辑有可靠样式的Microsoft Word文档和DOCX文件,编号,跟踪更改,表格,章节,并进行相容性检查. 当 (1) 任务涉及 Word 或 ".docx " 时使用; (2) 文件包括跟踪的更改,评论,字段,表格,模板,或页面布局限制; (3) 文档必须在不…

文档办公

Api Gateway

通过 Maton 网关调用第三方 API, 它为用户已经连接的应用程序注入证书 。 当用户命名一个连接的应用程序和其中的具体行动时使用此技能——读取一个邮箱,查询一个CMM,归档一个问题,更新一个电子表格,通过一个连接的搜索或刮取提供者运行一个查询. 每一次通话都到用户连接的应用…