v1 Documentation
A powerful web scraping API that allows you to extract data from any website with JavaScript rendering support, screenshots, and advanced data extraction capabilities.
https://www.foxscrape.com/api/v1
Execute JavaScript and wait for dynamic content to load
Capture full page or element screenshots
Extract structured data using CSS selectors
Forward custom headers and cookies
FoxScrape API uses API key authentication. Include your API key in the request headers.
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.foxscrape.com/api/v1?url=https://example.com"
1,000 requests per month
100,000 requests per month
Get started with simple web scraping requests.
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.foxscrape.com/api/v1?url=https://example.com"
const response = await fetch('https://www.foxscrape.com/api/v1?url=https://example.com', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const html = await response.text();
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.foxscrape.com/api/v1?url=https://example.com&render_js=true"
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.foxscrape.com/api/v1?url=https://example.com&json_response=true"
Complete reference of all available parameters.
Parameter | Type | Required | Description |
---|---|---|---|
url | string | Required | The URL to scrape |
render_js | boolean | Optional | Enable JavaScript rendering |
json_response | boolean | Optional | Return JSON response with metadata |
Parameter | Type | Required | Description |
---|---|---|---|
device | string | Optional | Device type: desktop or mobile |
window_width | number | Optional | Browser window width in pixels |
window_height | number | Optional | Browser window height in pixels |
wait_browser | string | Optional | Wait condition: load, domcontentloaded, networkidle0, networkidle2 |
wait_for | string | Optional | CSS selector or XPath to wait for |
wait | number | Optional | Additional wait time in milliseconds |
block_resources | boolean | Optional | Block images, CSS, and fonts for faster loading |
consent_action | string | Optional | Handle cookie consent: accept, reject, or off |
Parameter | Type | Required | Description |
---|---|---|---|
return_page_source | boolean | Optional | Include HTML source in response |
return_page_text | boolean | Optional | Include plain text in response |
return_page_markdown | boolean | Optional | Include markdown in response |
Execute JavaScript scenarios to interact with dynamic web pages.
{
"instructions": [
{"wait": 2000},
{"click": "#load-more"},
{"wait_for": ".new-content"}
]
}
{
"instructions": [
{"click": "#login-button"},
{"wait_for": "#username"},
{"fill": ["#username", "myuser@example.com"]},
{"fill": ["#password", "mypassword"]},
{"click": "#submit"},
{"wait_for": ".dashboard"}
]
}
Parameter | Type | Required | Description |
---|---|---|---|
click | string | Optional | Click on an element by CSS selector |
wait | number | Optional | Wait for specified milliseconds |
wait_for | string | Optional | Wait for element to appear |
wait_for_and_click | string | Optional | Wait for element and click it |
fill | array | Optional | Fill input field: [selector, value] |
scroll_x | number | Optional | Scroll horizontally by pixels |
scroll_y | number | Optional | Scroll vertically by pixels |
infinite_scroll | object | Optional | Scroll until no new content loads |
evaluate | string | Optional | Execute custom JavaScript code |
Capture screenshots of web pages or specific elements.
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.foxscrape.com/api/v1?url=https://example.com&screenshot=true" \
--output screenshot.png
Parameter | Type | Required | Description |
---|---|---|---|
screenshot | boolean | Optional | Enable screenshot capture |
screenshot_full_page | boolean | Optional | Capture full page (not just viewport) |
screenshot_selector | string | Optional | CSS selector for element screenshot |
screenshot_type | string | Optional | Image format: png, jpeg, or webp |
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.foxscrape.com/api/v1?url=https://example.com&screenshot=true&screenshot_selector=.hero-section" \
--output element.png
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.foxscrape.com/api/v1?url=https://example.com&screenshot=true&json_response=true"
Extract structured data from web pages using CSS selectors and XPath.
{
"title": "h1",
"price": ".price"
}
curl -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","extract_rules":{"title":"h1","price":".price"}}' \
"https://www.foxscrape.com/api/v1"
{
"title": {
"selector": "h1",
"attr": "textContent"
},
"image": {
"selector": "img",
"attr": "src"
},
"price": {
"selector": ".price",
"coerce": "number"
}
}
{
"products": {
"type": "list",
"selector": ".product",
"item": {
"title": ".title",
"price": ".price",
"image": {
"selector": "img",
"attr": "src"
}
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
selector | string | Optional | CSS selector or XPath (prefix with 'xpath://') |
attr | string | Optional | Attribute to extract (default: textContent) |
kind | string | Optional | Output type: text, html, or attr |
required | boolean | Optional | Whether field is required |
default | any | Optional | Default value if extraction fails |
coerce | string | Optional | Convert to: string, number, or boolean |
normalize | boolean | Optional | Normalize whitespace |
Real-world examples of common scraping tasks.
{
"title": "h1.product-title",
"price": {
"selector": ".price",
"coerce": "number"
},
"description": ".product-description",
"images": {
"type": "list",
"selector": ".product-images img",
"item": {
"selector": "",
"attr": "src"
}
},
"availability": ".stock-status"
}
curl -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://shop.example.com/product/123",
"render_js": true,
"extract_rules": {
"title": "h1.product-title",
"price": {"selector": ".price", "coerce": "number"},
"description": ".product-description",
"images": {
"type": "list",
"selector": ".product-images img",
"item": {"selector": "", "attr": "src"}
},
"availability": ".stock-status"
}
}' \
"https://www.foxscrape.com/api/v1"
{
"instructions": [
{"wait": 3000},
{"scroll_y": 1000},
{"wait": 2000},
{"scroll_y": 1000},
{"wait": 2000}
]
}
{
"posts": {
"type": "list",
"selector": ".post",
"item": {
"author": ".author-name",
"content": ".post-content",
"timestamp": ".timestamp",
"likes": {
"selector": ".like-count",
"coerce": "number"
}
}
}
}
{
"headline": "h1.article-title",
"author": ".author-name",
"publish_date": ".publish-date",
"content": ".article-content",
"tags": {
"type": "list",
"selector": ".tags a",
"item": {"selector": "", "attr": "textContent"}
},
"featured_image": {
"selector": ".featured-image img",
"attr": "src"
}
}
Understanding and handling API errors.
Parameter | Type | Required | Description |
---|---|---|---|
200 | number | Optional | Success - Request completed successfully |
400 | number | Optional | Bad Request - Missing or invalid parameters |
401 | number | Optional | Unauthorized - Invalid or missing API key |
402 | number | Optional | Payment Required - Quota exceeded |
429 | number | Optional | Too Many Requests - Rate limit exceeded |
500 | number | Optional | Internal Server Error - Server-side error |
502 | number | Optional | Bad Gateway - Target website unreachable |
504 | number | Optional | Gateway Timeout - Request timeout |
{
"message": "Error description",
"code": "ERROR_CODE",
"details": {
"parameter": "url",
"reason": "Invalid URL format"
}
}
{
"message": "Missing url",
"code": "MISSING_PARAMETER"
}
{
"message": "Invalid URL format",
"code": "INVALID_URL"
}
{
"message": "ENOTFOUND example.com",
"code": "NETWORK_ERROR"
}
async function scrapeWithRetry(url, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
const response = await fetch(`https://www.foxscrape.com/api/v1?url=${url}`, {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
if (response.ok) {
return await response.text();
}
if (response.status === 429) {
// Rate limited - wait before retry
await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
continue;
}
if (response.status >= 500) {
// Server error - retry
continue;
}
// Client error - don't retry
throw new Error(`HTTP ${response.status}`);
} catch (error) {
if (i === maxRetries - 1) throw error;
await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
}
}
}