## 1
1. First, Let's Talk About That API Documentation Nobody Wants to Write
Independent developers and small teams have probably all been through this: a project requires integrating with an API that has no documentation—maybe it's a legacy system from the client, maybe a third-party platform that didn't provide complete API specs, or maybe the previous engineer left behind nothing but a barely working demo when they quit.
What's your first reaction? Open up a packet-capture tool, grab the requests one by one with Charles or Fiddler, and manually compile them into documentation.
That's exactly what I did last month. A legacy system needed to be migrated, and the only reference available was the frontend code—all backend APIs had to be reverse-engineered from packet captures. 317 requests, covering roughly 60+ APIs. I estimated the workload of doing it purely by hand:
- Copying the URL, method, headers, and body for each request
- Figuring out which requests belong to the same API versus which ones just differ in parameters
- Inferring field meanings and marking which ones are required
- Organizing response structures and flattening nested JSON into tables
At an average of 15 minutes per API, 60 APIs means 15 hours—nearly two full workdays, and the kind of mind-numbingly tedious 15 hours where one mis-copied field breaks everything downstream.
That's the pain point: packet capture isn't hard—what's hard is turning a pile of raw messages into documentation a human can read. The task isn't technically demanding, but it's extremely draining, and nobody wants to do it.
2. What AI Can Do Here
I ended up handing this task to AI. The core idea is simple: AI doesn't do the packet capture—you still do that; what AI does is all the conversion work from raw messages to structured documentation—the most time-consuming and tedious 80% of the job.
Specifically, AI can help you accomplish four things:
1. Merging similar requests. Among the 317 raw records, a large number of requests are actually calls to the same API with different parameters. AI can cluster them by URL pattern, request method, and request body structure, identifying that "these 57 records are actually the same API."
2. Reconstructing API structure. From multiple requests to the same API, AI can infer which fields are fixed parameters, which are business parameters, and which fields appear only sometimes (most likely optional fields).
3. Generating standardized documentation. Output in whatever format you specify—Markdown tables, OpenAPI 3.0 YAML, or a format importable into Apifox. Field descriptions, types, and example values, all generated in one pass.
4. Flagging uncertain items. The reliable approach is to have AI explicitly mark "this field's meaning is inferred from context, low confidence," rather than making up an explanation. These flagged points are the only places you need to focus on during manual review.
3. The Actual Workflow
The whole process has three steps, using my 60+ API project as an example:
Step 1: Export the captured data. Export a HAR file (HTTP Archive, JSON format—both Charles and Chrome DevTools support this export) from your packet-capture tool. The HAR contains complete request and response information. If the file is too large, roughly split it into several parts by domain or path.
Step 2: Feed it to AI in batches. Stuffing hundreds of requests into the context at once will blow it up. My approach was to batch by business module, 20–40 requests per batch, paired with a consistent prompt (see the template in the next section). Each batch produces one documentation fragment.
Step 3: Merge and review. Have AI merge the fragments into a unified format, then focus your review on the fields it flagged as "low confidence" and verify the merging logic is correct.
Here's the time accounting: capturing and splitting took 1.5 hours, writing and tuning the prompt took 0.5 hours, feeding batches took about 2 hours total, and review took 1 hour. 5 hours in total, versus an estimated 15 hours manually—saving 10 hours, roughly 3x the efficiency. And the quality is higher—by the 40th API, a human is already numb from copying; AI isn't.
If calling large language model APIs is involved, for cost refer to the official pricing page. At my scale (tens of thousands of lines of message text), it's typically on the order of what you'd spend on a bubble tea, mentally speaking.
4. A Copy-Paste-Ready Prompt Template
你是一位资深后端工程师,擅长接口逆向分析。我会提供从抓包工具导出的
HAR数据片段,请帮我整理成接口文档,要求如下:
1. 归并:将同一接口的不同请求(仅参数值不同的)归并为一个接口定义,
并说明归并依据;
2. 字段分析:对每个接口,列出请求参数和响应字段,包括:字段名、
类型、是否必填(根据多条样本对比推断)、示例值、含义推测;
3. 置信度标注:字段含义如果只是推测,标注[待确认],不要编造确定
的解释;
4. 输出格式:Markdown,每个接口包含:接口名称(自拟)、URL、方法、
请求头关键项、请求参数表、响应结构表、调用示例;
5. 对于你无法从样本中确认的信息(如错误码含义),明确写"样本中未
出现",不要猜测。
以下是HAR数据片段:
<在此粘贴HAR内容>Two usage tips: first, if your documentation ultimately needs to go into Apifox or Postman, change item 4 to "output OpenAPI 3.0 spec YAML"—AI can directly generate an importable file; second, after the first batch, review the quality manually and append any issues you find (like incorrect merging) to the prompt before running subsequent batches—accuracy will improve noticeably.
5. Before-and-After Comparison
| Dimension | Pure Manual | AI-Assisted |
|---|---|---|
| Time to document 60 APIs | ~15 hours | ~5 hours |
| Field transcription errors | Human copying inevitably errors | Structured conversion has virtually zero transcription errors |
| Optional field identification | Relies on memory and eyeballing | Automatic multi-sample comparison and inference |
| Output format consistency | Gets sloppier as you go | Consistent template throughout |
| Human state | Numb starting from hour 2 | Only need to focus on the review step |
What you save isn't just 10 hours—more importantly, it frees you from the role of "human converter." You're only responsible for making judgments (is this field what we think it is), not for doing the搬运—wait, not for doing the grunt work of moving data around.
Final Thoughts
For independent developers and small teams, "AI replacing repetitive labor" in practice usually isn't some grand Agent system—it's concrete scenarios like this that save you two workdays in one shot. Tasks like organizing packet-capture data, log analysis, and configuration comparison—this kind of "format conversion + pattern recognition" dirty work—is precisely what large language models excel at, and where the return on investment is most tangible.
If you're still struggling with API calls and management and want a unified OpenAI-compatible gateway to manage your model calls, check out https://api.thistoken.ai/register —you can get started right after signing up, and spend the time you save on code that's truly worth writing.
---
Ready to try it yourself? Sign up at https://api.thistoken.ai/register to get your API key and start building.
Ready to try Token.AI?
Create a project-level API Key, enable channels in the console, and configure routing, budgets, and audit logs.
注册 ThisToken.AI 并获取 API Key