SDKs

Bash / cURL

One-liners de shell e pipelines com jq para trabalho ad-hoc

Útil para verificações rápidas, scripts de CI ou para canalizar Markdown direto para outra ferramenta. Combine curl com jq para fatiar a resposta.

Configurar

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

Distill de uma página

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'

Canalize direto para um arquivo ou outra ferramenta:

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

Extract de dados estruturados

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

Para execuções de batch ad-hoc a partir de um 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

Para produção, prefira Webhooks em vez de polling — veja Webhooks.

Batch dirigido por lista de 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": [{}]}'