What are APIs?
An Application Programming Interface (API) is a kind of coding (or set of codes) that is used to enable connections – or, transactions – between software applications, databases, operating systems, and servers.
One side of the transaction (usually known as the client) will send a request to access the data or features of an API-connected application or database. This request is received by the second party’s API (usually known as the server), which then either allows or denies the request based on a predefined set of rules (these are known as the API specifications).
What is a Trading API?
When trading forex, CFDs, and other financial instruments, trading APIs allow a user’s front-end system to connect to the broker’s back-end system through an encrypted communication channel. Practically speaking, this means that traders who utilize APIs are not committed to using the application or platform supplied by their broker. Instead, traders have the option to use third-party software or their own custom platform or app while remaining connected to their forex broker’s trading ecosystem.
Unlike a read-only API – which doesn’t permit trading or account operations – a trading API provides full access, allowing you to trade your brokerage account programmatically. Trading APIs provide the ability to send and cancel orders, retrieve live prices and historical data, and access account details such as balances and current market prices. APIs can even link traders’ automated trading algorithms to their forex broker’s platform (check out our guide to high-frequency trading to read more about algo trading and automated HFT algorithms).
Some API connections can be as rudimentary as a few lines of code or an excel spreadsheet, while others may be a fully-fledged trading platform.
MetaTrader, the wildly popular forex trading platform, is a well-known example of a third-party software suite that connects to your forex broker by API. Read our MetaTrader guide to learn more about the platform, and check out our MetaTrader 5 guide to get an in-depth look at the newest version of the MetaTrader software.
Pros and cons of using trading APIs
- Live market data and executable prices.
- Historical market data and prices, allowing API users to analyze markets and chart client sentiment.
- Risk management tools and features, such as stop-loss and take-profit limits.
- Immediate execution and instant confirmation, so orders can be carried out through their own trading platform.
- Trades can be carried out anonymously without being recorded on the broker’s platform.
- API trading requires development time and ongoing maintenance, which can be costly.
- Generally speaking, programming knowledge and skills are required. The extent of this skill requirement will depend on your forex broker.
- Connecting an API can open the door for hackers to attack the application, hampering the security of the site – yet another reason to only use trusted, regulated brokers, even when using APIs for trading. Learn more about how to determine which forex brokers are trustworthy on our Trust Score page.
Which forex broker has the best API?
Most forex brokers that offer automated trading provide some form of API connectivity. We've evaluated trading APIs from the best forex brokers in the industry, and determined which of those offerings stand out as exceptional. Read about our top picks for the best forex brokers for trading APIs:
FXCM is our top choice for API trading. Four APIs are available, including REST, JAVA, FIX, and its ForexConnect proprietary software development kit (SDK).
FXCM’s ForexConnect provides access to a rich variety of trading API features, such as forex robots and automated trading systems, integrated trading data and pricing histories, and the ability to connect to custom trading platforms. ForexConnect supports a wide range of popular programming languages, such as Python, Java, C#, Visual Basic, and C++.
FXCM also offers a plethora of public resources to aid your coding projects, including dedicated Python packages that can be installed from the command line using Python, as well as open-source code for its public APIs on its GitHub page. Read our full-length review of FXCM.
Runner Up: OANDA
OANDA is another excellent choice for API trading, due to its robust documentation and the resources available in its developer portal. Three APIs are available: FIX, MT4, and the versatile v20 REST API.
OANDA’s v20 REST API grants access to a range of commonly sought-after trading API features, such as account management, historical pricing data and real-time trading rates, and the ability to place, modify, and close orders. You can read the full list of supported functions and features on OANDA’s developer page.
Like FXCM, OANDA has plenty of resources on its GitHub page, with public open-source code repositories to complement its API offering. Check out our full-length review of OANDA.
Podium Finisher: Interactive Brokers
Interactive Brokers offers a comprehensive API offering. Trader Workstation (TWS) is Interactive Brokers’ proprietary, open-source API, and traders can connect to Interactive Brokers’ trading system via FIX API.
Interactive Brokers’ TWS API delivers a powerful assortment of API features and functions. Traders can place orders, view positions, monitor portfolios, and automate trading strategies. TWS provides the ability to connect custom applications or platforms, and it supports a range of programming languages, such as Python, C#, C++, and Java.
Learn more about Interactive Brokers' API offerings on the IBKR Trading APIs site, and read our full-length review of Interactive Brokers.
What forex brokers have APIs?
Nearly all forex brokers that offer automated trading provide API connectivity, and even brokers that do not offer algorithmic trading may provide an API for public access. We've put together a list of the best forex brokers that provide free public API access:
- FXCM - FXCM’s ForexConnect API is a favorite of ours, due to its rich variety of supported functions. Also available at FXCM are industry-standard REST and FIX APIs, as well as the Java API (a wrapper SDK for FIX API).
- OANDA - OANDA’s API offering includes its v20 REST API, as well as standard FIX API support and API connection to MetaTrader 4 (MT4). Read more about OANDA’s API solutions on OANDA’s developer site.
- Interactive Brokers - Interactive Brokers’ Trader Workstation (TWS) is the broker’s proprietary, open-source API, which allows for connectivity to IBKR’s trading systems via FIX API. Read more about TWS on IBKR’s Trading APIs site.
- Saxo Bank - Saxo Bank’s REST OpenAPI powers nearly every end-user platform provided by the broker, and allows traders to build portfolio analysis tools, native applications, and use third-party apps. Learn more at Saxo Bank’s OpenAPI Developer Portal.
- IG - Available via its IG Labs site, IG's standard REST API and Streaming API provide access to the IG ecosystem - all you need is an IG account to get started.
- FOREX.com - FOREX.com’s REST API allows traders to execute trades, manage accounts, gather historical data for technical analysis, and code using popular programming languages like C++ and Python. Learn more at FOREX.com’s API Trading page.
- TD Ameritrade - TD Ameritrade supports a variety of API methods and functions, such as standard CRUD operations and an XML-based API. Learn more at TD Ameritrade’s Developer site.
Some forex brokers reserve their APIs for institutional clients, and some may require that you meet a certain balance threshold or trading volume requirement in order to be eligible for API access.
How do I connect a forex API to a broker?
- Read your forex broker’s API documentation (or, API specifications) to understand the specific API connection requirements. It’s also important to read up on the available software development kits (SDKs) and on any supported programming languages.
- Next, you’ll need to make sure you have a demo or live account registered with your forex broker – you’ll need this to connect programmatically.
- Request API access. Once registered, you'll receive your API key (make sure to keep this safe) – this will allow you to securely connect and access the API.
- Once you’ve successfully connected to the API, you’ll likely need to debug and/or troubleshoot your code (or the third-party program you are connecting).
- After handling any necessary troubleshooting, you can start using basic commands, such as accessing account balances and viewing live market data. Then, move on to more complex operations such as order and trade management.
keyDon't lose your (API) keys
Connecting with a third-party program will require that you enter your API keys. API keys are passwords that let you access your account, much like the username and password required to log into your forex broker’s software. Make sure to keep your API keys as secure and protected as you would any password(s) for your brokerage account.
ForexBrokers.com 2023 Overall Rankings
Now that you've seen our picks for the top seven brokers for trading APIs, check out the ForexBrokers.com Overall Rankings for forex brokers. We've evaluated over 60 forex brokers, using a testing methodology that's based on 100+ data-driven variables and thousands of data points. Check out our full-length, in-depth forex broker reviews.
Here are our 2023 Overall Rankings for all 62 online brokers that we have reviewed and tested (read more about how we test):
Popular Forex Guides
At ForexBrokers.com, our evaluations of online brokers and their products and services are based on our collected quantitative data as well as the qualitative observations and qualified opinions of our expert researchers. Each year we publish tens of thousands of words of research on the online forex brokerage industry, and we evaluate dozens of international regulator agencies (learn more about how we calculate Trust Score).
When assessing the best forex brokers for trading APIs, we conduct extensive research on a wide variety of API services, connections, and interfaces across the forex industry and evaluate each broker’s offerings based on a range of factors. Our research team also examines all publicly available API documentation in online broker resource portals and in GitHub repositories.
All web-based platforms are tested using the latest version of the Google Chrome browser. Our Desktop PCs run Windows 11, and we use MacBook Pro laptops running macOS 12.5 to test trading APIs on the go. We also test on mobile devices; for Apple, we test using the iPhone XS running iOS 15, and for Android we use the Samsung Galaxy S9+ and Samsung Galaxy S20 Ultra devices running Android OS 12.
Ultimately, our rigorous data validation process yields an error rate of less than .1% each year, providing site visitors with quality data they can trust. Click here to learn more about how we test.
Forex Risk Disclaimer
There is a very high degree of risk involved in trading securities. With respect to margin-based foreign exchange trading, off-exchange derivatives, and cryptocurrencies, there is considerable exposure to risk, including but not limited to, leverage, creditworthiness, limited regulatory protection and market volatility that may substantially affect the price, or liquidity of a currency or related instrument. It should not be assumed that the methods, techniques, or indicators presented in these products will be profitable, or that they will not result in losses. Read more on forex trading risks.
About the Editorial Team
Steven Hatzakis is the Global Director of Research for ForexBrokers.com. Steven previously served as an Editor for Finance Magnates, where he authored over 1,000 published articles about the online finance industry. A forex industry expert and an active fintech and crypto researcher, Steven advises blockchain companies at the board level and holds a Series III license in the U.S. as a Commodity Trading Advisor (CTA).
John Bringans is the Senior Editor of ForexBrokers.com. An experienced media professional, John has close to a decade of editorial experience with a background that includes key leadership roles at global newsroom outlets. He holds a Bachelor’s Degree in English Literature from San Francisco State University, and conducts research on forex and the financial services industry while assisting in the production of content.
Blain Reinkensmeyer has 20 years of trading experience with over 2,500 trades placed during that time. He heads research for all U.S.-based brokerages on StockBrokers.com and is respected by executives as the leading expert covering the online broker industry. Blain’s insights have been featured in the New York Times, Wall Street Journal, Forbes, and the Chicago Tribune, among other media outlets.
TD Ameritrade, Inc. and StockBrokers.com are separate, unaffiliated companies and are not responsible for each other’s services and products.