Form2API
All you need to do: send me the form URL, then submit the form once manually. I'll handle the rest.
What it does:
- - Injects a network interceptor into the page to capture real API requests on form submission
- Analyzes the request structure, annotating which fields are user input vs fixed values vs auto-generated
- Generates complete API documentation with curl and Python examples
- Enables batch/automated operations without manual form filling
Typical use cases:
- - Internal system forms are tedious — you want to create data in bulk via script
- You need to automate a workflow but there's no official API documentation
- You want to understand what APIs a form is actually calling under the hood
How to trigger:
Send me the form page URL and say something like "reverse this form" / "find the API for this form" / "I want to automate this form".
Workflow (Agent execution steps)
Step 1: Inject interceptor
After opening the target page, inject the interceptor script via the browser tool's evaluate action:
CODEBLOCK0
On success returns { status: 'injected' }. Returns already_active if already injected.
Step 2: Prompt user to submit the form
Tell the user:
"Interceptor is ready. Please fill out and submit the form normally in the browser, then let me know when done."
Step 3: Read captured results
After user submits, run evaluate to read captured requests:
CODEBLOCK1
Save the result to /tmp/form_api_raw.json.
Step 4: Analyze requests
CODEBLOCK2
Outputs a ranked list of candidate API requests. Structured result saved to /tmp/form_api_analysis.json.
Step 5: Extract cookies
CODEBLOCK3
Cookies are auto-cached in /tmp/form_api_cookies/ for 1 hour. Repeated calls reuse the cache.
Step 6: Generate API documentation
Based on the analysis, using references/output_template.md as reference, generate complete API docs including:
- - Endpoint info (URL, method, content-type)
- Request parameter table (user input / fixed value / system-generated)
- Cookie extraction command
- curl and Python call examples
Scripts
| Script | Purpose |
|---|
| INLINECODE8 | Injected into page to hook fetch/XHR |
| INLINECODE9 |
Standardized cookie extraction with caching |
|
scripts/analyze_requests.py | Filter and annotate captured requests |
Notes
- - Browser requirement: The target page must already be open and logged in within the current browser session
- Interceptor lifecycle: Interceptor is cleared on page refresh — re-inject if needed
- Multiple submissions:
window.__capturedRequests accumulates across submissions; analysis picks the most relevant batch - Cookie expiry: If API returns 401/403, re-extract with
--force flag - Output format reference: INLINECODE13
Form2API
你只需要做:把表单URL发给我,然后手动提交一次表单。剩下的交给我。
功能说明:
- - 在页面中注入网络拦截器,捕获表单提交时的真实API请求
- 分析请求结构,标注哪些字段是用户输入、固定值还是自动生成
- 生成包含curl和Python示例的完整API文档
- 支持批量/自动化操作,无需手动填写表单
典型使用场景:
- - 内部系统表单操作繁琐——希望通过脚本批量创建数据
- 需要自动化工作流程但缺乏官方API文档
- 想要了解表单底层实际调用了哪些API
触发方式:
将表单页面URL发给我,并说类似逆向这个表单/查找这个表单的API/我想自动化这个表单。
工作流程(Agent执行步骤)
第1步:注入拦截器
打开目标页面后,通过browser工具的evaluate操作注入拦截器脚本:
从以下路径读取脚本内容:
dir>/scripts/injectinterceptor.js
然后通过browser(action=act) evaluate执行,注入到页面中。
成功时返回{ status: injected }。如果已注入则返回already_active。
第2步:提示用户提交表单
告诉用户:
拦截器已就绪。请在浏览器中正常填写并提交表单,完成后告诉我。
第3步:读取捕获结果
用户提交后,运行evaluate读取捕获的请求:
javascript
JSON.stringify(window.capturedRequests)
将结果保存到/tmp/formapiraw.json。
第4步:分析请求
bash
python3 dir>/scripts/analyzerequests.py /tmp/formapiraw.json
输出候选API请求的排名列表。结构化结果保存到/tmp/formapianalysis.json。
第5步:提取Cookie
bash
COOKIE=$(python3 dir>/scripts/extractcookies.py )
echo $COOKIE
Cookie自动缓存到/tmp/formapicookies/,有效期1小时。重复调用会复用缓存。
第6步:生成API文档
基于分析结果,以references/output_template.md为参考,生成完整的API文档,包括:
- - 端点信息(URL、方法、内容类型)
- 请求参数表(用户输入/固定值/系统生成)
- Cookie提取命令
- curl和Python调用示例
脚本
| 脚本 | 用途 |
|---|
| scripts/injectinterceptor.js | 注入页面以拦截fetch/XHR |
| scripts/extractcookies.py |
标准化的Cookie提取(带缓存) |
| scripts/analyze_requests.py | 过滤和标注捕获的请求 |
注意事项
- - 浏览器要求:目标页面必须在当前浏览器会话中已打开并登录
- 拦截器生命周期:页面刷新后拦截器会被清除——需要时重新注入
- 多次提交:window.capturedRequests会累积多次提交的数据;分析时会选择最相关的批次
- Cookie过期:如果API返回401/403,使用--force标志重新提取
- 输出格式参考:references/output_template.md