SDKs
Bash / cURL
One-liners shell et pipelines jq pour le travail ad-hoc
Pratique pour les vérifications rapides, les scripts CI ou pour piper du markdown directement dans un autre outil. Associe curl à jq pour découper la réponse.
Configuration
export THUNDERBIT_API_KEY="..."
export API="https://openapi.thunderbit.com/openapi/v1"Distill une page
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'Pipe directement vers un fichier ou un autre outil :
curl -sX POST "$API/distill" \
-H "Authorization: Bearer $THUNDERBIT_API_KEY" \
-d '{"url": "'"$1"'"}' \
| jq -r '.data.markdown' > out.mdExtract de données structurées
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 + polling
Pour des runs batch ad-hoc depuis un shell :
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
doneEn production, préfère les webhooks au polling — voir Webhooks.
Batch piloté par liste d'URLs
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": [{}]}'