Quickstart
From an API key to a filled order, in about five minutes.
You need an API key (create one in the console),
an MT5 account number, its trading password, and the server name exactly as
MetaTrader shows it — VantageMarkets-Demo, ICMarkets-Demo. Use a demo
account the first time.
The investor password will not work. It can read an account but cannot trade, and the login succeeds — so the failure arrives later, as a rejected order.
Set your key
export FXAPIS_KEY="fx_live_7f3a9c21_your-secret-here"
export FXAPIS_API="https://api.fxapis.com"Keys are server-to-server credentials. Keep them out of browsers, apps and repositories. See Authentication.
Connect the account
curl -sS -X POST "$FXAPIS_API/v1/accounts" \
-H "Authorization: Bearer $FXAPIS_KEY" \
-H "Content-Type: application/json" \
-d '{
"login": "26177561",
"server": "VantageMarkets-Demo",
"password": "your-mt5-trading-password",
"mode": "warm_on_demand",
"label": "Demo — strategy A"
}'This stores the account and does not log in yet. The password is encrypted under a key bound to this one account and is never returned by any endpoint.
Bring it online
curl -sS -X POST "$FXAPIS_API/v1/accounts/$FXAPIS_ACCOUNT/warm" \
-H "Authorization: Bearer $FXAPIS_KEY"
until curl -sS "$FXAPIS_API/v1/accounts/$FXAPIS_ACCOUNT/status" \
-H "Authorization: Bearer $FXAPIS_KEY" | grep -q '"ready"'
do sleep 2; donewarm answers 202 at once — a terminal is starting and the broker has not
answered yet. It walks starting → connecting → synchronizing → ready, usually
in about ten seconds. Only ready accepts orders.
Place an order
curl -sS -X POST "$FXAPIS_API/v1/accounts/$FXAPIS_ACCOUNT/orders/market" \
-H "Authorization: Bearer $FXAPIS_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "symbol": "EURUSD", "side": "buy", "volume": "0.01" }'{
"data": {
"id": "b1c7…9e2a",
"symbol": "EURUSD",
"side": "buy",
"volume": "0.01",
"state": "filled",
"filledPrice": "1.13426",
"brokerOrderId": "2109584418"
}
}Volumes and prices are strings, never floats. Keep the Idempotency-Key if you
retry: the same key never places a second order. An order ends filled,
rejected, or unknown while it is reconciled against the broker — see
Trading.
Close it, and let the terminal go
curl -sS "$FXAPIS_API/v1/accounts/$FXAPIS_ACCOUNT/positions" -H "Authorization: Bearer $FXAPIS_KEY"
curl -sS -X POST "$FXAPIS_API/v1/accounts/$FXAPIS_ACCOUNT/positions/$POSITION_TICKET/close" \
-H "Authorization: Bearer $FXAPIS_KEY" -H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" -d '{}'A warm-on-demand terminal stops on its own after a quiet spell with no orders;
POST /cool stops it now. Stops and take-profits live at the broker and keep
working without a terminal.
If it does not reach ready
| State | Meaning | What to do |
|---|---|---|
invalid_credentials | The broker rejected the login | Fix the password and reconnect. Do not retry — repeated failures are how a broker locks an account. |
needs_2fa | The account requires a second factor | Not supported headlessly. Disable 2FA or use another account. |
needs_certificate | The broker requires a client certificate | Contact us. |
trading_disabled | Login worked, trading is off | Usually read-only credentials or a broker restriction. |
error | Something transient | Retryable. Warm it again. |