Context.dev Web Scraping API
The Web Scraping API from Context.dev — 7 operation(s) for web scraping.
The Web Scraping API from Context.dev — 7 operation(s) for web scraping.
openapi: 3.1.0
info:
title: Context Brand Intelligence Web Scraping API
description: API for retrieving context data from any website
version: 1.0.0
servers:
- url: https://api.context.dev/v1
tags:
- name: Web Scraping
paths:
/web/scrape/html:
get:
summary: Scrape HTML
description: Scrapes the given URL and returns the raw HTML content of the page.
security:
- bearerAuth: []
tags:
- Web Scraping
x-mint:
content: <Badge color="blue">1 Credit</Badge>
title: Scrape HTML
sidebarTitle: Scrape HTML
description: Scrape the raw HTML from a URL
parameters:
- schema:
type: string
minLength: 1
format: uri
description: Full URL to scrape (must include http:// or https:// protocol)
required: true
description: Full URL to scrape (must include http:// or https:// protocol)
name: url
in: query
- schema:
type: object
properties:
shouldParse:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: true
description: When true, PDF URLs are fetched and parsed. When false, PDF URLs are skipped and a 400 WEBSITE_ACCESS_ERROR is returned.
start:
type: integer
minimum: 1
description: First 1-based PDF page to parse. When omitted, parsing starts at the first page.
end:
type: integer
minimum: 1
description: Last 1-based PDF page to parse. When omitted, parsing ends at the last page. Must be greater than or equal to start when both are provided.
ocr:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: When true, detect and OCR images embedded in the selected PDF pages, inserting recognized text at each image's position in page reading order while preserving the PDF text layer. This is separate from automatic scanned-PDF OCR fallback.
default:
shouldParse: true
ocr: false
description: PDF parsing controls. Use start/end to limit text extraction and embedded-image detection/OCR to an inclusive 1-based page range.
required: false
description: PDF parsing controls. Use start/end to limit text extraction and embedded-image detection/OCR to an inclusive 1-based page range.
name: pdf
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: When true, iframes are rendered inline into the returned HTML.
required: false
description: When true, iframes are rendered inline into the returned HTML.
name: includeFrames
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: When true, return only the page's main content in the HTML response, excluding headers, footers, sidebars, and navigation when detectable.
required: false
description: When true, return only the page's main content in the HTML response, excluding headers, footers, sidebars, and navigation when detectable.
name: useMainContentOnly
in: query
- schema:
type:
- array
- 'null'
items:
type: string
minLength: 1
maxLength: 2048
maxItems: 50
description: 'CSS selectors. When provided, only matching subtrees (and their descendants) are kept and everything else is dropped. When omitted, the entire document is kept. Examples: "article.main", "#content", "[role=main]".'
required: false
description: 'CSS selectors. When provided, only matching subtrees (and their descendants) are kept and everything else is dropped. When omitted, the entire document is kept. Examples: "article.main", "#content", "[role=main]".'
name: includeSelectors
in: query
- schema:
type:
- array
- 'null'
items:
type: string
minLength: 1
maxLength: 2048
maxItems: 50
description: 'CSS selectors to remove from the result. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]".'
required: false
description: 'CSS selectors to remove from the result. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]".'
name: excludeSelectors
in: query
- schema:
type:
- integer
- 'null'
minimum: 0
maximum: 2592000000
default: 86400000
description: Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
required: false
description: Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
name: maxAgeMs
in: query
- schema:
type:
- integer
- 'null'
minimum: 0
maximum: 30000
description: 'Optional browser wait time in milliseconds after initial page load. Min: 0. Max: 30000 (30 seconds).'
required: false
description: 'Optional browser wait time in milliseconds after initial page load. Min: 0. Max: 30000 (30 seconds).'
name: waitForMs
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: When true, waits briefly for CSS and transition animations to settle before extracting HTML. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages.
required: false
description: When true, waits briefly for CSS and transition animations to settle before extracting HTML. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages.
name: settleAnimations
in: query
- schema:
type: object
additionalProperties:
type: string
maxLength: 8192
pattern: ^[^\r\n]*$
description: 'Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.'
required: false
description: 'Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.'
name: headers
in: query
- schema:
$ref: '#/components/schemas/BrowserCountryCode'
required: false
description: Two-letter ISO 3166-1 alpha-2 country code identifying a supported Context.dev residential proxy exit location. Must be one of Context.dev's supported countries. When provided, Context.dev fetches the target page from that country.
name: country
in: query
- schema:
$ref: '#/components/schemas/LenientTimeoutMS'
required: false
description: Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).
name: timeoutMS
in: query
- $ref: '#/components/parameters/RequestTags'
responses:
'200':
description: Successful response
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
enum:
- true
description: Indicates success
html:
type: string
description: The scraped content of the page. For normal pages this is the raw HTML. When the page is a sitemap or feed served behind an XSL stylesheet (which browsers render into HTML), this is the underlying XML instead — see the `type` field.
url:
type: string
description: The URL that was scraped
type:
type: string
enum:
- html
- xml
- json
- text
- csv
- markdown
- svg
- pdf
- docx
- doc
- xlsx
- xls
- pptx
- ppt
description: Detected content type of the returned `html` field. Sitemaps and feeds are surfaced as `xml`; ordinary pages are `html`. Excel workbooks are surfaced as `xlsx`/`xls` with the extracted sheets as HTML tables; PowerPoint presentations are surfaced as `pptx`/`ppt` with the extracted slides as HTML.
metadata:
$ref: '#/components/schemas/PageMetadata'
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
required:
- success
- html
- url
- type
- metadata
'400':
description: Bad request - Invalid URL or failed to scrape
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error message describing the issue
error_code:
type: string
enum:
- INPUT_VALIDATION_ERROR
- WEBSITE_ACCESS_ERROR
description: Error code indicating the type of error
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
required:
- message
- error_code
'401':
description: Unauthorized - Invalid or missing API key
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error message
error_code:
type: string
enum:
- UNAUTHORIZED
description: Error code indicating unauthorized access
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
'403':
description: Forbidden - Insufficient permissions or usage limit exceeded
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error message
error_code:
type: string
enum:
- FORBIDDEN
- USAGE_EXCEEDED
- DISABLED
- INSUFFICIENT_PERMISSIONS
description: Error code indicating forbidden access
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
'404':
description: Target page returned a 404
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error message describing the issue
error_code:
type: string
enum:
- NOT_FOUND
description: Error code indicating the target page was not found
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
required:
- message
- error_code
'408':
description: Request timeout
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Timeout error message
error_code:
type: string
enum:
- REQUEST_TIMEOUT
description: Error code indicating request timeout
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
'415':
description: Unsupported content type - the URL resolved to a content type that is not supported (e.g. an image, presentation, media, or archive). Supported types are HTML, XML, PDF, DOCX, DOC, XLSX, XLS, PPTX, PPT, and CSV.
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error message describing the unsupported content type
error_code:
type: string
enum:
- UNSUPPORTED_CONTENT
description: Error code indicating an unsupported content type
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
required:
- message
- error_code
'429':
$ref: '#/components/responses/RateLimited'
'500':
description: Internal server error
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error message
error_code:
type: string
enum:
- INTERNAL_ERROR
description: Error code indicating internal server error
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
x-codeSamples:
- lang: JavaScript
source: "import ContextDev from 'context.dev';\n\nconst client = new ContextDev({\n apiKey: process.env['CONTEXT_DEV_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.web.webScrapeHTML({ url: 'https://example.com' });\n\nconsole.log(response.html);"
- lang: Python
source: "import os\nfrom context.dev import ContextDev\n\nclient = ContextDev(\n api_key=os.environ.get(\"CONTEXT_DEV_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.web.web_scrape_html(\n url=\"https://example.com\",\n)\nprint(response.html)"
- lang: Go
source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/context-dot-dev/context-go-sdk\"\n\t\"github.com/context-dot-dev/context-go-sdk/option\"\n)\n\nfunc main() {\n\tclient := contextdev.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.Web.WebScrapeHTML(context.TODO(), contextdev.WebWebScrapeHTMLParams{\n\t\tURL: \"https://example.com\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.HTML)\n}\n"
- lang: Ruby
source: 'require "context_dev"
context_dev = ContextDev::Client.new(api_key: "My API Key")
response = context_dev.web.web_scrape_html(url: "https://example.com")
puts(response)'
- lang: PHP
source: "<?php\n\nrequire_once dirname(__DIR__) . '/vendor/autoload.php';\n\nuse ContextDev\\Client;\nuse ContextDev\\Core\\Exceptions\\APIException;\n\n$client = new Client(apiKey: getenv('CONTEXT_DEV_API_KEY') ?: 'My API Key');\n\ntry {\n $response = $client->web->webScrapeHTML(\n url: 'https://example.com',\n country: 'de',\n excludeSelectors: ['x'],\n headers: ['foo' => 'J!'],\n includeFrames: 'true',\n includeSelectors: ['x'],\n maxAgeMs: 0,\n pdf: ['end' => 1, 'ocr' => 'true', 'shouldParse' => 'true', 'start' => 1],\n settleAnimations: 'true',\n tags: ['production', 'team-alpha'],\n timeoutMs: 1,\n useMainContentOnly: 'true',\n waitForMs: 0,\n );\n\n var_dump($response);\n} catch (APIException $e) {\n echo $e->getMessage();\n}"
- lang: CLI
source: "context-dev web web-scrape-html \\\n --api-key 'My API Key' \\\n --url https://example.com"
/web/scrape/markdown:
get:
summary: Scrape Markdown
description: 'Scrapes the given URL into LLM usable Markdown. Inspect key_metadata on JSON responses from a recognized API key; use error_code to distinguish stable failure categories.
### Billing & errors
| HTTP status | Billed? | Meaning |
| --- | --- | --- |
| 200 | Yes — 1 credit | Successful scrape, including a zero-length result when includeSelectors matched nothing |
| 400 | No | Invalid input, skipped PDF, or the page could not be scraped |
| 401 / 403 | No | Invalid/disabled key, insufficient permissions, or credits exhausted; inspect error_code |
| 404 | No | Target page returned or fingerprinted as not found |
| 408 | No | Request timed out |
| 415 | No | Unsupported content type |
| 429 | No | Per-minute rate limit exceeded; honor Retry-After |
| 500 | No | Internal error |'
security:
- bearerAuth: []
tags:
- Web Scraping
x-mint:
content: <Badge color="blue">1 Credit</Badge>
title: Scrape Markdown
sidebarTitle: Scrape markdown
description: Scrape the given URL into LLM usable Markdown
parameters:
- schema:
type: string
minLength: 1
format: uri
description: Full URL to scrape into LLM usable Markdown (must include http:// or https:// protocol)
required: true
description: Full URL to scrape into LLM usable Markdown (must include http:// or https:// protocol)
name: url
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: true
description: Preserve hyperlinks in Markdown output
required: false
description: Preserve hyperlinks in Markdown output
name: includeLinks
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: Include image references in Markdown output
required: false
description: Include image references in Markdown output
name: includeImages
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: true
description: Shorten base64-encoded image data in the Markdown output
required: false
description: Shorten base64-encoded image data in the Markdown output
name: shortenBase64Images
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: Extract only the main content of the page, excluding headers, footers, sidebars, and navigation
required: false
description: Extract only the main content of the page, excluding headers, footers, sidebars, and navigation
name: useMainContentOnly
in: query
- schema:
type: object
properties:
shouldParse:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: true
description: When true, PDF URLs are fetched and parsed. When false, PDF URLs are skipped and a 400 WEBSITE_ACCESS_ERROR is returned.
start:
type: integer
minimum: 1
description: First 1-based PDF page to parse. When omitted, parsing starts at the first page.
end:
type: integer
minimum: 1
description: Last 1-based PDF page to parse. When omitted, parsing ends at the last page. Must be greater than or equal to start when both are provided.
ocr:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: When true, detect and OCR images embedded in the selected PDF pages, inserting recognized text at each image's position in page reading order while preserving the PDF text layer. This is separate from automatic scanned-PDF OCR fallback.
default:
shouldParse: true
ocr: false
description: PDF parsing controls. Use start/end to limit text extraction and embedded-image detection/OCR to an inclusive 1-based page range.
required: false
description: PDF parsing controls. Use start/end to limit text extraction and embedded-image detection/OCR to an inclusive 1-based page range.
name: pdf
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: When true, the contents of iframes are rendered to Markdown.
required: false
description: When true, the contents of iframes are rendered to Markdown.
name: includeFrames
in: query
- schema:
type:
- array
- 'null'
items:
type: string
minLength: 1
maxLength: 2048
maxItems: 50
description: 'CSS selectors. When provided, only matching HTML subtrees (and their descendants) are kept before conversion to Markdown. When omitted, the entire document is kept. Examples: "article.main", "#content", "[role=main]".'
required: false
description: 'CSS selectors. When provided, only matching HTML subtrees (and their descendants) are kept before conversion to Markdown. When omitted, the entire document is kept. Examples: "article.main", "#content", "[role=main]".'
name: includeSelectors
in: query
- schema:
type:
- array
- 'null'
items:
type: string
minLength: 1
maxLength: 2048
maxItems: 50
description: 'CSS selectors to remove before conversion to Markdown. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]".'
required: false
description: 'CSS selectors to remove before conversion to Markdown. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]".'
name: excludeSelectors
in: query
- schema:
type:
- integer
- 'null'
minimum: 0
maximum: 2592000000
default: 86400000
description: Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
required: false
description: Return a cached result if a prior scrape for the same parameters exists and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
name: maxAgeMs
in: query
- schema:
type:
- integer
- 'null'
minimum: 0
maximum: 30000
description: 'Optional browser wait time in milliseconds after initial page load before converting the page to Markdown. Min: 0. Max: 30000 (30 seconds).'
required: false
description: 'Optional browser wait time in milliseconds after initial page load before converting the page to Markdown. Min: 0. Max: 30000 (30 seconds).'
name: waitForMs
in: query
- schema:
anyOf:
- type: boolean
- type: string
enum:
- 'true'
- 'false'
default: false
description: When true, waits briefly for CSS and transition animations to settle before converting to Markdown. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages.
required: false
description: When true, waits briefly for CSS and transition animations to settle before converting to Markdown. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages.
name: settleAnimations
in: query
- schema:
type: object
additionalProperties:
type: string
maxLength: 8192
pattern: ^[^\r\n]*$
description: 'Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.'
required: false
description: 'Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache.'
name: headers
in: query
- schema:
$ref: '#/components/schemas/BrowserCountryCode'
required: false
description: Two-letter ISO 3166-1 alpha-2 country code identifying a supported Context.dev residential proxy exit location. Must be one of Context.dev's supported countries. When provided, Context.dev fetches the target page from that country.
name: country
in: query
- schema:
$ref: '#/components/schemas/LenientTimeoutMS'
required: false
description: Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).
name: timeoutMS
in: query
- $ref: '#/components/parameters/RequestTags'
responses:
'200':
description: Successful response
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
enum:
- true
description: Indicates success
markdown:
type: string
description: Page content converted to GitHub Flavored Markdown
contentLength:
type: integer
minimum: 0
description: UTF-8 byte length of the returned Markdown. Use 0 to identify an empty result and compare small values against your workload's minimum useful-content threshold.
url:
type: string
description: The URL that was scraped
metadata:
$ref: '#/components/schemas/PageMetadata'
key_metadata:
$ref: '#/components/schemas/KeyMetadata'
required:
- success
- markdown
- contentLength
- url
- metadata
'400':
description: Bad request - Invalid URL or failed to scrape
headers:
X-RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error message describing the issue
error_code:
type: string
enum:
- INPUT_VALIDATION_ERROR
- WEBSITE_ACCESS_ERROR
description: Error code indicating the type of error
key_me
# --- truncated at 32 KB (138 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/contextdev/refs/heads/main/openapi/contextdev-web-scraping-api-openapi.yml