REST API
Also known as: REST trading API, HTTP trading API, broker REST endpoint, RESTful API
What is it?
A REST API is the request-and-response interface a coded strategy uses to talk to a broker over ordinary HTTPS: your program sends a request to a URL, the broker acts on it and sends a JSON reply. It is one of three ways automation reaches the market. MT4 and MT5 native integration runs the strategy inside the platform, a FIX API speaks the institutional protocol banks and prime brokers use, and a REST API sits between them - open to any language that can make an HTTP call, documented like an ordinary web service, and available to a retail account without an institutional agreement.
How a bot places an order through a broker's REST API
-
1
The bot posts the order
Your program posts a JSON body naming the instrument, side, size and order type to the broker's orders endpoint, authenticated by an API token.
-
2
The broker validates and fills
It checks margin, size limits and trading permissions, routes the order to liquidity, and matches it at the best available price.
-
3
A JSON response returns the fill
The reply carries the order ID, the fill price and your remaining margin. Nothing arrives unless the bot asked for it.
Placing an order is a POST to an orders endpoint carrying the instrument, size and order type; the reply carries a fill price and an order ID. The cost is latency and shape. Every REST call is a full HTTP round trip, typically tens of milliseconds against a FIX session's single digits, and REST is request-driven rather than streaming, so price updates arrive because you asked rather than because they happened.
For a strategy holding positions for minutes or hours that difference is irrelevant; for one competing on fill priority it decides the outcome.
Why it matters: A REST API is the most accessible way to wire a custom bot to a broker, trading tens of milliseconds of latency for the freedom to code in any language.
The connector sets your round-trip latency and whether prices stream or are polled, which decides the shortest holding period a strategy can realistically trade.
Real-world example
A Python strategy places a EUR/USD market order by posting the instrument and 10,000 units to the broker's orders endpoint, then reads the fill price and order ID back from the JSON response about 60 milliseconds later.
How SignalBots handles it
SignalBots delivers signals over webhooks and platform connectors, so a custom bot can act on them through your broker's own REST endpoint without you building a market-data pipeline first.
Pro tip
Send a unique client order ID with every REST order request. If the response is lost to a timeout, that ID is what lets you check and retry without opening the position twice.
Common pitfalls
Polling prices in a tight loop instead of using the broker's streaming endpoint, which burns the request budget and gets the bot rate-limited exactly when the market is moving.
Frequently asked questions
How is a REST API different from a FIX API?
REST is a request-and-response web interface over HTTPS that is easy to code against in any language. FIX is a persistent streaming session using an institutional message protocol - faster, but far heavier to implement and usually gated behind volume requirements.
Do I need a REST API if I use MT4 or MT5?
No. An expert advisor runs inside the platform and places orders through its native functions. A REST API matters when the strategy lives outside the platform, in Python, C# or a web service.
Is REST fast enough for scalping?
For most retail scalping, yes; tens of milliseconds sits well inside a strategy holding trades for minutes. For latency-sensitive strategies competing on fill priority it is not, and FIX or a colocated setup is the answer.
How do I authenticate to a broker's REST API?
Usually with a bearer token you generate in the account portal and send in an HTTP header. Treat it as a credential with trading permissions: never commit it to a repository, and rotate it immediately if it is exposed.
What happens if a REST request times out?
You do not know whether the order was placed. Send a unique client order ID with each request, then query the order by that ID before retrying rather than sending it again. Your capital is at risk.
Trading involves substantial risk of loss. Historical and backtested results do not guarantee future performance. Read the full risk warning.