Passing API Parameters as Headers
Along with the "traditional" means of passing API parameters, they can be passed as part of the request headers as well. For example: api_key, render, ultra_premium and instruction_set.
Please note that the 'x-sapi-' prefix is used on each header to avoid collisions with headers used by target sites. We support all standard parameters available with the API. The instruction_set parameter is specifically supported only through headers.
API REQUEST (URL Parameters)
curl --request GET \
--url 'https://api.scraperapi.com?api_key=API_KEY&render=true&url=https://example.com/'import requests
target_url = 'https://example.com/'
# Replace the value for api_key with your actual API Key.
api_key = 'API_KEY'
request_url = (
f'https://api.scraperapi.com?'
f'api_key={api_key}'
f'&render=true'
f'&url={target_url}'
)
response = requests.get(request_url)
print(response.text)import request from 'node-fetch';
// Replace the value for api_key with your actual API Key.
const url = 'http://api.scraperapi.com/?api_key=API_KEY&render=true&url=https://example.com/';
request(url)
.then(response => {
console.log(response);
})
.catch(error => {
console.error(error);
});API REQUEST (Headers Parameters)
curl --request GET \
--url 'https://api.scraperapi.com?url=https://www.example.com' \
--header 'x-sapi-api_key: API_KEY' \
--header 'x-sapi-render: true'import requests
url = "https://api.scraperapi.com"
params = {
"url": "https://www.example.com"
}
headers = {
# Replace the value for api_key with your actual API Key.
"x-sapi-api_key": "API_KEY",
"x-sapi-render": "true"
}
response = requests.get(url, params=params, headers=headers)
print(response.text)import fetch from "node-fetch";
const url = new URL("https://api.scraperapi.com");
url.searchParams.append("url", "https://www.example.com");
const response = await fetch(url, {
method: "GET",
headers: {
"x-sapi-api_key": "API_KEY",
"x-sapi-render": "true",
},
});
const body = await response.text();
console.log(body);PROXY MODE
curl --request GET \
--url 'https://www.example.com' \
--proxy 'http://scraperapi:[email protected]:8001' \
--header 'x-sapi-render: true' \
-kimport requests
url = "https://www.example.com"
# Replace the value for api_key with your actual API Key.
proxy = "http://scraperapi:[email protected]:8001"
proxies = {
"http": proxy,
"https": proxy,
}
headers = {
"x-sapi-render": "true"
}
response = requests.get(url, headers=headers, proxies=proxies, verify=False)
print(response.text)Credentials must still be passed to the proxy API using the standard method, not as headers.
Last updated

