Guide

How to get a IG API key

IG API keys are created in the My IG web platform, one per environment (demo and live).

About 10 minutes 4 steps Checked October 2026

Before you start

  • An IG account (a demo account is enough to start)
  • Your IG username and password

Create your IG API key

  1. 1

    Log in to My IG

    Log in to the web platform for the environment you want (demo or live).

  2. 2

    Open API keys

    Go to Settings → API keys (labelled My IG → Settings).

  3. 3

    Create a key

    Choose Create API key, name it, and copy the key. Save it as IG_API_KEY.

  4. 4

    Store your login

    Save IG_USERNAME and IG_PASSWORD; the API opens a session with them.

Test the key

Before wiring the key into a strategy, make one request by hand. It separates “the key is wrong” from “my code is wrong”.

curl -s -i -X POST https://demo-api.ig.com/gateway/deal/session \
  -H "X-IG-API-KEY: $IG_API_KEY" -H "Content-Type: application/json" -H "Version: 2" \
  -d '{"identifier":"'$IG_USERNAME'","password":"'$IG_PASSWORD'"}'
200 with CST and X-SECURITY-TOKEN headers means the key works.

Keep the credentials safe

  • Store values in a password manager or a git-ignored .env, never in code or notebooks you share.
  • In an AlgoGP project you can still add them under APIs & keys (encrypted at rest) and read them with strategy_runtime.secrets.get("IG_API_KEY").
  • Give each bot its own credential so you can revoke one without stopping the others.
IG_API_KEY=paste-your-value-here
IG_USERNAME=paste-your-value-here
IG_PASSWORD=paste-your-value-here
.env for local runs

Frequently asked questions

Does a demo IG key work on live?

No. Create a separate key while logged in to the live platform.

Design and backtest your IG strategy first

AlgoGP turns an idea into Python and tests it on years of history before you connect it to IG. The exported code keeps the broker behind four small adapter methods.

  • AI copilot writes and revises the rules
  • Backtests with realistic costs
  • Exported Python ready to wire to IG

Free plan, no card required.

How the IG API works

AlgoGP is not affiliated with IG. Menus get renamed from time to time; if a label differs, the official documentation has the current path.