## 1
1. Those Packet Capture Files Lying Around on Your Hard Drive
Independent developers have probably all been through this scenario: you take on secondary development for a legacy project, or you need to integrate with a third-party system that has no documentation. The only clue you have is a packet capture file from a colleague—a HAR file, a JSON exported from Charles, or even a cURL command copied and pasted directly.
The pain points are very concrete:
- No documentation. You guess at API parameters, test your way through field meanings, and accumulate knowledge of error codes by stepping on landmines.
- Manual organization is too slow. For a capture file containing dozens of requests, manually breaking down each URL, header, request body, and response structure one by one, then writing it up as proper documentation, typically takes a full day or more.
- Outdated as soon as it's written. The documentation you finally pieced together becomes invalid as soon as the API changes, and no one wants to maintain it.
- Small teams have no one to do this work. Writing documentation is the task that always gets bumped—it's perpetually "next week's problem."
I had a real experience of this myself: I took over an internal legacy system, and all the other side gave me were two capture export files totaling 87 HTTP requests across 23 different API paths. My estimate at the time was that manual organization would take at least 6 to 8 hours—assuming I didn't doze off midway or copy fields incorrectly.
In the end, AI produced a first draft for me in about 20 minutes, and I spent another half hour verifying and supplementing the business descriptions. A full day's work was compressed into under an hour.
2. What AI Can Actually Do for This Task
Many people think AI can only "help write some code," but when it comes to organizing API documentation, AI can do far more than you'd imagine:
- Automatic deduplication and grouping. Capture data contains plenty of duplicate requests (polling, retries, static resources). AI can group by path and method, consolidating 87 raw requests into 23 APIs.
- Extracting parameter structures. From the request bodies of multiple requests, it can derive field lists, types, and whether fields are required—it can even infer which fields are variable based on multiple samples.
- Inferring semantic naming. Field names in captures are often abbreviations or pinyin. AI can provide reasonable Chinese meaning annotations based on context (to be confirmed by a human).
- Generating standard documentation structure. It directly outputs Markdown or OpenAPI format, including request methods, paths, parameter tables, response examples, and error code descriptions.
- Flagging "uncertain items". With good prompts, AI will explicitly list "field meanings I guessed" and "parts where samples were insufficient to determine," making human review easier.
The key point: AI doesn't make the final decisions for you—it does the repetitive labor for you. Final confirmation of field meanings still relies on humans, but the entire process from zero to first draft can absolutely be handed off to AI.
3. My Actual Workflow
The whole process has four steps:
Step 1: Preprocess the capture file. Capture exports often contain a lot of noise (images, fonts, analytics requests). I do a rough pass first, keeping only business API-related requests, and export them as JSON. AI can assist with this step, but doing it yourself is more reliable.
Step 2: Feed in batches. If there are many requests, don't dump them all into the AI at once. I split them into 3 batches by API module, about 30 requests each, processing them in rounds to avoid omissions and hallucinations caused by overly long contexts.
Step 3: Use a structured prompt. This is the most critical step. The prompt template is attached in the next section—you can copy and use it directly.
Step 4: Human review. Focus on verifying fields the AI marked as "guessed," required-field judgments, and error code descriptions. This step cannot be skipped—AI handles structure and formatting, but business semantics must be vetted by a human.
4. A Ready-to-Copy Prompt Template
你是一位资深后端工程师,擅长编写接口文档。我会提供一份抓包数据(JSON 格式),
请将其整理成规范的接口文档,要求如下:
1. 按接口路径 + HTTP 方法去重分组,相同的接口合并为一条文档;
2. 每个接口包含:接口名称、请求方法、完整 URL、路径参数、查询参数、
请求 Header(标注哪些是认证相关)、请求体字段表(字段名、类型、示例值、
是否必填、含义说明)、响应体字段表、响应状态码说明;
3. 字段含义如果抓包数据中无法确定,请基于命名和上下文给出推测,并统一在
「待人工确认」章节列出,不要编造确定的描述;
4. 字段是否必填:如果多条请求样本中某字段始终出现,标注"疑似必填";
出现缺失的标注"非必填";
5. 输出格式为 Markdown,接口较多时按业务模块分节;
6. 对于响应中包含的列表数据,请归纳列表元素的字段结构,而不是罗列每条记录。
以下是抓包数据:
{{在此粘贴抓包 JSON}}In actual use, just replace {{在此粘贴抓包 JSON}} with your data. If you're using a Claude or GPT-4-level model, processing a batch of 30 requests yields fairly stable results; if you want to control costs, you can also use a cheaper model for the deduplication and grouping first, then a stronger model to generate the documentation body—refer to the official pricing pages for specific model prices.
5. Before-and-After Comparison
Using this method, I did a simple efficiency comparison:
| Task | Purely Manual | AI-Assisted |
|---|---|---|
| Request deduplication and grouping | ~1 hour | 3 minutes (done automatically by AI) |
| Field structure extraction and tabulation | ~3 hours | ~10 minutes |
| Document formatting and standardization | ~1.5 hours | 0 minutes (outputs standard format directly) |
| Business semantics supplement and review | ~1.5 hours | ~30 minutes |
| Total | ~7 hours | ~45 minutes |
That's nearly a 9x efficiency gain, plus a few benefits that manual work can't achieve: the field tables AI generates are completely uniform in format—no "meticulous at first, sloppy later on"—and after each batch it proactively lists uncertain items, which is more manageable than guessing as I write.
For small teams, this calculation can be framed differently: if you estimate based on one working day's labor cost, the time saved on each documentation pass is enough to build one more feature module. Documentation goes from "nobody wants to do it" to "just doing it along the way"—and that's the most practical change of all.
6. A Few Tips and Reminders
- Don't skip human review. AI's inferences about field meanings can be right or wrong; publishing directly is risky.
- Desensitize sensitive information first. Tokens, phone numbers, and internal IPs in capture data must be scrubbed before feeding them in.
- Keep original samples. Attaching one desensitized real request example in the documentation is more intuitive than ten lines of description.
- Put documentation under version control. AI makes documentation updates cheap, so it's even more important to stick to the habit of "re-organize whenever an API changes."
If you also frequently need to call various LLM APIs for this kind of batch processing and structured output work, give https://api.thistoken.ai/register a try. It aggregates multiple mainstream models, and you can get started right after registering—letting AI truly save you the time spent on repetitive labor.
---
Ready to try it yourself? Sign up at https://api.thistoken.ai/register to get your API key and start building.
Хотите попробовать Token.AI?
Создайте API Key уровня проекта, включите каналы в консоли и настройте маршрутизацию, бюджеты и журналы аудита.
注册 ThisToken.AI 并获取 API Key