Skip to main content
Context.dev’s Batch API runs large scraping jobs asynchronously. Submit a fixed list of up to 25,000 URLs, or start a crawl from one page or a domain’s sitemap. Each successful page costs 1 credit; credits reserved for pages that do not succeed are released when the batch settles. Choose Markdown or HTML output when you submit the batch. You can poll for progress, receive a webhook when processing finishes, page through results as JSON, or download gzipped NDJSON result files.

Integrate Context.dev's Batch API in your app

Open in Cursor

Prerequisites

Create an API key at context.dev/signup, copy it from the dashboard, and export it:
The examples below call the HTTPS API directly with 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 in input.data.urls requires a url. Add itemId or meta when you need to join result records back to your own data.
cURL
1 credit per successfully scraped page The API reserves credits for accepted pages at submission and returns 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 under input.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 a start_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 a sitemap 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
A sitemap batch scrapes only URLs from the sitemap. It does not follow links from those pages, so sitemap controls support maxUrls and regex, but not maxDepth or followSubdomains.

Poll for completion

Save the id returned by submission, then retrieve the batch:
cURL
Poll every few seconds while the status is 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
Successful records have 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
A page can close before limit to keep its payload under approximately 8 MB. Continue based on has_more and next_cursor, not the number of records:
cURL
For large result sets, retrieve the batch and download the signed URLs in 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 reaches cancelled, and unused reserved credits are released.
cURL
After a batch reaches 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.