import ContextDev from 'context.dev';
const client = new ContextDev({
apiKey: process.env['CONTEXT_DEV_API_KEY'], // This is the default and can be omitted
});
const response = await client.batch.submit({
input: {
data: {
urls: [
{
url: 'https://example.com/products/anvil',
itemId: 'sku-1',
meta: { category: 'tools' },
},
{ url: 'https://example.com/products/hammer', itemId: 'sku-2' },
],
options: { useMainContentOnly: true },
},
},
});
console.log(response.id);import os
from context.dev import ContextDev
client = ContextDev(
api_key=os.environ.get("CONTEXT_DEV_API_KEY"), # This is the default and can be omitted
)
response = client.batch.submit(
input={
"data": {
"urls": [{
"url": "https://example.com/products/anvil",
"item_id": "sku-1",
"meta": {
"category": "tools"
},
}, {
"url": "https://example.com/products/hammer",
"item_id": "sku-2",
}],
"options": {
"use_main_content_only": True
},
}
},
)
print(response.id)package main
import (
"context"
"fmt"
"github.com/context-dot-dev/context-go-sdk"
"github.com/context-dot-dev/context-go-sdk/option"
)
func main() {
client := contextdev.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Batch.Submit(context.TODO(), contextdev.BatchSubmitParams{
Input: contextdev.BatchSubmitParamsInputUnion{
OfScrape: &contextdev.BatchSubmitParamsInputScrape{
Data: contextdev.BatchSubmitParamsInputScrapeDataUnion{
OfMarkdown: &contextdev.BatchSubmitParamsInputScrapeDataMarkdown{
URLs: []contextdev.BatchSubmitParamsInputScrapeDataMarkdownURL{{
URL: "https://example.com/products/anvil",
ItemID: contextdev.String("sku-1"),
Meta: map[string]any{
"category": "tools",
},
}, {
URL: "https://example.com/products/hammer",
ItemID: contextdev.String("sku-2"),
}},
Options: contextdev.BatchSubmitParamsInputScrapeDataMarkdownOptions{
UseMainContentOnly: contextdev.Bool(true),
},
},
},
},
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.ID)
}
require "context_dev"
context_dev = ContextDev::Client.new(api_key: "My API Key")
response = context_dev.batch.submit(
input: {
data: {
format: :markdown,
urls: [{url: "https://example.com/products/anvil"}, {url: "https://example.com/products/hammer"}]
},
mode: :scrape
}
)
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use ContextDev\Client;
use ContextDev\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('CONTEXT_DEV_API_KEY') ?: 'My API Key');
try {
$response = $client->batch->submit(
input: [
'data' => [
'format' => 'markdown',
'urls' => [
[
'url' => 'https://example.com/products/anvil',
'itemID' => 'sku-1',
'meta' => ['category' => 'bar'],
],
[
'url' => 'https://example.com/products/hammer',
'itemID' => 'sku-2',
'meta' => ['foo' => 'bar'],
],
],
'options' => [
'country' => 'de',
'excludeSelectors' => ['x'],
'includeImages' => true,
'includeLinks' => true,
'includeSelectors' => ['x'],
'maxAgeMs' => 0,
'pdf' => [
'end' => 1, 'ocr' => 'true', 'shouldParse' => 'true', 'start' => 1
],
'settleAnimations' => true,
'shortenBase64Images' => true,
'useMainContentOnly' => true,
'waitForMs' => 0,
],
],
'mode' => 'scrape',
],
tags: ['docs', 'competitor'],
webhookURL: 'webhookUrl',
idempotencyKey: 'Idempotency-Key',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}context-dev batch submit \
--api-key 'My API Key' \
--input '{data: {format: markdown, urls: [{url: https://example.com/products/anvil}, {url: https://example.com/products/hammer}]}, mode: scrape}'curl --request POST \
--url https://api.context.dev/v1/batch/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": {
"type": "scrape",
"data": {
"type": "markdown",
"urls": [
{
"url": "https://example.com/products/anvil",
"itemId": "sku-1",
"meta": {
"category": "tools"
}
},
{
"url": "https://example.com/products/hammer",
"itemId": "sku-2"
}
],
"options": {
"useMainContentOnly": true
}
}
}
}
'HttpResponse<String> response = Unirest.post("https://api.context.dev/v1/batch/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input\": {\n \"type\": \"scrape\",\n \"data\": {\n \"type\": \"markdown\",\n \"urls\": [\n {\n \"url\": \"https://example.com/products/anvil\",\n \"itemId\": \"sku-1\",\n \"meta\": {\n \"category\": \"tools\"\n }\n },\n {\n \"url\": \"https://example.com/products/hammer\",\n \"itemId\": \"sku-2\"\n }\n ],\n \"options\": {\n \"useMainContentOnly\": true\n }\n }\n }\n}")
.asString();{
"id": "batch_9f2c8a",
"status": "queued",
"tags": [
"docs"
],
"crawl": {
"source": {
"type": "start_url",
"url": "https://example.com/docs"
},
"max_pages": 500,
"max_depth": 0,
"follow_subdomains": true,
"url_pattern": "^https://example\\.com/docs/"
},
"input": {
"reserved": 24817,
"reserved_is_ceiling": false,
"submitted": 25000,
"duplicates": 183,
"invalid": 0
},
"credits": {
"reserved": 24817
},
"created_at": "<string>",
"invalid_urls": [
{
"url": "<string>",
"reason": "Must be a public http:// or https:// URL"
}
],
"webhook_secret": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}Submit a Batch
Scrape 25K URLs or crawl large websites asynchronously.
import ContextDev from 'context.dev';
const client = new ContextDev({
apiKey: process.env['CONTEXT_DEV_API_KEY'], // This is the default and can be omitted
});
const response = await client.batch.submit({
input: {
data: {
urls: [
{
url: 'https://example.com/products/anvil',
itemId: 'sku-1',
meta: { category: 'tools' },
},
{ url: 'https://example.com/products/hammer', itemId: 'sku-2' },
],
options: { useMainContentOnly: true },
},
},
});
console.log(response.id);import os
from context.dev import ContextDev
client = ContextDev(
api_key=os.environ.get("CONTEXT_DEV_API_KEY"), # This is the default and can be omitted
)
response = client.batch.submit(
input={
"data": {
"urls": [{
"url": "https://example.com/products/anvil",
"item_id": "sku-1",
"meta": {
"category": "tools"
},
}, {
"url": "https://example.com/products/hammer",
"item_id": "sku-2",
}],
"options": {
"use_main_content_only": True
},
}
},
)
print(response.id)package main
import (
"context"
"fmt"
"github.com/context-dot-dev/context-go-sdk"
"github.com/context-dot-dev/context-go-sdk/option"
)
func main() {
client := contextdev.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Batch.Submit(context.TODO(), contextdev.BatchSubmitParams{
Input: contextdev.BatchSubmitParamsInputUnion{
OfScrape: &contextdev.BatchSubmitParamsInputScrape{
Data: contextdev.BatchSubmitParamsInputScrapeDataUnion{
OfMarkdown: &contextdev.BatchSubmitParamsInputScrapeDataMarkdown{
URLs: []contextdev.BatchSubmitParamsInputScrapeDataMarkdownURL{{
URL: "https://example.com/products/anvil",
ItemID: contextdev.String("sku-1"),
Meta: map[string]any{
"category": "tools",
},
}, {
URL: "https://example.com/products/hammer",
ItemID: contextdev.String("sku-2"),
}},
Options: contextdev.BatchSubmitParamsInputScrapeDataMarkdownOptions{
UseMainContentOnly: contextdev.Bool(true),
},
},
},
},
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.ID)
}
require "context_dev"
context_dev = ContextDev::Client.new(api_key: "My API Key")
response = context_dev.batch.submit(
input: {
data: {
format: :markdown,
urls: [{url: "https://example.com/products/anvil"}, {url: "https://example.com/products/hammer"}]
},
mode: :scrape
}
)
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use ContextDev\Client;
use ContextDev\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('CONTEXT_DEV_API_KEY') ?: 'My API Key');
try {
$response = $client->batch->submit(
input: [
'data' => [
'format' => 'markdown',
'urls' => [
[
'url' => 'https://example.com/products/anvil',
'itemID' => 'sku-1',
'meta' => ['category' => 'bar'],
],
[
'url' => 'https://example.com/products/hammer',
'itemID' => 'sku-2',
'meta' => ['foo' => 'bar'],
],
],
'options' => [
'country' => 'de',
'excludeSelectors' => ['x'],
'includeImages' => true,
'includeLinks' => true,
'includeSelectors' => ['x'],
'maxAgeMs' => 0,
'pdf' => [
'end' => 1, 'ocr' => 'true', 'shouldParse' => 'true', 'start' => 1
],
'settleAnimations' => true,
'shortenBase64Images' => true,
'useMainContentOnly' => true,
'waitForMs' => 0,
],
],
'mode' => 'scrape',
],
tags: ['docs', 'competitor'],
webhookURL: 'webhookUrl',
idempotencyKey: 'Idempotency-Key',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}context-dev batch submit \
--api-key 'My API Key' \
--input '{data: {format: markdown, urls: [{url: https://example.com/products/anvil}, {url: https://example.com/products/hammer}]}, mode: scrape}'curl --request POST \
--url https://api.context.dev/v1/batch/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": {
"type": "scrape",
"data": {
"type": "markdown",
"urls": [
{
"url": "https://example.com/products/anvil",
"itemId": "sku-1",
"meta": {
"category": "tools"
}
},
{
"url": "https://example.com/products/hammer",
"itemId": "sku-2"
}
],
"options": {
"useMainContentOnly": true
}
}
}
}
'HttpResponse<String> response = Unirest.post("https://api.context.dev/v1/batch/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input\": {\n \"type\": \"scrape\",\n \"data\": {\n \"type\": \"markdown\",\n \"urls\": [\n {\n \"url\": \"https://example.com/products/anvil\",\n \"itemId\": \"sku-1\",\n \"meta\": {\n \"category\": \"tools\"\n }\n },\n {\n \"url\": \"https://example.com/products/hammer\",\n \"itemId\": \"sku-2\"\n }\n ],\n \"options\": {\n \"useMainContentOnly\": true\n }\n }\n }\n}")
.asString();{
"id": "batch_9f2c8a",
"status": "queued",
"tags": [
"docs"
],
"crawl": {
"source": {
"type": "start_url",
"url": "https://example.com/docs"
},
"max_pages": 500,
"max_depth": 0,
"follow_subdomains": true,
"url_pattern": "^https://example\\.com/docs/"
},
"input": {
"reserved": 24817,
"reserved_is_ceiling": false,
"submitted": 25000,
"duplicates": 183,
"invalid": 0
},
"credits": {
"reserved": 24817
},
"created_at": "<string>",
"invalid_urls": [
{
"url": "<string>",
"reason": "Must be a public http:// or https:// URL"
}
],
"webhook_secret": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}Authorizations
Bearer authentication header of the form Bearer <API_KEY>, where <API_KEY> is your api key.
Headers
Any string unique to this submission. Retries with the same key return the original batch.
200Body
Create an asynchronous scraping job.
Scrape up to 25K URLs in one batch.
- Scrape
- Crawl
Show child attributes
Show child attributes
URL notified when the batch finishes.
Tags stored on the batch. Filter the batch list by them later.
201 - 50["docs", "competitor"]
Response
Batch accepted. Read progress and results from GET /batch/{batch_id}.
Batch ID. Poll GET /batch/{batch_id} with it.
"batch_9f2c8a"
Always queued. An accepted batch has not started yet.
queued How pages will be selected.
scrape, crawl What each page will be returned as.
markdown, html Tags stored on the batch.
["docs"]
How the crawl was configured. Null for scrape batches.
Show child attributes
Show child attributes
What submission took in, and what it charged for.
Show child attributes
Show child attributes
What accepting this batch cost.
Show child attributes
Show child attributes
When the batch was created.
Rejected URLs, up to 100. These are not charged.
Show child attributes
Show child attributes
Signing secret for the completion webhook, returned only here and never again. Store it now; it is not repeated by GET /batch/{batch_id}.
API key usage for this request.
Show child attributes
Show child attributes
Was this page helpful?