MarkUDown

Extract API — MarkUDown AI 数据提取 API 文档

POST/api/extract

Extract

抓取 URL 并使用 LLM 根据您的 Schema 提取结构化数据。精确定义所需字段 — 由 AI 处理解析。

参数类型必填默认值描述
urlstring必填—要提取数据的页面 URL。请务必传入——缺少时任务会失败。
extract_querystring必填—用自然语言描述要提取的内容,例如 "书名、价格和库存情况"。
schemaarray<object>必填—要提取的字段:[{name, type, active}]。只使用 active: true 的字段;type 是给 LLM 的提示(例如 String、Number、Boolean、Array)。
extraction_scopestring可选null传给 LLM 的可选提示,例如 "single_page" 或 "list_page"。它不会让 Extract 读取其他页面。
extraction_targetstring可选null传给 LLM 的可选提示,例如分类名称 "poetry"。
callback_urlstring可选null任务完成时接收结果(POST)的 webhook URL。
allowed_words、blocked_words、allowed_patterns 和 blocked_patterns(Create Schema 会返回这些字段)可以传入,但不会生效:Extract 只读取 url 指定的页面。只有页面 Markdown 的前 50,000 个字符会发送给 LLM。

请求

{
  "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
  "extract_query": "Book title, price and availability",
  "schema": [
    { "name": "title", "type": "String", "active": true },
    { "name": "price", "type": "String", "active": true },
    { "name": "in_stock", "type": "Boolean", "active": true }
  ],
  "extraction_scope": "single_page"
}

响应

// POST returns { "success": true, "id": "abc123", "url": "/api/extract/abc123" }
// Poll GET /api/extract/{id}
{
  "success": true,
  "id": "abc123",
  "status": "completed",
  "data": {
    "success": true,
    "data": [
      {
        "title": "A Light in the Attic",
        "price": "£51.77",
        "in_stock": true,
        "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
      }
    ],
    "total": 1,
    "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
    "processing_time_ms": 6120
  }
}