Custom User Agent
Set a custom user agent to test how pages render for different browsers and devices.
DomShot’s default user agent is already optimized to bypass most bot detection systems, including Cloudflare. Only use a custom user agent when you need specific browser or device emulation.
Basic usage
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&customUserAgent=%7B%22userAgent%22%3A%22Mozilla%2F5.0%20(iPhone%3B%20CPU%20iPhone%20OS%2014_0%20like%20Mac%20OS%20X)%22%7D" \
--output screenshot.png
const userAgent = {
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)'
};
const params = new URLSearchParams({
key: 'YOUR_API_KEY',
url: 'https://example.com',
customUserAgent: JSON.stringify(userAgent)
});
await fetch(`https://api.domshot.com/shot?${params}`)
.then(res => res.blob())
.then(blob => fs.writeFile('screenshot.png', blob));
$userAgent = [
'userAgent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)'
];
$params = [
'key' => 'YOUR_API_KEY',
'url' => 'https://example.com',
'customUserAgent' => json_encode($userAgent)
];
$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"
)
type UserAgent struct {
UserAgent string `json:"userAgent"`
}
func main() {
userAgent := UserAgent{
UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)",
}
params := url.Values{}
params.Set("key", "YOUR_API_KEY")
params.Set("url", "https://example.com")
userAgentJSON, _ := json.Marshal(userAgent)
params.Set("customUserAgent", string(userAgentJSON))
resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
defer resp.Body.Close()
// Save response to file
}
{
"userAgent": "Mozilla/5.0 ...",
"platform": "iPhone",
"userAgentMetadata": {
"brands": [
{"brand": "Chrome", "version": "120"}
],
"platform": "iOS",
"platformVersion": "14_0",
"architecture": "",
"model": "iPhone",
"mobile": true
}
}
Fields
| Field | Type | Required | Description |
|---|
userAgent | string | No | Full user agent string |
platform | string | No | Platform identifier (e.g., “Win32”, “iPhone”) |
userAgentMetadata | object | No | Client Hints user agent data |
Common user agents
| Use case | User agent |
|---|
| Chrome Windows | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 |
| Safari iPhone | Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) |
| Googlebot | Mozilla/5.0 (compatible; Googlebot/2.1) |
Custom user agents may trigger bot detection systems. The default DomShot user agent is optimized to bypass most protections including Cloudflare.
Parameters
| Parameter | Type | Description |
|---|
customUserAgent | string | JSON object with user agent details |
See also