{
"url": "https://example.com",
"formats": {
"html": true
}
}curl https://api.context.dev/v1/web/scrape \
-H "Authorization: Bearer $CONTEXT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"formats": {
"html": true
}
}'import requests
url = "https://api.context.dev/v1/web/scrape"
payload = {
"url": "https://example.com",
"formats": { "html": True }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://example.com', formats: {html: true}})
};
fetch('https://api.context.dev/v1/web/scrape', 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/web/scrape",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://example.com',
'formats' => [
'html' => true
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.context.dev/v1/web/scrape"
payload := strings.NewReader("{\n \"url\": \"https://example.com\",\n \"formats\": {\n \"html\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.context.dev/v1/web/scrape")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com\",\n \"formats\": {\n \"html\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.context.dev/v1/web/scrape")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://example.com\",\n \"formats\": {\n \"html\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"url": "https://example.com/",
"html": {
"requested": true,
"data": "<h1>Example Domain</h1>"
},
"markdown": {
"requested": false,
"data": null
},
"screenshot": {
"requested": false,
"data": null
},
"images": {
"requested": false,
"data": null
},
"bytes": {
"requested": false,
"data": null
},
"parsed": {
"requested": false,
"data": null
}
}Scrape a URL
Fetch a page once and return any combination of Markdown, HTML, a screenshot, images, original bytes, and CSS-selected fields.
{
"url": "https://example.com",
"formats": {
"html": true
}
}curl https://api.context.dev/v1/web/scrape \
-H "Authorization: Bearer $CONTEXT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"formats": {
"html": true
}
}'import requests
url = "https://api.context.dev/v1/web/scrape"
payload = {
"url": "https://example.com",
"formats": { "html": True }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://example.com', formats: {html: true}})
};
fetch('https://api.context.dev/v1/web/scrape', 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/web/scrape",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://example.com',
'formats' => [
'html' => true
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.context.dev/v1/web/scrape"
payload := strings.NewReader("{\n \"url\": \"https://example.com\",\n \"formats\": {\n \"html\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.context.dev/v1/web/scrape")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com\",\n \"formats\": {\n \"html\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.context.dev/v1/web/scrape")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://example.com\",\n \"formats\": {\n \"html\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"url": "https://example.com/",
"html": {
"requested": true,
"data": "<h1>Example Domain</h1>"
},
"markdown": {
"requested": false,
"data": null
},
"screenshot": {
"requested": false,
"data": null
},
"images": {
"requested": false,
"data": null
},
"bytes": {
"requested": false,
"data": null
},
"parsed": {
"requested": false,
"data": null
}
}formats to choose outputs. Each requested output returns requested: true with its data; outputs you did not request return data: null. One credit covers every format in the request, including cache hits. See Scrape a webpage for content controls, freshness, and dynamic pages, or the format guides for screenshots, images, and bytes.Authorizations
Bearer authentication header of the form Bearer <API_KEY>. Keys have full access by default.
Body
The URL to scrape.
^https?://Outputs to return. Enable at least one; omitted formats are false.
Show child attributes
Show child attributes
Shared browser and content settings. Content filters leave screenshots and original bytes unchanged.
Show child attributes
Show child attributes
Markdown options. Requires formats.markdown: true.
Show child attributes
Show child attributes
Screenshot options. Requires formats.screenshot: true.
Show child attributes
Show child attributes
Image options. Requires formats.images: true.
Show child attributes
Show child attributes
Required when formats.parse is true.
Show child attributes
Show child attributes
Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and updates the requested outputs. Compatible outputs are shared with the individual scrape endpoints. Image results with hosted files refresh after 23 hours; other outputs retain their own freshness.
0 <= x <= 2592000000Zero data retention. Bypasses caches and uploads; excludes request/response content and tags from logs. Must be enabled for your organization.
enabled, disabled Total deadline, including navigation, actions, waiting, and all outputs. Defaults to 60000 milliseconds with behavior fail. Use return-partial to capture the current page state and return captured images if image processing cannot finish before the deadline; these responses set isPartial and are not cached. Every requested format must still be available. Fixed waits must fit before a response reserve of up to 5000 milliseconds (at most one quarter of the timeout) when using return-partial.
Show child attributes
Show child attributes
Labels for tracking request usage. Not retained when zdr is enabled.
201 - 50["production", "team-alpha"]
Response
All six outputs are present. Unrequested outputs have requested: false and data: null. Every requested output must succeed.
Final URL after redirects and browser actions.
^https?://Rendered HTML after content filters.
Show child attributes
Show child attributes
Markdown after content filters.
Show child attributes
Show child attributes
An image data URL. Use directly as an image src.
Show child attributes
Show child attributes
Images after content filters. Empty when none are found.
Show child attributes
Show child attributes
Original HTTP response body. Waiting, actions, and content filters never change it.
Show child attributes
Show child attributes
Fields produced by parseParams.rules, after shared content filters.
Show child attributes
Show child attributes
Page details, when available.
Show child attributes
Show child attributes
Cache outcome for this response. Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
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"
Present when return-partial captures a page that is still loading or returns images before image processing finishes. Partial responses are not cached.
Credit usage, included whenever a valid API key is provided.
Show child attributes
Show child attributes
Was this page helpful?