curl --request GET \
--url https://api.context.dev/v1/batch/{batch_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.context.dev/v1/batch/{batch_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.context.dev/v1/batch/{batch_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.context.dev/v1/batch/{batch_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.context.dev/v1/batch/{batch_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.context.dev/v1/batch/{batch_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.context.dev/v1/batch/{batch_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "batch_9f2c8a",
"status": "queued",
"mode": "scrape",
"format": "markdown",
"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
},
"progress": {
"succeeded": 18091,
"failed": 311,
"pending": 6415
},
"credits": {
"reserved": 24817,
"refunded": 6726,
"ocr_charged": 42,
"net": 18091
},
"timing": {
"created_at": "<string>",
"started_at": "<string>",
"completed_at": "<string>"
},
"page_errors": [
{
"code": "WEBSITE_ACCESS_ERROR",
"count": 204
}
],
"failure": {
"code": "stalled",
"message": "Batch stopped reporting progress and was finalized automatically"
},
"results": {
"expires_at": "<string>",
"files": [
{
"url": "<string>",
"items": 123,
"bytes": 123
}
]
},
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"invalid_urls": [
{
"url": "<string>",
"reason": "Must be a public http:// or https:// URL"
}
],
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
},
"webhook_delivery_id": "<string>"
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}Retrieve a Batch
Check progress, and get download links once the batch finishes.
curl --request GET \
--url https://api.context.dev/v1/batch/{batch_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.context.dev/v1/batch/{batch_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.context.dev/v1/batch/{batch_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.context.dev/v1/batch/{batch_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.context.dev/v1/batch/{batch_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.context.dev/v1/batch/{batch_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.context.dev/v1/batch/{batch_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "batch_9f2c8a",
"status": "queued",
"mode": "scrape",
"format": "markdown",
"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
},
"progress": {
"succeeded": 18091,
"failed": 311,
"pending": 6415
},
"credits": {
"reserved": 24817,
"refunded": 6726,
"ocr_charged": 42,
"net": 18091
},
"timing": {
"created_at": "<string>",
"started_at": "<string>",
"completed_at": "<string>"
},
"page_errors": [
{
"code": "WEBSITE_ACCESS_ERROR",
"count": 204
}
],
"failure": {
"code": "stalled",
"message": "Batch stopped reporting progress and was finalized automatically"
},
"results": {
"expires_at": "<string>",
"files": [
{
"url": "<string>",
"items": 123,
"bytes": 123
}
]
},
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"invalid_urls": [
{
"url": "<string>",
"reason": "Must be a public http:// or https:// URL"
}
],
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
},
"webhook_delivery_id": "<string>"
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"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.
Path Parameters
ID of the batch to retrieve or cancel.
"batch_9f2c8a"
Response
Current state of the batch, with download links once it has finished.
What a single-batch read adds to the batch itself.
Batch ID used to retrieve or cancel the job.
"batch_9f2c8a"
Current state. completed, cancelled, and failed are final.
queued, running, cancelling, completed, cancelled, failed How pages were selected. Matches input.mode on the submit request.
scrape, crawl What each page is returned as. Matches input.data.format on the submit request.
markdown, html Tags stored on the batch at submission.
["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
Pages attempted so far. Use status to check completion.
Show child attributes
Show child attributes
What this batch has done to your credit balance.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Individual page failures grouped by error code, sorted by count. Unrelated to failure, which is the batch itself failing.
Show child attributes
Show child attributes
Why the batch as a whole stopped. Null unless status is failed. Individual pages that failed are counted in page_errors instead.
Show child attributes
Show child attributes
Download links, available once the batch reaches a final status and null before then. GET /batch/{batch_id}/results serves the same records as paginated JSON.
Show child attributes
Show child attributes
Unique id of this API call, also sent in the X-Request-Id response header. Quote it when contacting support about a failed request.
"3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91"
Rejected URLs, up to 100. These are not charged.
Show child attributes
Show child attributes
API key usage for this request.
Show child attributes
Show child attributes
Batch completion delivery ID, when available.
Was this page helpful?