SDKs

Bash / cURL

Shell one-liners en jq-pipelines voor ad-hoc werk

Handig voor snelle checks, CI-scripts of het direct doorpipen van markdown naar een ander tool. Combineer curl met jq om de response te slicen.

Configureren

export THUNDERBIT_API_KEY="..."
export API="https://openapi.thunderbit.com/openapi/v1"

Een pagina Distillen

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 direct naar een bestand of een ander tool:

curl -sX POST "$API/distill" \
  -H "Authorization: Bearer $THUNDERBIT_API_KEY" \
  -d '{"url": "'"$1"'"}' \
  | jq -r '.data.markdown' > out.md

Gestructureerde data Extracten

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 + poll

Voor ad-hoc batch runs vanuit een 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
done

Voor productie gebruik je liever Webhooks dan polling — zie Webhooks.

URL-list driven 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": [{}]}'