Integrate Context.dev's Batch API in your app
Prerequisites
Create an API key at context.dev/signup, copy it from the dashboard, and export it:curl.
Choose how pages enter the batch
For every mode, set
input.data.type to markdown or html. Markdown output supports link and image controls in addition to the common scraping options.
Submit a fixed URL list
Each entry ininput.data.urls requires a url. Add itemId or meta when you need to join result records back to your own data.
cURL
202. Duplicate or invalid URLs are not accepted or charged.
sample response
Retries with the same
Idempotency-Key and request body return the original batch. Reusing the key with a different body returns 409 IDEMPOTENCY_KEY_CONFLICT. Keys can contain up to 200 characters.Content options
Common options underinput.data.options include:
Markdown batches also support
includeLinks, includeImages, and shortenBase64Images. See Submit a Batch for the complete schema.
Crawl from a starting URL
Use astart_url source to follow links from one page. The starting URL is always included, even when regex does not match it. If the URL has no scheme, Context.dev reads it as HTTPS.
cURL
controls is optional. maxUrls defaults to 100, followSubdomains defaults to false, and an omitted maxDepth allows any depth until another control stops discovery.
Scrape URLs from a sitemap
Use asitemap source to scrape URLs listed by a domain. The API accepts a bare domain or a full URL and reduces it to the domain.
cURL
Poll for completion
Save theid returned by submission, then retrieve the batch:
cURL
queued, running, or cancelling. Stop when it becomes completed, cancelled, or failed.
A crawl can complete below
maxUrls when no more eligible pages are reachable. The retrieve response also repeats invalid_urls and webhook_secret, so a dropped submit response does not lose them.
Read result records as JSON
Once the batch is terminal, request a page of results:cURL
status: "ok" plus http_status, final_url, metadata, and either markdown or html. Failed records have status: "error", error_code, and message. Scrape results echo any submitted itemId and meta.
sample response
limit to keep its payload under approximately 8 MB. Continue based on has_more and next_cursor, not the number of records:
cURL
results.files instead. Each file is gzipped NDJSON. The response includes results.expires_at; retrieve the batch again to obtain fresh links after they expire.
Find previous batches
List batches newest first and combine status, search, and tag filters:cURL
q matches batch IDs, crawl sources, and tags. The tags filter matches batches containing any supplied tag. Continue with next_cursor when has_more is true.
Cancel or delete a batch
Cancellation stops new pages from starting. Pages already in progress finish before the batch reachescancelled, and unused reserved credits are released.
cURL
completed, cancelled, or failed, you can permanently delete its metadata and stored results:
cURL
Handle errors
Next steps
Submit a Batch
Full request schema, examples, and responses.
List Batch Results
Paginated success and error records.
Scrape Websites
Use synchronous scraping for one page at a time.
Best Practices
Authentication, retries, caching, and error handling.