← Back to Blog
Python · Proxy Setup

How to Use Your StaticIP.in Proxy in Python

Once you've bought a dedicated static IP, every API call your bot makes needs to actually leave through that IP - that's what makes broker IP whitelisting work. Here are the two ways to wire that up in Python, and how to confirm it's actually working before you trust it with a real order.

Updated Aug 2026 · 5 min read

Before anything else - your credentials (staticip_userid / staticip_password / host / port below) come from your dashboard after you've issued an IP. The host will look like dc-mum-XXX.staticip.in - the exact number depends on which server your IP was issued from, so copy whatever your dashboard actually shows rather than assuming a fixed value; the raw IP address works identically if you'd rather use that instead. These are separate from your broker's own API key/secret - don't mix them up. Don't hardcode them in a script you'll share or commit - load them from environment variables or a secrets file in anything other than a quick local test.

The generic pattern (works with any Python HTTP library)

Every integration reduces to the same idea: build a proxy URL with your issued credentials, and tell your HTTP client to route through it. There are two equally valid ways to do that - which one you use just depends on whether the library you're calling accepts a proxies argument or not.

Method 1 - pass proxies directly on each request (preferred when the library supports it)

The cleanest option: pass the proxy explicitly on every requests.get()/requests.post() call (or to whatever client object your SDK exposes) - no shared session object, so it's obvious from each call exactly which traffic is going through the proxy.

generic_proxy_setup.py
import requests

STATICIP_HOSTNAME = "your-assigned-host.staticip.in"  # from your dashboard - hostname OR raw IP both work
STATICIP_PORT = 443
STATICIP_USERID = "your_staticip_userid"      # from your StaticIP.in dashboard
STATICIP_PASSWORD = "your_staticip_password"  # from your StaticIP.in dashboard

# Form the proxy URL with basic auth baked in
PROXY_URL = f"http://{STATICIP_USERID}:{STATICIP_PASSWORD}@{STATICIP_HOSTNAME}:{STATICIP_PORT}"
proxies = {"http": PROXY_URL, "https": PROXY_URL}

# Confirm which IP this request is actually leaving from BEFORE placing any order
ip_check = requests.get("https://api64.ipify.org?format=json", proxies=proxies, timeout=10)
print("Outgoing IP:", ip_check.json()["ip"])   # should match the static IP in your dashboard

# Now place the order through the same proxy
response = requests.post(
    "https://api.broker.com/v1/orders",
    json={"symbol": "RELIANCE", "qty": 10, "price": 2500, "side": "BUY", "order_type": "LMT"},
    proxies=proxies,
)
print(response.json())

Method 2 - set environment variables (works even when a library gives you no proxy option at all)

Some broker SDKs don't expose a proxies parameter anywhere - they just call requests internally with their own defaults. In that case, set the standard proxy environment variables before importing the SDK; requests (and almost everything built on it) reads these automatically for every outgoing call, with no code changes to the library itself needed.

generic_proxy_env_setup.py
import os

STATICIP_USERID = "your_staticip_userid"      # from your StaticIP.in dashboard
STATICIP_PASSWORD = "your_staticip_password"  # from your StaticIP.in dashboard
STATICIP_HOSTNAME = "your-assigned-host.staticip.in"  # from your dashboard - hostname OR raw IP both work
PORT_NO = 443

PROXY = f"http://{STATICIP_USERID}:{STATICIP_PASSWORD}@{STATICIP_HOSTNAME}:{PORT_NO}"
for var in ("HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"):
    os.environ[var] = PROXY

# Import the broker SDK AFTER the env vars are set
import requests

# Confirm which IP this request is actually leaving from BEFORE placing any order
ip_check = requests.get("https://api64.ipify.org?format=json", timeout=10)
print("Outgoing IP:", ip_check.json()["ip"])   # should match the static IP in your dashboard

response = requests.post(
    "https://api.broker.com/v1/orders",
    json={"symbol": "RELIANCE", "qty": 10, "price": 2500, "side": "BUY", "order_type": "LMT"},
)
print(response.json())   # this call leaves from your dedicated IP

Rule of thumb: use Method 1 whenever the SDK lets you (it's scoped and explicit); fall back to Method 2 only when the SDK genuinely doesn't expose a proxy option.

Why check the outgoing IP first?

A typo in the proxy URL, a missing scheme, or an SDK that quietly ignores your proxy setting can all leave your bot calling the broker from your regular internet connection instead - which fails whitelisting silently rather than loudly. The api64.ipify.org call above costs one extra request and tells you, in plain text, exactly which IP address is about to place your order. Always run it once after any proxy change, before you trust the setup with a real order.

Using Zerodha, Fyers, Angel One, Dhan, or Upstox?

See our broker-specific proxy setup guide for the exact wiring each broker's SDK actually supports, built on the same two methods above.

Using a broker not listed there?

Any of the 200+ brokers/platforms we support work the same way - if their SDK accepts a proxies parameter, use Method 1; if not, Method 2 works with virtually any requests-based library. Stuck on a specific one? message us or ping +91 94706 69031 on WhatsApp and we'll help you wire it up.

Don't have a static IP yet?

SEBI-compliant IPv4/IPv6 from ₹100/month. Whitelist-ready in minutes.