POST
/extract
AI 智慧結構化擷取

使用 AI 從網頁擷取結構化資料。用 JSON Schema 定義所需的輸出結構,我們的 AI 將智慧擷取資訊。

使用場景:

  • 從電商頁面擷取產品資訊
  • 將招聘資訊解析為結構化格式
  • 擷取聯絡資訊和企業詳情
  • 將新聞文章轉換為結構化資料
  • 抓取價格表和規格參數

工作原理:

  1. 提供 URL 和定義所需結構的 JSON Schema
  2. 我們的 AI 分析頁面內容
  3. 擷取符合 Schema 的資料
  4. 返回經過驗證的 JSON 輸出

Schema 定義:

使用 JSON Schema 定義所需的輸出結構:

  • 欄位類型:string、number、boolean、array、object
  • 欄位描述:幫助 AI 理解要擷取的內容
  • 必填欄位:將關鍵欄位標記為必填
  • 巢狀結構:支援複雜的巢狀資料

Schema 範例:

{
  "type": "object",
  "properties": {
    "title": {
      "type": "string",
      "description": "產品名稱或標題"
    },
    "price": {
      "type": "number",
      "description": "當前價格(美元)"
    },
    "availability": {
      "type": "boolean",
      "description": "產品是否有庫存"
    },
    "features": {
      "type": "array",
      "items": {"type": "string"},
      "description": "主要產品特性列表"
    }
  },
  "required": ["title", "price"]
}

授權

YOUR_API_KEY
授權Bearer <token>

在 Thunderbit Dashboard 取得 API key。標頭格式:Authorization: Bearer YOUR_API_KEY

位置: header

請求體

application/json

TypeScript Definitions

Use the request body type in TypeScript.

url*string必填

要擷取資料的網頁 URL

範例:https://thunderbit.com/playground
schemaobject

JSON Schema。選用——省略時,Thunderbit 會根據頁面內容自動產生 Schema。

範例:
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "Product name"
    },
    "price": {
      "type": "number",
      "description": "Product price"
    },
    "currency": {
      "type": "string",
      "description": "Currency unit"
    }
  },
  "required": [
    "name",
    "price"
  ]
}
timeoutnumber預設值:60000

請求逾時時間(毫秒),預設 30000

取值範圍:5000 <= x <= 120000
範例:
60000
waitFornumber預設值:0

頁面載入後等待動態內容渲染的時間(毫秒,預設 0,最大 10000)

取值範圍:0 <= x <= 10000
範例:
2000
renderModestring預設值:"none"

JavaScript 渲染模式。none = 不渲染 JS(預設);basic = 標準渲染;full = 延長等待以處理動態內容

取值範圍"none" | "basic" | "full"
formatsany[]

輸出格式(與 Distill 的 formats 陣列結構相同)。

範例:
[
  "markdown",
  "links",
  "images"
]

回應

application/json

Success response

successboolean
範例:
true
dataobject
展開子屬性
urlstring
範例:https://thunderbit.com/playground
dataobject[]

Extracted structured data matching your schema, returned as an array where each item is a key-value map

範例:
[
  {
    "name": "iPhone 15 Pro",
    "price": 999,
    "currency": "USD",
    "availability": true,
    "rating": 4.7,
    "features": [
      "A17 Pro chip with 6-core GPU",
      "Pro camera system with 48MP main camera",
      "Titanium design with textured matte glass"
    ]
  }
]
linksobject[]

從頁面擷取的連結。

展開子屬性
textstring

Visible link text.

範例:Read more
hrefstring

Resolved absolute URL.

範例:https://example.com/article
imagesobject[]

從頁面擷取的圖片。

展開子屬性
srcstring

Image source URL.

範例:https://example.com/hero.png
altstring

Image alt text.

範例:Hero banner
widthinteger

Image width in pixels.

heightinteger

Image height in pixels.

summarystring

頁面摘要(LLM 格式)。

answerstring

question 格式中提供的問題的回答。

highlightsstring[]

重點段落。

metadataobject
展開子屬性
titlestring

Page title extracted from tag or Open Graph

範例:iPhone 15 Pro - Apple
descriptionstring

Meta description or excerpt

範例:The ultimate iPhone with A17 Pro chip.
languagestring

Detected language code (ISO 639-1)

範例:en
authorstring

Article author if available

範例:
null
publishedDatestring

Publication date if available

範例:
null
imagestring

Featured image URL from Open Graph or Twitter Card

範例:https://example.com/product/iphone-15-pro.jpg
sourceURLstring

來源 URL

範例:https://example.com/product/iphone-15-pro
statusCodeinteger

HTTP 狀態碼

範例:
200
contentLengthinteger

Length of the markdown content in characters

範例:
5000