Polling Jobs

How to poll for async job results across all endpoints

Polling Jobs

Most AnakinScraper endpoints process jobs asynchronously. After submitting a request, you receive a jobId and poll a GET endpoint until the job completes.


How it works

  1. Submit a POST request — you receive a jobId with status pending
  2. Poll the corresponding GET endpoint with the jobId
  3. Check the status field — repeat until completed or failed
ProductSubmitPoll
URL ScraperPOST /v1/url-scraperGET /v1/url-scraper/{id}
URL Scraper (batch)POST /v1/url-scraper/batchGET /v1/url-scraper/{id}
Web ScraperPOST /v1/web-scraperGET /v1/web-scraper/{id}
Agentic SearchPOST /v1/agentic-searchGET /v1/agentic-search/{id}

Search API (POST /v1/search) is synchronous — results are returned immediately, no polling needed.


ProductIntervalTypical completion
URL Scraper2–5 seconds3–15 seconds
Web Scraper2–5 seconds3–10 seconds
Agentic Search10 seconds1–5 minutes

Polling examples

import requests
import time

def poll_job(endpoint, job_id, api_key, interval=5, timeout=300):
    """Poll a job until completed or failed."""
    elapsed = 0
    while elapsed < timeout:
        result = requests.get(
            f'https://api.anakin.io/v1/{endpoint}/{job_id}',
            headers={'X-API-Key': api_key}
        )
        data = result.json()

        if data['status'] == 'completed':
            return data
        if data['status'] == 'failed':
            raise Exception(data.get('error', 'Job failed'))

        time.sleep(interval)
        elapsed += interval

    raise TimeoutError('Job polling timed out')

# URL Scraper
result = poll_job('url-scraper', 'job_abc123xyz', 'your_api_key', interval=3)
print(result['markdown'])

# Agentic Search (longer interval)
result = poll_job('agentic-search', 'agentic_abc123xyz', 'your_api_key', interval=10, timeout=600)
print(result['markdown'])

Status values

StatusDescription
pendingJob is queued, not yet started
queuedJob is waiting for a worker (agentic search only)
processingJob is actively being processed
completedResults are ready — stop polling
failedJob encountered an error — stop polling