Broker API HubMenu

Getting started with API trading

An API lets your own code do what you would otherwise do by clicking in a broker's app: read prices, read your positions, and place or close trades. This guide explains how that works and what to sort out before you write a line of code.

Independent and unofficialBroker facts checked

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

What an API is

When you tap Buy in a trading app, the app sends a small message to the broker's computers and shows you the reply. An API is that same conversation, opened up so a program you control can have it instead.

Your program sends a request to an address called an endpoint. The request says what you want, such as your open positions, and proves who you are. The broker sends back a reply as structured text that code can read. That is the whole idea. Everything else is detail about which endpoints exist, how you prove who you are, and how often you may ask.

People use it to export their trade history, to keep a journal up to date without typing, to watch positions and send themselves alerts, to test a rule on past prices, and to place orders by rule. Most start with reading, not trading, and that is the right order.

What you need before you start

Is this for you at all?

If you trade on a phone app and have never written code, read Is API trading for you? first: one screen on who should not bother, what the realistic first win is, what the first request costs and what this is not.

Two routes: the broker's own API, or a platform API

Some brokers build their own API. Code written for it works with that broker only, but it usually reaches everything the broker offers.

Other brokers offer trading software made by someone else, and that software has an API of its own. Code written for a platform API can move with you between the brokers that offer the platform, which matters if you may change broker later.

Platform APIs, and how many brokers here offer each

Keep your key safe

An API key is a password for a program. Anyone holding it can do whatever the key allows, and on a live account that can mean placing trades.

The keys and demo accounts lesson shows how to set an environment variable on each operating system.

Limits: how often you may ask

Every broker limits how many requests you may send. The limits are usually several separate figures, each with its own scope: one for an application, one for an account, one for trading calls, one for price history. A program that loops without pausing can use a week's allowance in seconds, and repeated breaches can get a key suspended.

As a worked example, these are IG's published limits as held on this site's register. Where a broker's own pages disagree, pace against the lower figure.

LimitValueScopeSource
Historical price data points a week10,000Per account, price history endpoints onlylabs.ig.comchecked
Non trading requests a minute30Per account, non trading calls onlylabs.ig.comchecked
Non trading requests a minute60Per application, that is per API key, non trading calls onlylabs.ig.comchecked
Concurrent streaming subscriptions40Per streaming connectionlabs.ig.comchecked corroborated by labs.ig.com/streaming-api-guide.html
Trading requests a minute100Sources conflict ig.com states around 40, checked . IG's own pages disagree. The conflict is labelled, not resolved. Pace against 40.Per account, trading calls onlylabs.ig.comchecked

Each broker page lists the limits recorded for that broker.

Your first call

Start where no account is needed. This site's practice API answers with invented data and asks for no key, so a first request can go wrong without any cost. The lesson walks through it in Python.

Make a first request to the practice API

Then make the same kind of request to a broker, as a read, on a demo account: log in, then ask for your open positions. It cannot place a trade, and it proves that your key, your login and your code all work. That step needs a broker demo login.

Follow the first API call lesson, on a broker demo

When a call fails, the reply carries an error code. Look it up rather than guessing: there are 1,776 recorded on the errors pages.

Brokers on this register with an API of their own

How you get a key at each, as the broker's own pages state it. Lower down the page on purpose: pick a broker after the first call, not before.

BrokerHow you get accessSource
BitgetLog in to the Bitget website and create an API key under API Key Management. Each key set is an API key, a secret key and a passphrase you choose, with read or read and write permissions, and one UID can hold up to 50 key sets. Bitget recommends binding the key to an IP address.Bitget API quick startchecked
Capital.comEnable 2FA, then Settings > API integrations > Generate new key, with a custom key password.Capital.com Public APIchecked
DerivTwo kinds of app. With an OAuth 2.0 app the user signs in and consents at Deriv, and the app exchanges the code it gets back for an access token. With a Personal Access Token app the user generates a token in Deriv and enters it into the app. An earlier wording here (register an app_id in Manage Applications, or try the test app_id 1089) is legacy: it is not on Deriv's authentication page as read on 12 Oct 2026.Deriv API: authenticationchecked
DukascopyTwo routes of Dukascopy's own. The JForex API is a Java client library, shipped as the JForex SDK, that connects straight to Dukascopy's trade servers without the JForex platform running. The FIX API, on FIX 4.4, is described as for professional market participants: Dukascopy issues a TargetCompId, two SenderCompIds, a username and a password, and connections must come from IP addresses and ports agreed beforehand. The FIX page states no minimum deposit.Dukascopy JForex APIchecked
eToroSettings > Trading > API Key Management > Create New Key; choose Read or Write, optional IP whitelist and expiry.eToro API portal: authenticationchecked
FOREX.com / StoneX Trading (City Index)Open and fund a standard account, then request API access from support; an AppKey is emailed if accepted.FOREX.com API Tradingchecked
FXCMFree SDKs from FXCM GitHub; sign the EULA and apply for a demo account. Support at api@fxcm.com.GitHub fxcm/ForexConnectAPIchecked
IGAPI keys are only issued to existing live account holders: generate one in My IG > Settings > API keys.How to use IG APIchecked
Interactive BrokersNo key: run TWS or IB Gateway (TWS API) or the Client Portal Gateway and log in via browser (Web API).IBKR TWS API documentation, the IB Gatewaychecked
OANDAAccount Management Portal > My Services > Manage API Access, accept licence, generate personal access token.OANDA v20 Introductionchecked
PepperstoneAPI by application. You need a live Pepperstone account, then you email support to request one of two routes. The Standard API: once approved you generate an API key to connect your software. The FIX API: for account holders with a minimum trading volume of 160 million euro a month, or the local currency equivalent. The page publishes no protocol, documentation or eligibility test for the Standard API.Pepperstone API tradingchecked
Saxo OpenAPICreate a developer portal account for SIM (24 hour token or registered app); apply for live app credentials after testing.Saxo OpenAPI Learnchecked
SwissquoteSwissquote's APIs are presented on its institutional pages, which you reach by contacting a Swissquote office, not through a self service key. Three trading APIs are named there: a REST API on the OpenWealth standard for securities, cryptocurrencies and FX spot, a FIX API for securities and cryptocurrencies, and a dedicated FIX API for leveraged forex whose stated client types are corporates, banks and retail brokers. Separately, the platform comparison table on Swissquote's UK private client pages lists FIX API as a feature of the CFXD platform and not of MetaTrader 4 or MetaTrader 5, which carry Expert Advisors instead. That table does not say how a private client applies for FIX access.Swissquote institutional, securities and cryptos via an APIchecked
Trading 212On the web or in the app: menu, Settings, API (Beta), Generate API key. A risk warning must be accepted first. You then name the key, choose its permissions and choose whether to restrict it to given IP addresses. A key and a secret are issued, and the secret is shown once.Trading 212 help centre: Trading 212 API keychecked

Before you let code place a trade

None of this is advice about what to trade. It is the engineering care that automated orders need.

Common questions

Do I need to be a programmer to trade through an API?

No, but you need to be willing to learn a little. Reading your own positions takes a short script. The learning track on this site starts from no experience at all.

Is API trading free?

It depends on the broker. Some include API access with an ordinary account and some charge for it or require a minimum balance or volume. Check the access line on the broker's page here, which carries the source it was read from.

Can I test without risking money?

Usually, yes. Many brokers offer a demo environment for their API. Whether a demo key is available, and whether you need a live account first, differs by broker and is listed in the table above.

Is it safe to give an API key to a tool or a website?

Treat a key like the password to your account. Keep it in an environment variable on your own machine, never paste it into a website that is not your broker's, and prefer keys that can only read where a broker offers them. This site never asks for one.

What is the difference between a broker API and a platform API?

A broker API is built by one broker for its own accounts. A platform API, such as the MetaTrader or cTrader interface, belongs to trading software that many brokers offer, so code written for it can move between those brokers.

Where to go next

The whole learning track, or go straight to your broker, the other guides or a side by side comparison of two APIs.