Communitygithub.com

parse-api-doc — API Document Field Smart Parser

Parse API documents into structured field names/types/required/endpoints, directly outputting field mappings. Ideal for integrating third-party systems or low-code setups.

What is parse-api-doc — API Document Field Smart Parser?

This skill is a standalone, zero-dependency Node ESM module that parses API documentation (such as ERP, OpenAPI, or internal platform specs) into a structured list of fields, including their names, types, required status, and endpoint info. It automatically detects input formats like Markdown tables, JSON Schema, sample JSON, or plain-text field lists, making it easy to extract and map fields from various documentation sources. The module also provides fuzzy matching and alias resolution for field names, allowing seamless mapping between different naming conventions (e.g., 'asin' to '商品ID'). It is designed for use in AI agent workflows, low-code platforms, or as a reference implementation for building custom field extraction pipelines. All processing is local, with no network calls.

Works with~Claude Code~Codex CLI~Cursor
npx skills add shuangying0001-beep/parse-api-doc

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

parse-api-doc — Intelligent API Document Field Parser

Parse any format of API/field documentation into a structured field list + field mapping, used for integrating third-party systems. Pure function implementation (Node ESM, zero dependencies), can be directly imported, and serves as a reference implementation for AI-driven field extraction.

Use Cases

  • When you receive API documentation from an ERP / open platform / internal middleware and need to quickly know "what fields exist, their types, and which are required"
  • When you need to map fields from an external document to your own collection/storage fields (fuzzy matching aliases for inconsistent field names)
  • When extracting fields in batch from Markdown tables, JSON Schema, sample JSON, or plain-text field lists

Supported Input Formats (Auto-Detected)

  1. Markdown table: | Field | Type | Required | Description |
  2. JSON Schema: Contains "properties" + "type"
  3. Sample JSON: { "asin": "B0XXX", "title": "Title" }
  4. Plain-text field list: asin: Product ID / title (string) Product Title

Usage

import { parseErpDocument, matchField, loadVocabulary } from './scripts/doc-parser.mjs';

const doc = `
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| asin | string | Yes | Product ID |
| title | string | No | Product Title |
`;

const result = parseErpDocument(doc);
console.log(result.detectedFormat);   // markdown_table
console.log(result.productFields);    // [{name,type,required,description}]
console.log(result.fieldMappings);    // [{erpField,erpType,erpRequired,erpDescription,collectorField}]
console.log(result.endpoint);         // Automatically inferred method+path

Core API

  • parseErpDocument(content, options?) → DocParseResult
    • options.vocabulary: Custom field vocabulary (default includes a common set of e-commerce/API fields; inject your own)
    • Returns: { success, detectedFormat, productFields[], endpoint, requestStructure, responseStructure, fieldMappings[], error? }
  • matchField(name, vocabulary?) → Matched standard field key (fuzzy/alias matching, normalized case and _-)
  • loadVocabulary(text) → Build a vocabulary from text (for ad-hoc extension)

Field Mapping Vocabulary (Injectable)

The default vocabulary covers common fields (asin/title/price/rating/bsr/image/brand...). When integrating with your own system, pass your custom vocabulary:

const myVocab = [
  { key: 'sku', aliases: ['sku', '货号', 'SKU'] },
  { key: 'stock', aliases: ['stock', '库存', 'quantity'] },
];
parseErpDocument(doc, { vocabulary: myVocab });

Notes

  • On parse failure, success=false and an error.code is provided (EMPTY_CONTENT / PARSE_ERROR / NO_FIELDS_FOUND), along with error.suggestion offering targeted fix advice.
  • This is a structure extraction tool; it does not make network calls or send any data—purely local parsing.

Related Skills