Static IP for the Flattrade API

Flattrade's Pi API needs a registered static IP before it will even create an API key, and both your daily token and every order must come from that same IP. You need one fixed public IP that only you use, entered when you create the Pi API key, with the login and order calls both sent through it.

Last checked against the broker's own docs on 31 October 2026

What Flattrade checks

From Flattrade's support pages and its API version 2 announcement:

That token rule is stricter than most brokers. Generate the token through the fixed IP too, not from your home connection.

IPv4 or IPv6 for Flattrade

Flattrade's pages don't say whether the static IP field accepts IPv6. On the network side, piconnect.flattrade.in has an IPv6 address, so the API and WebSocket are reachable over IPv6. Try the IPv6 address in the Pi key screen or ask Flattrade support. If you'd rather not wait, IPv4 works for certain.

How to register your IP with Flattrade

  1. Get your fixed IP's proxy details: host, port, username and password.
  2. Check the exact exit address: curl -x http://USER:PASS@HOST:PORT https://ifconfig.co
  3. Log in to Flattrade's WALL platform, open Pi, and create a new API key with your redirect URL and the static IP.
  4. Run the daily login flow from the Pi docs with the proxy already set, so the token is issued against the registered IP.

Send Flattrade calls through the fixed IP

NorenRestApiPy calls requests.post() directly, so the standard proxy environment variables route every REST call:

import os

PROXY = os.environ["PROXY_URL"]  # http://USER:PASS@HOST:PORT
for v in ("HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"):
    os.environ[v] = PROXY  # every requests call in this process uses the fixed IP

from NorenRestApiPy.NorenApi import NorenApi

class FlattradeApi(NorenApi):
    def __init__(self):
        NorenApi.__init__(
            self,
            host="https://piconnect.flattrade.in/PiConnectAPI/",
            websocket="wss://piconnect.flattrade.in/PiConnectWSAPI/",
        )

api = FlattradeApi()
api.set_session(userid=os.environ["FLATTRADE_USERID"], password="", usertoken=os.environ["FLATTRADE_TOKEN"])

If your token script runs separately, set the same variables there as well, or the token will be issued against your home IP and orders will fail. The WebSocket doesn't pick up these variables. The full Flattrade proxy guide on GitHub has a small patch that routes it through the proxy, plus a sample order.

Common Flattrade errors

For a step-by-step check of IP errors, see how to fix "IP not whitelisted" errors.

Flattrade static IP: FAQs

Can I create a Flattrade API key with a home IP?

No. Flattrade requires a static IP to create an API key, and dynamic home IPs aren't accepted.

Why are my Flattrade orders rejected when the IP is correct?

Check where the token was generated. Flattrade needs the token and the orders to come from the same registered IP, so a token made on your home connection fails even if orders leave from the right IP.

Can I add a backup IP on Flattrade?

Yes, one primary and one optional backup IP. Each can be changed at most once a calendar week.

Which TrueIP plan should I take for Flattrade?

IPv4 at ₹200 a month plus GST works for certain. If Flattrade accepts your IPv6 address in the Pi key screen, a dedicated IPv6 at ₹50 a month is the cheaper option.

Sources

Get your dedicated static IP

IPv6 ₹50 a month, IPv4 ₹200 a month, plus GST. Live in minutes, whitelisted once.

Get IPv4 · ₹200/mo + GSTGet IPv6 · ₹50/mo + GST

Other brokers

Zerodha Kite Connect

Zerodha Kite Connect accepts API orders only from a whitelisted IP. The rules, IPv4 or IPv6, where to add the IP, and Python code to route orders through it.

Upstox API

Upstox accepts API orders only from your registered static IP. The rules, IPv4 or IPv6, where to add the IP, and the Python SDK setup that avoids 407 errors.

Angel One SmartAPI

Angel One SmartAPI accepts orders only from your registered static IP, and only IPv4 for now. The rules, how to register the IP, and the Python setup.

Fyers API

Fyers accepts API orders only from the static IP on your Algo trading app. How the new app works, IPv4 or IPv6, and the Python setup for fyers-apiv3.