# Connect to rotating proxies

Read the gateway hosts, ports and credentials of a rotating proxy plan from the API, connect over HTTP or SOCKS5, use sticky ports and track the remaining request quota.

- Canonical: https://fineproxy.org/developers/docs/proxies/rotating/

A rotating proxy plan gives you a gateway instead of a fixed list of IPs: you connect to one host and port, and the exit IP is chosen from a pool. This page shows how to read the connection settings from the API, connect, use sticky sessions and track your quota.

## How rotating plans work

- A rotating plan is a catalog product with `product_kind: proxy_rotating`, bought with `POST /api/v1/customer/services` — see [Idempotency & price guards](/developers/docs/idempotency/#rest-rotating-plans-and-catalog-products).
- The plan includes a quota of **requests** (also called credits): for example, "Rotating Proxies 2.5M Credits" includes 2,500,000 requests for a 30-day period.
- You connect to a **gateway host** with the plan's username and password. The gateway has regular ports for rotating connections and **sticky ports** that keep the same exit IP for a session.

The rotating-specific endpoints — `GET .../proxy/config` and the sticky-session endpoints — work only for rotating services. For a datacenter service they return `404`, for example `{"detail": "Rotating config not available for service <id>"}`.

## Get the connection config

```bash
curl https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/config \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

Example response:

```json
{
  "endpoint": "fineproxy.xyz",
  "endpoints": ["fineproxy.xyz"],
  "https_endpoints": ["eu01.mcccx.com", "us01.mcccx.com"],
  "port": 3081,
  "http_ports": [3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094],
  "socks_ports": [2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094],
  "sticky_http": 5080,
  "sticky_socks5": 4080,
  "sticky_https": 4443,
  "session_format": "ip:port:username:password",
  "mode": "sticky",
  "sample_connection_string": "fineproxy.xyz:3081:USER:********",
  "sample_connection_strings": ["fineproxy.xyz:3081:USER:********"]
}
```

| Field | Meaning |
| --- | --- |
| `endpoint` | Primary gateway host (the first entry of `endpoints`) |
| `endpoints` | All gateway entry hosts for HTTP and SOCKS5 connections |
| `https_endpoints` | Regional hosts for HTTPS connections; in the example they are also the sticky hosts |
| `port` | Primary HTTP port (the first entry of `http_ports`) |
| `http_ports` | HTTP proxy ports on the gateway hosts |
| `socks_ports` | SOCKS5 proxy ports on the gateway hosts |
| `sticky_http`, `sticky_socks5`, `sticky_https` | Sticky-session ports for HTTP, SOCKS5 and HTTPS |
| `session_format` | Order of the parts in a connection string: `host:port:username:password` |
| `mode` | Current session mode of the plan (`sticky` by default) |
| `sample_connection_string(s)` | Ready-made connection strings with the password masked |

> **Important:** Hosts and ports depend on your plan and can change. Always read them from `proxy/config` instead of hardcoding the values shown here.

## Get the username and password

The config does not include credentials. Read them from `GET .../proxy/auth`, adding `reveal=true` to get the password in plain text:

```bash
curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/auth?reveal=true" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

For a rotating service, the response contains `username`, `password` and a `rotating_gateway` object that repeats the gateway layout, including `entry_hosts`, `https_hosts` and `sticky_hosts`:

```json
{
  "username": "PPR0123456789",
  "password": "your_proxy_password",
  "password_set": true,
  "rotating_gateway": {
    "entry_hosts": ["fineproxy.xyz"],
    "https_hosts": ["eu01.mcccx.com", "us01.mcccx.com"],
    "sticky_hosts": ["eu01.mcccx.com", "us01.mcccx.com"],
    "entry_host": "fineproxy.xyz",
    "https_host": "eu01.mcccx.com",
    "http_ports": [3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094],
    "socks_ports": [2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094],
    "sticky_http": 5080,
    "sticky_socks5": 4080,
    "sticky_https": 4443
  }
}
```

The response also contains `endpoints[]` and other fields shared with datacenter services; they are trimmed here. You can rotate the password with `PUT .../proxy/auth` and `{"rotate_password": true}`, as for [datacenter proxies](/developers/docs/proxies/datacenter/#change-the-proxy-password).

## Connect

Build the proxy URL from the config and the credentials. The connection string format is `host:port:username:password`, so the config's sample `fineproxy.xyz:3081:USER:********` becomes the proxy URL `http://USER:PASSWORD@fineproxy.xyz:3081`.

| Connection | Host | Port |
| --- | --- | --- |
| HTTP, rotating | `endpoint` (or any of `endpoints`) | `port` (or any of `http_ports`) |
| SOCKS5, rotating | `endpoint` (or any of `endpoints`) | one of `socks_ports` |
| HTTP, sticky | one of the sticky hosts (`rotating_gateway.sticky_hosts`) | `sticky_http` |
| SOCKS5, sticky | one of the sticky hosts | `sticky_socks5` |
| HTTPS, sticky | one of the sticky hosts | `sticky_https` |

With the values from the example, and the host and port taken from your own config:

```bash
export PROXY_USER="PPR0123456789"
export PROXY_PASS="your_proxy_password"
export GATEWAY_HOST="fineproxy.xyz"   # proxy/config → endpoint
export GATEWAY_PORT="3081"            # proxy/config → port

curl -x "http://$PROXY_USER:$PROXY_PASS@$GATEWAY_HOST:$GATEWAY_PORT" https://api.ipify.org
```

For SOCKS5, use a port from `socks_ports` and remote DNS:

```bash
curl --socks5-hostname "$PROXY_USER:$PROXY_PASS@$GATEWAY_HOST:2081" https://api.ipify.org
```

In code, read everything from the API at startup:

```javascript
// npm install undici
import { fetch, ProxyAgent } from 'undici';

const API = `https://fineproxy.org/account_new/api/v1/customer/services/${process.env.SERVICE_ID}`;
const headers = { Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}` };
const getJson = async (url) => {
  const res = await fetch(url, { headers });
  if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
  return res.json();
};

const config = await getJson(`${API}/proxy/config`);
const auth = await getJson(`${API}/proxy/auth?reveal=true`);

const dispatcher = new ProxyAgent({
  uri: `http://${config.endpoint}:${config.port}`,
  token: `Basic ${Buffer.from(`${auth.username}:${auth.password}`).toString('base64')}`,
});
const res = await fetch('https://api.ipify.org', { dispatcher });
console.log(await res.text());
```

```python
import os
from urllib.parse import quote

import requests

API = f"https://fineproxy.org/account_new/api/v1/customer/services/{os.environ['SERVICE_ID']}"
headers = {"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"}


def get_json(url, **params):
    res = requests.get(url, headers=headers, params=params, timeout=30)
    res.raise_for_status()
    return res.json()


config = get_json(f"{API}/proxy/config")
auth = get_json(f"{API}/proxy/auth", reveal="true")

proxy = f"http://{quote(auth['username'], safe='')}:{quote(auth['password'], safe='')}@{config['endpoint']}:{config['port']}"
res = requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}, timeout=30)
print(res.text)
```

For SOCKS5 in Python, install `requests[socks]` and use `socks5h://` with a port from `socks_ports`; in Node.js, use `socks-proxy-agent` as shown for [datacenter proxies](/developers/docs/proxies/datacenter/#connect-from-code).

> **Note:** Country targeting or session IDs inside the username are not part of the documented connection format. Use the hosts, ports and connection strings returned by `proxy/config`.

## Sticky sessions

On sticky ports the gateway keeps the same exit IP for a session instead of rotating it on every request. The session settings of the plan are available through the API:

- `GET .../proxy/sticky/mode` — the session mode; `sticky` by default.
- `GET .../proxy/sticky/ttl` — how long a session keeps its exit IP: 900 seconds (15 minutes) by default; you can set your own value (minimum 30 seconds).
- `GET .../proxy/sticky/sessions` — active sessions, with endpoints to rotate a single session or purge all of them.

```bash
curl https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/ttl \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

```json
{
  "ttl_seconds": 900,
  "is_custom": false,
  "global_default_ttl": 900,
  "ttl_human": "15m"
}
```

For changing the mode and TTL and managing sessions, see [Sticky sessions](/developers/docs/guides/sticky-sessions/).

## Track usage and quota

The plan's quota is stored on the service. `GET /api/v1/customer/services/{service_id}` returns it in `params`:

| Field | Meaning |
| --- | --- |
| `params.quota_kind` | What the quota counts: `requests` |
| `params.requests_quota` | Requests included in the current period |
| `params.requests_remaining` | Requests left in the current period |
| `params.base_remaining_requests`, `params.topup_remaining_requests` | Remaining requests from the plan itself and from top-ups |
| `expires_at` | End of the current period |

Traffic for a time window comes from `GET .../usage` with ISO 8601 `start` and `end` (requires `usage:read`):

```bash
curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/usage?start=2026-11-27T00:00:00Z&end=2026-11-27T23:59:59Z" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

```json
{
  "connections": 0,
  "bytes_used": 0,
  "window": { "start": "2026-11-27T00:00:00Z", "end": "2026-11-27T23:59:59Z" }
}
```

A service that runs out of quota is suspended with `suspend_reason: quota_exhausted` until the quota is topped up in the dashboard or the next period's quota is granted. Through MCP, use `get_usage`, `get_usage_overview` and `get_diagnostics` for usage and error analysis.

## Next steps

- [Sticky sessions](/developers/docs/guides/sticky-sessions/) — control how long an exit IP is kept.
- [Datacenter proxies](/developers/docs/proxies/datacenter/) — dedicated IPs with per-IP endpoints.
- [Proxy access API reference](/developers/docs/api/proxy-access/) and [Sticky API reference](/developers/docs/api/sticky/).
