Broker Trading APIs: What a Retail Account Actually Gets

Search for a broker trading API and the results are almost all rankings. They compare brokers on deposits, instrument counts and spreads, and they describe REST, WebSocket and FIX as though every account came with a choice between them.

For most retail forex accounts none of that is true. What your account exposes to an outside program depends on which platform your broker runs, and the two most common answers are not variations on one idea. They are different architectures with different security consequences, and the one used by more retail traders than any other is not a network API at all.

Key takeaways

  • The MetaTrader 5 Python package is not a web service. It talks to a copy of the terminal on the same computer, so there is no endpoint and no API key.
  • Because it drives the terminal, it can reuse the account password already stored there, and that access cannot be scoped or revoked separately from the account.
  • cTrader Open API is a genuine server-side interface built on OAuth 2.0, with published token lifetimes and an application identity separate from the account.
  • Revocation is the practical difference: an application token can be withdrawn without touching the account, while terminal access cannot.
  • The FCA algorithmic trading rules are addressed to investment firms, not to a retail client running a script.
  • No deposit, spread, symbol count or rate limit appears here, because no figure of that kind in the sources reviewed was traceable to anything official.

What a Trading API Is, and What Most Retail Accounts Do Not Have

An application programming interface is simply a defined way for one program to ask another program to do something. In trading that usually means a program of yours asking for prices, or asking for an order to be placed, without a human clicking anything.

The rankings treat that as one product with several protocol flavours. It is more useful to ask a different question: where does the program you write actually connect to?

There are two answers in common use, and they are not close relatives. In one, your program connects to trading software installed on your own machine, and that software keeps its existing connection to the broker. In the other, your program connects to the broker’s servers directly, over the internet, holding a credential of its own.

Almost everything that matters afterwards follows from that split: whether a machine has to stay switched on, whether a credential exists that can be taken away, and what an attacker gets if your code is compromised.

The Terminal Route: Why the MetaTrader Python Package Is Not a Network API

MetaQuotes publishes a Python package for MetaTrader 5, installed with pip, and it is the route most retail traders reach for. Its documentation is specific about how it works, and the detail is easy to skim past.

The package does not call a web service. It exchanges data with the MetaTrader 5 terminal on the same computer, using communication between processes rather than a network request. There is no hostname to connect to, no endpoint to call and no API key to issue, because nothing is being authenticated across a network in the first place.

That shows in the first function you call. Initialising the connection takes the file path of the terminal executable, and if you do not supply one the package goes looking for the installed program itself. You can pass an account number, a password and a server name, but you do not have to: MetaQuotes documents that where no password is given, the one already saved in the terminal for that account is used automatically.

Read that again, because it is the sentence with consequences. Your script does not hold a credential you granted it. It borrows the credential the terminal is already holding.

What the package can do is broad. Its documented functions cover account and terminal information, symbol lists and individual symbol data, the last tick, market depth subscriptions, historical bars and ticks, pending orders, margin and profit calculations, an order check, order submission, open positions, and order and deal history.

That is a full trading surface. It just reaches it through a program on your desk rather than through a server, and it needs both the terminal and the machine running to do any of it. If you are weighing the platforms themselves, the terminal differences are set out in what separates MT4 from MT5.

The Server Route: What an OAuth Token Actually Grants

cTrader takes the opposite approach. Spotware, which builds the platform, publishes an Open API that anyone holding a cTrader ID can use to build an application talking to the cTrader backend, and its documentation states the service is available to anyone registered with a broker offering the platform.

Messages travel as JSON or as Google Protocol Buffers, so the language you write in is your own choice. Who builds cTrader and what the broker controls is covered in what cTrader is and who builds it.

The part worth understanding is the authorisation, because it is where this model differs most.

Access runs on OAuth 2.0. The user is sent to a page where they grant your application permission, and the application receives a short-lived authorisation code, which Spotware documents as expiring after one minute. That code is exchanged for an access token, documented with a lifetime of 2,628,000 seconds, which is roughly thirty days. When it expires a refresh token issues a new one, and the refresh token itself carries no expiry.

There is a second identity in play as well. Before an application can act on any account it authenticates itself, sending its own client identifier and secret, and only then asks which trading accounts the user’s token covers.

So there are two separate things here: the application, which the broker’s platform knows about, and the permission a specific user has given it. Neither of them is the account password.

Two Security Models, and What Each One Puts at Risk

Put the two side by side and the difference stops being a technical footnote.

QuestionTerminal routeServer route
What the code connects toSoftware on the same machineThe platform backend, over the internet
What it authenticates withThe credential the terminal already holdsA token granted to a named application
Can access be withdrawn on its ownNo, not without changing the account passwordYes, by revoking the token
Does it expire by itselfNoYes, on a published schedule
Does a machine have to stay onYes, the terminal must be runningOnly wherever the code itself runs

The revocation row is the one to weigh. If a script on the terminal route is compromised, the attacker has whatever the terminal has, and the only way to cut that off is to change the account password, which stops every other tool at the same time. On the server route the permission is a separate object and can be withdrawn on its own.

What Happens to an Open Position When Your Code Stops

This question is missing from every ranking, and it has a clear answer.

An open position lives on the broker’s server. It is a record there, not in your program, so a crashed script, a closed terminal or a dead internet connection does not close it. It also does not close a stop or a take-profit that you attached to the position, because those were sent to the server too.

What does disappear is anything that existed only inside your code. A rule that would have closed the trade at a certain time, a level your script was watching in order to move a stop, an exit that had not yet been submitted as an order: none of these exist anywhere except in the running program. When the program stops, they stop.

That is the practical argument for putting protective orders on the server rather than in your logic, and it applies identically to both routes.

Keeping the whole setup running without depending on your own machine is a separate subject, covered in keeping a strategy running around the clock, and this page does not repeat it. Where several automated programs share one account, the interference problem is set out in running several expert advisors at once.

Who the Algorithmic Trading Rules Actually Bind

Two of the pages reviewed for this article carry a section on regulation. Neither names a regulator, a rule or a person the rule applies to. The rulebook is public, so the question can be settled rather than gestured at.

In the United Kingdom the relevant chapter is MAR 7A of the FCA Handbook. Its application rule names two kinds of firm: a UK MiFID investment firm, and a third country investment firm, provided it maintains an establishment in the United Kingdom. Three activities are then caught: algorithmic trading; the service of giving a client direct electronic access to a trading venue; and the service of acting as general clearing member to another person.

Every obligation that follows is written to the firm. The systems and controls rule requires a firm to keep its trading systems resilient and adequately sized, subject to appropriate thresholds and limits, unable to send erroneous orders or otherwise contribute to a disorderly market, and incapable of being used in breach of the market abuse regime or of a trading venue’s own rules.

A retail client running a script at home is not the addressee of any of that. Nor is a retail spot forex or contracts-for-difference account direct electronic access to a trading venue, because the orders go to the broker rather than to an exchange.

None of which means a retail trader has no responsibilities. They are simply contractual rather than regulatory: an order sent by your program is your order, and the client agreement, not the Handbook, is where the consequences of one sent in error are written down.

The Numbers Every Comparison Page States and No Source Supports

The rankings reviewed for this page share one feature. Their figures come from nowhere.

Minimum deposits, tradeable symbol counts, average spreads, proprietary broker scores, request limits per minute, and the share of market volume said to be automated are all stated flatly, with no citation to the broker, the exchange or any regulator. One page gives three different instrument counts for the same broker in three places without reconciling them.

That is why no figure of that kind appears here. Under the evidence rule this site works to, a figure that cannot be traced to an official source does not go on the page at all, and a number repeated by several competitors is not evidence of anything except that they read each other.

The two figures this page does state, the one-minute authorisation code and the thirty-day access token, are published by the company that operates the platform and were read at its documentation on the date given below. If your broker documents something different, the broker is the authority for its own service.

Who This Page Is Not For

Anyone expecting programmatic access to improve results. It changes how an instruction is delivered, not whether the instruction was any good, and a strategy that loses money by hand loses it faster automatically.

Anyone who has not tested the logic. Sending live orders from code that has never been examined against historical data is an expensive way to discover an error, and the ground rules are in testing a strategy before it trades money.

Anyone choosing a broker on the strength of an API listing alone. The interface is one property of an account among many, and it says nothing about pricing, execution or which regulated entity holds the money.

Frequently Asked Questions

Does a MetaTrader account come with a trading API?

Not in the sense the comparison pages mean. MetaQuotes publishes a Python package, but it communicates with the MetaTrader 5 terminal on the same computer rather than with a server over the internet, so there is no endpoint and no key. Server-side interfaces for the platform are licensed to brokers rather than issued to clients.

What is the difference between the MetaTrader Python package and a REST API?

A REST interface is a web service your program calls across a network using a credential issued to it. The Python package is a local bridge to installed software, so it needs the terminal running on the same machine and it uses the credentials that terminal already holds.

How long does a cTrader Open API access token last?

Spotware documents the access token as lasting 2,628,000 seconds, which is about thirty days, and the authorisation code exchanged for it as expiring after one minute. The refresh token used to obtain a new access token is documented without an expiry date.

Do algorithmic trading regulations apply to a retail trader?

The FCA chapter on algorithmic trading is addressed to investment firms, not to individual clients, and a retail forex or contracts-for-difference account is not direct electronic access to a trading venue. Responsibility for an order a program sends still rests with the account holder under the client agreement.

What happens to an open trade if my script crashes?

It stays open, because the position and any stop or target attached to it are held on the broker server rather than in your program. What is lost is any exit that existed only as logic inside the code and had never been submitted as an order.

Sources checked 6 August 2026: MetaQuotes, MQL5 Reference, Python Integration section and its initialize page, for the package installed with pip, the exchange of data with the terminal on the same computer, the terminal executable path, the automatic use of the password stored in the terminal, and the documented function list. Spotware, cTrader Open API documentation, getting started and account authentication pages, for availability to holders of a cTrader ID at an affiliated broker, JSON and Protocol Buffers messaging, the one-minute authorisation code, the 2,628,000-second access token, the non-expiring refresh token, and the separate application authentication step. Financial Conduct Authority, FCA Handbook MAR 7A, for the firms the chapter applies to, the three activities it catches, and the systems and controls obligations placed on a firm. No broker minimum deposit, spread, symbol count, request limit or market-share percentage appears on this page: every figure of that kind found during research was published without a traceable source.

Disclaimer: This article is educational only and is not investment advice, and nothing here recommends automating any strategy. Platform capabilities, documentation and access conditions change, and what a particular broker exposes differs between firms and between regulated entities of the same firm, so check the current documentation for your own account. Leveraged trading carries risk and the sum at stake can be lost in full.

Leave A Reply

Your email address will not be published.