Retrieving results
Polling — GET /v1/tasks/{id}/result
curl -sS -H "Authorization: Bearer $API_KEY" \
https://api.asgrefinery.io/v1/tasks/tsk_xxx/result
Still labeling (202)
{
"status": "in_progress",
"message": "Task is still being labeled."
}
Ready (200)
{
"task_id": "tsk_xxx",
"status": "settled",
"consensus_label": "cat",
"confidence": 1.0,
"worker_count": 3,
"agreement_count": 3,
"bsv_txid": "abc123...",
"created_at": "2026-04-08T21:00:00Z",
"settled_at": "2026-04-08T21:00:47Z"
}
Not found (404)
{
"error": "task not found"
}
Field meanings
| Field | Meaning |
|---|---|
consensus_label | Winning label string from consensus |
confidence | Agreement signal (see Consensus) |
worker_count | Workers counted toward the result |
agreement_count | Workers matching consensus |
settlement.bsv_txid | On-chain transaction id |
settlement.total_cost_sats | Cost model in satoshis |
settlement.settled_at | RFC3339 timestamp when settled |
Python SDK
import os
from asg_gateway import ASGGatewayClient
client = ASGGatewayClient(os.environ["API_KEY"])
# One-shot fetch (may be 202 in raw HTTP — SDK raises on non-2xx except your own poll loop)
r = client.get_result("tsk_xxx")
# Blocking poll: default interval 5s, timeout 300s
final = client.poll_result("tsk_xxx", timeout=600, interval=5)
print(final["consensus_label"])
tip
The Python ASGGatewayClient.get_result uses requests and treats non-2xx as errors. For 202 handling, use poll_result or a custom loop with requests and check status_code == 202.
Recommended polling strategy
- After task creation, wait ~5s before the first
GET. - Use exponential backoff (e.g. 5s → 10s → 20s, cap 60s) if still 202.
- Stop when you receive 200 or the task reaches a terminal error state.
Why webhooks beat polling
For production, register Webhooks for task.settled — your endpoint receives a signed payload when the label and bsv_txid are ready, eliminating busy polling and reducing 429 pressure.
:::tip Settlement Timing
settled_at is the real timestamp of the BSV payment, not the time you polled the result.
Average settlement time is typically 30–60 seconds depending on consensus threshold and worker availability.
:::