# Proxies

> How to pass a proxy with a Noptcha task, which types need one, and how proxy credentials are handled.

Source: https://noptcha.com/docs/proxies/

Some captchas are tied to the IP address that loads them. For those types you can (or, for some, must) give the proxy the solver should use. Each [task type page](https://noptcha.com/docs/task-types.md) says whether a proxy is optional, required or not used.

## Native API (v1)

Add `proxy` to `params`:

| Field |  |
| --- | --- |
| `type` | `http`, `https`, `socks4` or `socks5` |
| `host` | IP address or host name; private and loopback addresses are rejected |
| `port` | 1–65535 |
| `login`, `password` | optional |

**curl**

```bash
export NOPTCHA_KEY=nop_test_...  # your test or live key
curl -s -X POST "https://api.noptcha.com/v1/tasks" \
  -H "Authorization: Bearer $NOPTCHA_KEY" \
  -H 'Content-Type: application/json' \
  -d @- <<EOF
{
  "type": "recaptcha.v2",
  "params": {
    "website_url": "https://example.com/login",
    "website_key": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
    "proxy": {
      "type": "http",
      "host": "203.0.113.7",
      "port": 8080,
      "login": "proxyuser",
      "password": "proxypass"
    }
  }
}
EOF
```


**Python**

```python
import os

import requests

API = "https://api.noptcha.com"
KEY = os.environ["NOPTCHA_KEY"]

r = requests.post(
    f"{API}/v1/tasks",
    headers={
        "Authorization": f"Bearer {KEY}",
    },
    json={
        "type": "recaptcha.v2",
        "params": {
            "website_url": "https://example.com/login",
            "website_key": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
            "proxy": {
                "type": "http",
                "host": "203.0.113.7",
                "port": 8080,
                "login": "proxyuser",
                "password": "proxypass",
            },
        },
    },
    timeout=30,
)
print(r.status_code, r.json())
```


**Node.js**

```js
const API = 'https://api.noptcha.com';
const KEY = process.env.NOPTCHA_KEY;

const res = await fetch(`${API}/v1/tasks`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    type: "recaptcha.v2",
    params: {
      website_url: "https://example.com/login",
      website_key: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
      proxy: {
        type: "http",
        host: "203.0.113.7",
        port: 8080,
        login: "proxyuser",
        password: "proxypass",
      },
    },
  }),
});
console.log(res.status, await res.json());
```

A task with `proxy` uses the type’s `proxy` variant, which can have a different price (`GET /v1/types` lists the price of each variant).

## Compatibility API

Use the name without `Proxyless` (for example `RecaptchaV2Task` instead of `RecaptchaV2TaskProxyless`) and add `proxyType`, `proxyAddress`, `proxyPort` and optionally `proxyLogin` and `proxyPassword`. `proxyPort` may be a number or a string. Names ending in `Proxyless` ignore proxy fields.

**curl**

```bash
export NOPTCHA_KEY=nop_test_...  # your test or live key
curl -s -X POST "https://api.noptcha.com/createTask" \
  -H 'Content-Type: application/json' \
  -d @- <<EOF
{
  "clientKey": "$NOPTCHA_KEY",
  "task": {
    "type": "RecaptchaV2Task",
    "websiteURL": "https://example.com/login",
    "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
    "proxyType": "http",
    "proxyAddress": "203.0.113.7",
    "proxyPort": 8080,
    "proxyLogin": "proxyuser",
    "proxyPassword": "proxypass"
  }
}
EOF
```


**Python**

```python
import os

import requests

API = "https://api.noptcha.com"
KEY = os.environ["NOPTCHA_KEY"]

r = requests.post(
    f"{API}/createTask",
    json={
        "clientKey": KEY,
        "task": {
            "type": "RecaptchaV2Task",
            "websiteURL": "https://example.com/login",
            "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
            "proxyType": "http",
            "proxyAddress": "203.0.113.7",
            "proxyPort": 8080,
            "proxyLogin": "proxyuser",
            "proxyPassword": "proxypass",
        },
    },
    timeout=30,
)
print(r.status_code, r.json())
```


**Node.js**

```js
const API = 'https://api.noptcha.com';
const KEY = process.env.NOPTCHA_KEY;

const res = await fetch(`${API}/createTask`, {
  method: 'POST',
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    clientKey: KEY,
    task: {
      type: "RecaptchaV2Task",
      websiteURL: "https://example.com/login",
      websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
      proxyType: "http",
      proxyAddress: "203.0.113.7",
      proxyPort: 8080,
      proxyLogin: "proxyuser",
      proxyPassword: "proxypass",
    },
  }),
});
console.log(res.status, await res.json());
```

## 2captcha legacy API

`proxy=login:password@host:port` (or `host:port`) and `proxytype=HTTP|HTTPS|SOCKS4|SOCKS5`.

## Credentials

Proxy logins and passwords are used in memory only: they are never stored, logged or returned. Task responses show `params` without them.

## Proxy errors

If the solver cannot use the proxy, the task fails with `proxy_error` (v1), `ERROR_PROXY_CONNECT_REFUSED` or another `ERROR_PROXY_…` code (compatibility API), or `ERROR_PROXY_CONNECTION_FAILED` (2captcha legacy API). Failed tasks are not charged. Check that the proxy is reachable from the internet and accepts the credentials.
