SDKs
Bash / cURL
面向临时任务的 shell 一行命令和 jq 流水线
适合快速验证、CI 脚本,或者把 markdown 直接管道到下一个工具。curl 配 jq 切响应。
配置
export THUNDERBIT_API_KEY="..."
export API="https://openapi.thunderbit.com/openapi/v1"Distill 一个页面
curl -sX POST "$API/distill" \
-H "Authorization: Bearer $THUNDERBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://thunderbit.com/playground"}' \
| jq -r '.data.markdown'直接管道到文件或下一个工具:
curl -sX POST "$API/distill" \
-H "Authorization: Bearer $THUNDERBIT_API_KEY" \
-d '{"url": "'"$1"'"}' \
| jq -r '.data.markdown' > out.mdExtract 结构化数据
curl -sX POST "$API/extract" \
-H "Authorization: Bearer $THUNDERBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/product/iphone-15-pro",
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"price": { "type": "number" }
},
"required": ["name", "price"]
}
}' \
| jq '.data'Batch + 轮询
shell 里临时跑 batch 任务:
JOB=$(curl -sX POST "$API/batch/distill" \
-H "Authorization: Bearer $THUNDERBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"urls": ["https://example.com/p1", "https://example.com/p2"]}' \
| jq -r '.data.id')
while :; do
STATUS=$(curl -s "$API/batch/distill/$JOB" \
-H "Authorization: Bearer $THUNDERBIT_API_KEY" \
| jq -r '.data.status')
echo "$STATUS"
[[ "$STATUS" == "COMPLETED" || "$STATUS" == "FAILED" ]] && break
sleep 10
done生产环境优先用 Webhook 而不是轮询 —— 详见 Webhooks。
从 URL 列表跑 Batch
xargs -a urls.txt -I {} echo '"{}"' \
| paste -sd, - \
| xargs -I {} curl -sX POST "$API/batch/distill" \
-H "Authorization: Bearer $THUNDERBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"urls": [{}]}'