#
Proxy & User Agent
Configure proxy and User-Agent for tasks that support them.
#
Supported tasks
- ReCAPTCHA v2 / v2 Enterprise
- FunCaptcha
- GeeTest (v3 & v4)
- Turnstile
- AWS WAF
- Binance
- Data Dome (proxy required)
- Imperva (proxy required)
- MTCaptcha, Prosopo, Yidun, Altcha, Basilisk, Castle, Hunt, RecaptchaClick, TurnstileWaitroom, TSPD
#
Per-task proxy
Pass proxy directly in the task configuration. This allows using different proxies for different tasks with the same client instance.
import { RecaptchaV2Task } from "node-capmonster"
const client = new RecaptchaV2Task("<api_key>")
const task = client.task({
websiteURL: "https://example.com",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
proxy: {
proxyType: "http", // "http" | "https" | "socks4" | "socks5"
proxyAddress: "1.2.3.4",
proxyPort: 8080,
},
})
const taskId = await client.createWithTask(task)
const result = await client.joinTaskResult(taskId)
#
With proxy authentication
const task = client.task({
websiteURL: "https://example.com",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
proxy: {
proxyType: "http",
proxyAddress: "1.2.3.4",
proxyPort: 8080,
proxyLogin: "username", // optional
proxyPassword: "password", // optional
},
})
#
Different proxies per task
const client = new RecaptchaV2Task("<api_key>")
// Task 1 — HTTP proxy
const taskId1 = await client.createWithTask({
websiteURL: "https://site-a.com",
websiteKey: "key_a",
proxy: {
proxyType: "http",
proxyAddress: "1.2.3.4",
proxyPort: 8080,
},
})
// Task 2 — SOCKS5 proxy
const taskId2 = await client.createWithTask({
websiteURL: "https://site-b.com",
websiteKey: "key_b",
proxy: {
proxyType: "socks5",
proxyAddress: "5.6.7.8",
proxyPort: 1080,
proxyLogin: "user",
proxyPassword: "pass",
},
})
#
Without proxy (Proxyless)
If you omit the proxy field, CapMonster Cloud uses built-in proxies:
const task = client.task({
websiteURL: "https://example.com",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
})
#
ProxyConfig type
You can import the ProxyConfig type for type-safe proxy configuration:
import { RecaptchaV2Task, ProxyConfig } from "node-capmonster"
const myProxy: ProxyConfig = {
proxyType: "http",
proxyAddress: "1.2.3.4",
proxyPort: 8080,
}
If the proxy is authorized by IP, whitelist 65.21.190.34.
#
Global proxy (deprecated)
setGlobalProxy and unsetProxy are deprecated and will be removed in a future version. Use
The global proxy applies to all tasks created by that client instance. It is still functional but will emit a deprecation warning.
const client = new RecaptchaV2Task("<api_key>")
// Deprecated — use per-task proxy instead
client.setGlobalProxy({
proxyType: "http",
proxyAddress: "1.2.3.4",
proxyPort: 8080,
})
// Remove global proxy
client.unsetProxy()
#
Priority
When both per-task and global proxy are set, per-task proxy takes precedence:
- Per-task proxy — if
proxyis provided in the task config - Global proxy — if
setGlobalProxywas called and no per-task proxy - Proxyless — if neither is set (uses CapMonster Cloud built-in proxies)
#
Set User-Agent
client.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) ...")
#
Remove User-Agent
client.unsetUserAgent()
#
Get current User-Agent
Fetch the current valid Windows UA from CapMonster Cloud:
const ua = await client.getUserAgent()
client.setUserAgent(ua)
User-Agent settings persist until explicitly unset with unsetUserAgent(). They apply to all tasks created by that client instance.