Skip to main content

Custom Headers

Set custom HTTP headers to modify how the target page behaves or responds.

Basic usage

bash
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&customHeaders=%7B%22Accept-Language%22%3A%22en-US%22%7D" \
  --output screenshot.png
const headers = {
  'Accept-Language': 'en-US'
};

const params = new URLSearchParams({
  key: 'YOUR_API_KEY',
  url: 'https://example.com',
  customHeaders: JSON.stringify(headers)
});

await fetch(`https://api.domshot.com/shot?${params}`)
  .then(res => res.blob())
  .then(blob => fs.writeFile('screenshot.png', blob));
$headers = [
  'Accept-Language' => 'en-US'
];

$params = [
  'key' => 'YOUR_API_KEY',
  'url' => 'https://example.com',
  'customHeaders' => json_encode($headers)
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
file_put_contents('screenshot.png', $result);
curl_close($ch);
package main

import (
    "encoding/json"
    "net/http"
    "net/url"
)

func main() {
    headers := map[string]string{
        "Accept-Language": "en-US",
    }

    params := url.Values{}
    params.Set("key", "YOUR_API_KEY")
    params.Set("url", "https://example.com")

    headersJSON, _ := json.Marshal(headers)
    params.Set("customHeaders", string(headersJSON))

    resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
    defer resp.Body.Close()

    // Save response to file
}

Multiple headers

bash
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&customHeaders=%7B%22Accept-Language%22%3A%22en-US%22%2C%22Accept-Encoding%22%3A%22gzip%2C%20deflate%22%7D" \
  --output screenshot.png
const headers = {
  'Accept-Language': 'en-US',
  'Accept-Encoding': 'gzip, deflate',
  'Authorization': 'Bearer token'
};

const params = new URLSearchParams({
  key: 'YOUR_API_KEY',
  url: 'https://example.com',
  customHeaders: JSON.stringify(headers)
});

await fetch(`https://api.domshot.com/shot?${params}`)
  .then(res => res.blob())
  .then(blob => fs.writeFile('screenshot.png', blob));
$headers = [
  'Accept-Language' => 'en-US',
  'Accept-Encoding' => 'gzip, deflate',
  'Authorization' => 'Bearer token'
];

$params = [
  'key' => 'YOUR_API_KEY',
  'url' => 'https://example.com',
  'customHeaders' => json_encode($headers)
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
file_put_contents('screenshot.png', $result);
curl_close($ch);
package main

import (
    "encoding/json"
    "net/http"
    "net/url"
)

func main() {
    headers := map[string]string{
        "Accept-Language": "en-US",
        "Accept-Encoding":  "gzip, deflate",
        "Authorization":   "Bearer token",
    }

    params := url.Values{}
    params.Set("key", "YOUR_API_KEY")
    params.Set("url", "https://example.com")

    headersJSON, _ := json.Marshal(headers)
    params.Set("customHeaders", string(headersJSON))

    resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
    defer resp.Body.Close()

    // Save response to file
}

Common use cases

Use caseExample header
Language preferenceAccept-Language: en-US
Content negotiationAccept: application/json
Custom authenticationAuthorization: Bearer token
Geographic targetingX-Forwarded-For: 1.2.3.4
Custom headers override browser defaults. Some headers like User-Agent have a dedicated parameter (see Custom User Agent).

Parameters

ParameterTypeDescription
customHeadersstringJSON object of HTTP headers

See also