Custom Headers

BrowserAPI allows you to add your own headers to a request and get customised results.

Custom HTTP headers are useful when you want to provide additional information to your request. If your request requires passing custom HTTP headers, all you have to do is to append WSA- to your header's name and add them to your request.

For example, the Sec-Fetch-Dest: document header will be passed as WSA-Sec-Fetch-Dest: document.

Only use this feature to get customized results, do not use this feature to avoid blocks. BrowserAPI has a powerful internal engine that takes care of everything for you.

Custom Headers Integration Examples

curl --request GET --url "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=http%3A%2F%2Fhttpbin.org%2Fheaders" --header "WSA-My-header: test" --header "WSA-User-Agent: potato"

Important! The url parameter has to be encoded. ( i.e. &url=https%3A%2F%2Fwww.webscrapingapi.com%2F )

Response Example
{
    "headers": {
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "Accept-Encoding": "gzip, deflate, br",
        "Host": "httpbin.org",
        "My-Header": "test",
        "Upgrade-Insecure-Requests": "1",
        "User-Agent": "potato",
        "X-Amzn-Trace-Id": "Root=1-6267c064-44fa9993017cfcc32e41dfc1"
    }
}

Keeping the Original Headers

By default, when you add custom headers to your request, BrowserAPI will pass the original headers alongside the ones you specified. If you do not wish to pass the original headers to your request, you will have to disable this feature by passing the keep_headers=0 parameter.

We've kept the example above and just added the keep_headers=0 parameter to the request and here is how the response differs from the original one:

{
    "headers": {
        "Accept-Encoding": "gzip, deflate, br",
        "Host": "httpbin.org",
        "My-Header": "test",
        "User-Agent": "potato",
        "X-Amzn-Trace-Id": "Root=1-6320123d-7d995c9d1c8f6cd66937f114"
    }
}

Last updated