Requests

How to Use SocksNode Residential Proxies with Python Requests

Quick answer

To use SocksNode residential proxies with Python's requests library, pass a proxies dict pointing at http://USERNAME-country-us:[email protected]:9000 for both http and https keys. Use port 9000 for rotating IPs, or port 10000 with a session token for sticky IPs, and add country tokens to the username for geo targeting.

Before you start

SocksNode offers residential proxies in 195+ countries over HTTP, HTTPS, and SOCKS5 with username/password auth. Generate credentials for free in the dashboard proxy generator; only routed traffic consumes your prepaid bandwidth (from 5 GB for $4.50, non-expiring on flexible plans).

The requests library reads proxy URLs directly, so no extra dependency is needed for HTTP. For SOCKS5, install requests[socks].

Python 3.9+ with the requests library installed
requests[socks] installed if you want SOCKS5
A SocksNode account with prepaid bandwidth
A username/password from /dashboard/generator
Your target country token

Configure the proxy in requests

Build the proxies dict and pass it to your call:

For SOCKS5, change the scheme and port: socks5h://USERNAME-country-us:[email protected]:11000. The socks5h scheme resolves DNS through the proxy. Swap the country token to target any of 195+ countries.

import requests

proxies = {
    'http': 'http://USERNAME-country-us:PASSWORD@global.socksnode.com:9000',
    'https': 'http://USERNAME-country-us:PASSWORD@global.socksnode.com:9000',
}

r = requests.get('https://api.ipify.org', proxies=proxies)
print(r.text)

Rotating vs sticky sessions

Rotating sessions give a new residential IP per request: HTTP port 9000 or SOCKS5 port 11000. Ideal for spreading many small requests across exits.

Sticky sessions keep one IP from 1 minute up to 24 hours: HTTP port 10000 or SOCKS5 port 12000. Add a token like USERNAME-country-us-session-job5-lifetime-30 and reuse a requests.Session() to keep cookies and IP aligned for a stateful workflow.

Geo targeting with username tokens

Targeting is driven by username tokens: country across 195+ countries, US state and city, or ASN/ISP within a country. Only the username string changes between regions, keeping your code stable.

Fetch data lawfully, respect each site's terms of service, and stay within applicable law and reasonable request rates.

See also

Frequently asked questions

Do I need extra packages for SOCKS5?

Yes. Install requests[socks] (PySocks) to use socks5h URLs on ports 11000 or 12000. Plain HTTP on 9000 and 10000 needs no extra package.

How do I keep the same IP across calls?

Use port 10000 with a session token like USERNAME-country-us-session-abc-lifetime-30, and a shared requests.Session() so the IP persists for up to 24 hours.

Why should I use socks5h instead of socks5?

socks5h resolves DNS through the proxy rather than locally, which keeps lookups on the residential exit and avoids leaking your real resolver.

How do I target a US state or city?

Add state and city tokens to the username. SocksNode supports US targeting down to state and city, plus ASN/ISP within a country.

Is it free to create more credentials?

Yes. Generating credentials is free; only the traffic you route through the proxy consumes prepaid bandwidth.

Related posts

All posts

Get started.

Create an account, generate a credential, connect. The API is the same one the dashboard uses.