# FOREX.com and City Index API

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/brokers/forex-com-city-index, written from the same records as that page.

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.

StoneX (formerly GAIN Capital) REST trading API shared by FOREX.com and StoneX Trading, the new UK name for City Index since 9 Sep 2026.

- Kind: Broker API
- Newest reading: 2026-10-12
- Official documentation: [docs.labs.gaincapital.com](https://docs.labs.gaincapital.com/)
- Everything recorded for FOREX.com / StoneX Trading (City Index), as one JSON file: https://openbrokerapi.com/data/brokers/forex-com-city-index.json

## FOREX.com API rate limits and allowances

One record per limit. The scope is part of the limit: a figure without its scope is not a figure you can pace against.

- Request throttle: 500 requests per 5 s, HTTP 429 above it
  - Scope: Requests from one client application. The page does not say whether the count is per session, per AppKey or per IP address
  - Status: verified. Source: [docs.labs.gaincapital.com](https://docs.labs.gaincapital.com/Content/Getting%20Started/CIAPI%20Basics.htm), checked 2026-10-12.
  - Note: After a 429 the client must wait 1 second before sending more requests. The window is 5 seconds, which a single unit cannot state, so the figure stays as wording.

[FOREX.com API rate limits in full](https://openbrokerapi.com/brokers/forex-com-city-index/rate-limits), with the related error codes.

## Access, authentication and streaming

- How you get a key: Open and fund a standard account, then request API access from support; an AppKey is emailed if accepted.
  - Status: verified. Source: [FOREX.com API Trading](https://www.forex.com/en/trading-tools/api-trading/), checked 2026-09-21.
- Who can use it: By application: you must describe your expertise, language, goal and expected volume, and sign API terms.
  - Status: verified. Source: [StoneX API Getting Started](https://docs.labs.gaincapital.com/Content/Getting%20Started/Getting%20Started.htm), checked 2026-09-21.
- Demo: Partial: the StoneX API documentation describes two environments, Live and Pre-Production, each with its own API and streaming address. It says most users work on Live and that only some users, depending on user type and circumstances, are given Pre-Production access. An account in one environment is not recognised in the other. The documentation does not say that a retail demo account can use the API.
  - Status: verified. Source: [StoneX API documentation, Getting Started](https://docs.labs.gaincapital.com/Content/Getting%20Started/Getting%20Started.htm), checked 2026-10-12.
- Authentication: A session token. POST your user name, password and the AppKey you were issued to /v2/Session, then send the returned session token and your user name with every request as the request headers Session and UserName. Passing them in the query string is marked obsolete. The documentation says a token is valid for at least 20 minutes, and an expired one is signalled by HTTP 401. Subscribing to the streams uses the user name and the session token as its credentials.
  - Status: verified. Source: [StoneX API documentation, API basics](https://docs.labs.gaincapital.com/Content/Getting%20Started/CIAPI%20Basics.htm), checked 2026-10-12.
  - Status: verified. Source: [StoneX API documentation, LogOn v2](https://docs.labs.gaincapital.com/Content/HTTP%20Services/LogOn%20v2.htm), checked 2026-10-12.
- Streaming: Lightstreamer, a third party streaming protocol, over long lived HTTP connections and not WebSocket as documented. Streams cover prices, news headlines, client account margin, orders and quotes, grouped into adapters. Each adapter needs one HTTP connection plus one control connection. The documentation says the servers still run Lightstreamer 7.4.1 and that clients should use that version of the Lightstreamer SDK.
  - Status: verified. Source: [StoneX API documentation, architecture](https://docs.labs.gaincapital.com/Content/Getting%20Started/CIAPI%20Arky.htm), checked 2026-10-12.
- History depth: Price bars: max 4,000 per request (default 1,000). Trade history: max 200 results per call, filter by from date.
  - Status: verified. Source: [GAIN Capital API docs: GetPriceBarsBeforeDate](https://docs.labs.gaincapital.com/Content/HTTP%20Services/GetPriceBarsBeforeDate.htm), checked 2026-09-22.
- Rate limits, as worded: The StoneX API documentation says the servers throttle a client application that sends more than 500 requests in a 5 second window. A throttled request gets HTTP 429, and the client must then wait 1 second before sending more. It names requests for market information and for price history as the usual causes. FOREX.com's own API page answered 403 Forbidden on 12 Oct 2026 and was not re-read.
  - Status: verified. Source: [StoneX API documentation, API basics, throttling](https://docs.labs.gaincapital.com/Content/Getting%20Started/CIAPI%20Basics.htm), checked 2026-10-12.

## Platform APIs an account here can reach

- [MetaTrader 4 (MQL4)](https://openbrokerapi.com/platforms/metatrader-4): offered. MT4 on desktop, web and mobile. Expert Advisors allowed ('Expert Advisors (EAs) are programs that can be used to automate trading'); only one EA per chart; EA hosting/VPS for qualifying clients.
  - Status: verified. Source: [FOREX.com UK trading platforms](https://www.forex.com/en-uk/trading-platforms/), checked 2026-09-18.
- [MetaTrader 4 (MQL4)](https://openbrokerapi.com/platforms/metatrader-4): offered. City Index UK pages now redirect to stonex.com/en-gb. MT4 offered with Expert Advisors from FX Blue (nine EAs).
  - Status: verified. Source: [StoneX Trading MetaTrader 4](https://www.stonex.com/en-gb/trading-platforms/metatrader-4/), checked 2026-09-18.
- [MetaTrader 5 (Python package and MQL5)](https://openbrokerapi.com/platforms/metatrader-5): not verified. MT5 not listed on FOREX.com UK or StoneX Trading UK platforms pages; the FOREX.com UK MT5 URL returned HTTP 429 so could not be checked.
  - Status: unverified. Source: [StoneX Trading UK platforms](https://www.stonex.com/en-gb/trading-platforms/), checked 2026-09-18.
- [cTrader Open API](https://openbrokerapi.com/platforms/ctrader): not offered. cTrader not listed on the broker's UK platforms page; absence from an overview page is not proof, so unverified.
  - Status: unverified. Source: [FOREX.com UK trading platforms](https://www.forex.com/en-uk/trading-platforms/), checked 2026-09-18.
- [TradeLocker API](https://openbrokerapi.com/platforms/tradelocker): not offered. TradeLocker not listed on the broker's UK platforms page; absence from an overview page is not proof, so unverified.
  - Status: unverified. Source: [FOREX.com UK trading platforms](https://www.forex.com/en-uk/trading-platforms/), checked 2026-09-18.
- [Match-Trader Platform API](https://openbrokerapi.com/platforms/match-trader): not offered. Match-Trader not listed on the broker's UK platforms page; absence from an overview page is not proof, so unverified.
  - Status: unverified. Source: [FOREX.com UK trading platforms](https://www.forex.com/en-uk/trading-platforms/), checked 2026-09-18.
- [DXtrade APIs](https://openbrokerapi.com/platforms/dxtrade): not offered. DXtrade not listed on the broker's UK platforms page; absence from an overview page is not proof, so unverified.
  - Status: unverified. Source: [FOREX.com UK trading platforms](https://www.forex.com/en-uk/trading-platforms/), checked 2026-09-18.

## FOREX.com API SDKs and wrappers

- pygcapi (Python, Community)
  - Status: unverified. Source: [github.com](https://github.com/athammad/pygcapi), no checked date recorded.
- forexcom (Python, Community): Community package, last release 1.2.0 in June 2022.
  - Status: verified. Source: [pypi.org](https://pypi.org/project/forexcom/), checked 2026-09-18.

## FOREX.com API: questions and answers

### Does FOREX.com have an API?

This register records FOREX.com as having its own API (REST and Streaming), with availability marked as restricted. StoneX (formerly GAIN Capital) REST trading API shared by FOREX.com and StoneX Trading, the new UK name for City Index since 9 Sep 2026.

- Status: verified. Source: [StoneX API documentation host](https://docs.labs.gaincapital.com/), checked 2026-09-20.

### FOREX.com API key: how do I get one?

Open and fund a standard account, then request API access from support; an AppKey is emailed if accepted.

- Status: verified. Source: [FOREX.com API Trading](https://www.forex.com/en/trading-tools/api-trading/), checked 2026-09-21.

### Who can use the FOREX.com API?

By application: you must describe your expertise, language, goal and expected volume, and sign API terms.

- Status: verified. Source: [StoneX API Getting Started](https://docs.labs.gaincapital.com/Content/Getting%20Started/Getting%20Started.htm), checked 2026-09-21.

### FOREX.com API demo: is there a demo or sandbox?

Partial: the StoneX API documentation describes two environments, Live and Pre-Production, each with its own API and streaming address.

- Status: verified. Source: [StoneX API documentation, Getting Started](https://docs.labs.gaincapital.com/Content/Getting%20Started/Getting%20Started.htm), checked 2026-10-12.

### What are the FOREX.com API rate limits?

Request throttle: 500 requests per 5 s, HTTP 429 above it. Scope: Requests from one client application. The page does not say whether the count is per session, per AppKey or per IP address. As the record words it: The StoneX API documentation says the servers throttle a client application that sends more than 500 requests in a 5 second window. A throttled request gets HTTP 429, and the client must then wait 1 second before sending more.

- Status: verified. Source: [docs.labs.gaincapital.com](https://docs.labs.gaincapital.com/Content/Getting%20Started/CIAPI%20Basics.htm), checked 2026-10-12.

### How does FOREX.com API authentication work?

A session token. POST your user name, password and the AppKey you were issued to /v2/Session, then send the returned session token and your user name with every request as the request headers Session and UserName.

- Status: verified. Source: [StoneX API documentation, API basics](https://docs.labs.gaincapital.com/Content/Getting%20Started/CIAPI%20Basics.htm), checked 2026-10-12.
- Status: verified. Source: [StoneX API documentation, LogOn v2](https://docs.labs.gaincapital.com/Content/HTTP%20Services/LogOn%20v2.htm), checked 2026-10-12.

### Does the FOREX.com API support streaming?

Lightstreamer, a third party streaming protocol, over long lived HTTP connections and not WebSocket as documented. Streams cover prices, news headlines, client account margin, orders and quotes, grouped into adapters.

- Status: verified. Source: [StoneX API documentation, architecture](https://docs.labs.gaincapital.com/Content/Getting%20Started/CIAPI%20Arky.htm), checked 2026-10-12.

### How much history does the FOREX.com API return?

Price bars: max 4,000 per request (default 1,000). Trade history: max 200 results per call, filter by from date.

- Status: verified. Source: [GAIN Capital API docs: GetPriceBarsBeforeDate](https://docs.labs.gaincapital.com/Content/HTTP%20Services/GetPriceBarsBeforeDate.htm), checked 2026-09-22.

### Is there a Python library for the FOREX.com API?

This register lists these Python libraries for the FOREX.com API. pygcapi (community, Python). forexcom (community, Python): Community package, last release 1.2.0 in June 2022.

- Status: verified. Source: [forexcom](https://pypi.org/project/forexcom/), checked 2026-09-18.

### Which platform APIs work with an account at FOREX.com?

Recorded as offered, with a source: MetaTrader 4. Not verified either way: MetaTrader 5, cTrader, TradeLocker, Match-Trader and DXtrade.

- Status: verified. Source: [FOREX.com UK trading platforms](https://www.forex.com/en-uk/trading-platforms/), checked 2026-09-18.

[FOREX.com API questions, each answered in a sentence or two](https://openbrokerapi.com/answers/forex-com-city-index).

## Partner programme

Published figure, as the page words it: $300 for each account you referred to us that has deposited a minimum of >$300. [The StoneX (FOREX.com and City Index) partner programme record](https://openbrokerapi.com/partners/forex-com-city-index). This site carries no affiliate links.

## Licence and how to cite

The limit records on this page come from the limits register, which is CC BY 4.0 (https://openbrokerapi.com/data/limits.json). Everything else on it comes from records that are all rights reserved. This file is the page itself, at its own address, in another format, and it is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data.

Cite as: FOREX.com and City Index API. Broker API Hub, https://openbrokerapi.com/brokers/forex-com-city-index, newest check 2026-10-12.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
