Skip to main content

Add HTTP headers to request

You can add your custom headers to a request.

Headers are passed as JSON in headers parameter.

tip

Remember to encode this parameter like in the example below.

Example

In the example below, we add two headers:

  • Date: Mon, 12 Dec 2022 07:28:00 GMT,
  • X-Custom-Header: value.

These headers will be forwarded to the requested page.

curl -G \
--data-urlencode 'url=https://httpbin.org/headers' \
--data-urlencode 'headers={"date": "Mon, 12 Dec 2022 07:28:00 GMT", "x-custom-header": "value"}' \
'https://scraping.narf.ai/api/v1/?api_key=[your API key]'

In the response from https://httpbin.org, you will be able to validate that the desired headers were indeed included in the request:

{
"headers": {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US",
"Date": "Mon, 12 Dec 2022 07:28:00 GMT",
"Host": "httpbin.org",
"Sec-Ch-Ua": "\"Google Chrome\";v=\"107\", \"Chromium\";v=\"107\", \";Not A Brand\";v=\"99\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"Windows\"",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-63963404-57e4efe21185436d73ea000e",
"X-Custom-Header": "value"
}
}