← Knowledge base
Integration

curl, Python and Node.js

Working proxy examples for curl, Python (requests and aiohttp) and Node.js (undici and axios), plus how to handle proxy errors in each.

Updated Sep 15, 2026 · 2 min read

Every example below uses the same credential (ofp_0123abcd / PASSWORD) against the gateway from the Docs:

HTTP / HTTPS (CONNECT)  proxy.oneforproxy.com:8080
SOCKS5                  proxy.oneforproxy.com:1080

Targeting options (country, state, city, ASN, sticky session) are appended to the username — see the full DSL in Targeting.

curl

HTTP proxy, rotating IP:

curl -x "http://ofp_0123abcd-country-de:PASSWORD@proxy.oneforproxy.com:8080" https://api.ipify.org

SOCKS5 with remote DNS resolution — use socks5h://, not socks5://, so the target hostname resolves through the proxy rather than locally:

curl -x "socks5h://ofp_0123abcd-country-de:PASSWORD@proxy.oneforproxy.com:1080" https://api.ipify.org

Surface the HTTP status on failure instead of curl's generic exit code:

curl -s -o /dev/null -w "%{http_code}\n" \
  -x "http://ofp_0123abcd:PASSWORD@proxy.oneforproxy.com:8080" \
  https://api.ipify.org

Python — requests

import requests

proxy = "http://ofp_0123abcd-country-us-city-new_york:PASSWORD@proxy.oneforproxy.com:8080"

try:
    r = requests.get(
        "https://api.ipify.org?format=json",
        proxies={"http": proxy, "https": proxy},
        timeout=30,
    )
    r.raise_for_status()
    print(r.json())
except requests.exceptions.ProxyError:
    print("proxy auth or connection failed — check the credential and DSL options")
except requests.exceptions.Timeout:
    print("upstream timeout — retry or change targeting")

Python — aiohttp

aiohttp speaks the HTTP proxy natively; SOCKS5 needs aiohttp-socks.

import asyncio
import aiohttp

PROXY = "http://ofp_0123abcd-country-de:PASSWORD@proxy.oneforproxy.com:8080"

async def main():
    async with aiohttp.ClientSession() as session:
        try:
            timeout = aiohttp.ClientTimeout(total=30)
            async with session.get("https://api.ipify.org", proxy=PROXY, timeout=timeout) as resp:
                if resp.status == 407:
                    print("auth failed — check login/password")
                elif resp.status == 402:
                    print("balance or quota exhausted — see /kb/billing-and-packages")
                else:
                    print(resp.status, await resp.text())
        except asyncio.TimeoutError:
            print("request timed out")

asyncio.run(main())

Node.js — undici

import { ProxyAgent, fetch } from "undici";

const dispatcher = new ProxyAgent("http://ofp_0123abcd-country-de:PASSWORD@proxy.oneforproxy.com:8080");

try {
  const res = await fetch("https://api.ipify.org", { dispatcher });
  if (res.status === 407) throw new Error("proxy auth failed");
  console.log(await res.text());
} catch (err) {
  console.error("request failed:", err.message);
}

Node.js — axios

import axios from "axios";

const client = axios.create({
  proxy: {
    protocol: "http",
    host: "proxy.oneforproxy.com",
    port: 8080,
    auth: { username: "ofp_0123abcd-country-de", password: "PASSWORD" }
  },
  timeout: 30000
});

try {
  const res = await client.get("https://api.ipify.org");
  console.log(res.data);
} catch (err) {
  const status = err.response?.status;
  if (status === 429) console.error("too many concurrent connections — lower concurrency");
  else console.error(err.message);
}

Error handling

Treat the proxy like any other upstream that can fail: catch connection and auth errors separately from a successful non-2xx response, and back off on 429/503/504 instead of retrying immediately — retrying a bad credential just produces more 407s. The full HTTP/SOCKS5 error table is in Errors and the Docs.