Mile Global Markets API documentation

Build trading apps on Mile Global Markets: REST for accounts and contracts, and WebSockets for real-time trading and prices. Your users approve your app with OAuth 2.0, and you earn a markup on every trade they place.

Getting started

New to the API? Start with these.

API endpoints

Everything the API does, by area.

REST

OAuth 2.0

Authorization code flow with mandatory PKCE (S256). The authorize endpoints are browser pages; only the token endpoint is called by your server.

Explore
REST

Developer apps

Register and manage OAuth apps, and read and claim app earnings. Intended for the app owner's signed-in browser session (the Developer apps page); these routes also accept the owner's API token.

Explore
REST

API tokens

Personal API tokens for the signed-in user. OAuth-issued tokens for that user also appear here and can be deleted here.

Explore
REST

Account and balances

The user's profile, options accounts (wallets) and multi-currency transfers. Account ids (loginid) are MP followed by 10 hex characters for real accounts and VR followed by 10 hex characters for demo accounts.

Explore
REST

Contracts (REST trading)

Price, place and list contracts over REST. Trades placed with an OAuth-issued token are attributed to that token's app, and a real USD trade carries the app's markup in its price. Digit contracts: even, odd, match, differ, over, under (synthetic indices only). Price contracts: rise, fall (any instrument). Amounts are integer minor units (cents) of the account currency.

Explore
REST

Market data (public)

Read-only prices with no authentication and CORS open to any origin (Access-Control-Allow-Origin: *). /api/v1/quotes covers the platform's own instruments (synthetic indices plus display-only real-feed prices). /api/v1/markets/* is the MT5 trade server's symbol catalog.

Explore
WEBSOCKET

Trading gateway

Authorize, price, buy and follow contracts in real time.

Explore
WEBSOCKET

Price feed

Live ticks for every market, no sign-in needed.

Explore

Introduction

Overview

ProductionTesting
RESThttps://api.miletrades.sitehttps://stg-backend.miletraders.com
Trading gatewaywss://api.miletrades.site/ws/v1wss://stg-backend.miletraders.com/ws/v1
Price feedwss://api.miletrades.site/api/v1/feed/wswss://stg-backend.miletraders.com/api/v1/feed/ws

All requests and responses are JSON. Money amounts on REST are in cents unless a field says otherwise. Connect WebSockets to the API origin directly. Build and test against the testing environment first: it gets new endpoints before production does.

Quickstart

  1. 1Register an app with its redirect URLs and the scopes it needs. You get an 8-digit app_id.
  2. 2Send the user through OAuth 2.0 with PKCE and exchange the code for an access token.
  3. 3Call REST with Authorization: Bearer mp_…, or open the gateway and send {"authorize": "mp_…"}.
  4. 4Get a price proposal, buy, and follow the contract until it settles.
Trade over the gateway (JavaScript)
const ws = new WebSocket("wss://api.miletrades.site/ws/v1");

ws.onopen = () => ws.send(JSON.stringify({ authorize: "mp_USER_TOKEN" }));

ws.onmessage = (ev) => {
  const msg = JSON.parse(ev.data);
  if (msg.error) return console.error(msg.error.code, msg.error.message);

  switch (msg.msg_type) {
    case "authorize":
      ws.send(JSON.stringify({
        proposal: 1, req_id: 1,
        contract_type: "DIGITOVER", symbol: "volatility_100", amount: 1, barrier: 4
      }));
      break;
    case "proposal":
      ws.send(JSON.stringify({ buy: msg.proposal.id, price: msg.proposal.ask_price, req_id: 2 }));
      break;
    case "buy":
      ws.send(JSON.stringify({ proposal_open_contract: msg.buy.contract_id, subscribe: 1, req_id: 3 }));
      break;
    case "proposal_open_contract":
      if (msg.proposal_open_contract.is_sold) {
        console.log(msg.proposal_open_contract.status, msg.proposal_open_contract.profit);
      }
      break;
  }
};

Introduction

Authentication

Third-party apps get a scoped API token for a user through OAuth 2.0 authorization code with PKCE (S256). A user can also create personal API tokens. Both kinds are the same mp_ token. Tokens authenticate REST calls and the /ws/v1 gateway (via the authorize call).

Presenting a token

  • REST: Authorization: Bearer mp_... header (the scheme is matched as "Bearer " or "bearer ").
  • REST (alternative): ?token=mp_... query parameter. Works, but puts the secret in URLs; prefer the header.
  • Gateway /ws/v1: Send {"authorize": "mp_..."} as the first message. Only API tokens are accepted here, not browser session tokens.
  • Price feed /api/v1/feed/ws: ?token=mp_... on the connection URL (or the browser session cookie).

Token formats

  • mp_ API access token. 24 random bytes, base64url. Only a SHA-256 hash is stored. Does not expire; valid until deleted.
  • mps_ App secret, shown once at registration. Not used by any current endpoint (the token exchange does not take it).
  • mpc_ OAuth authorization code. One-time use, expires 5 minutes after issue.
  • (none) app_id: 8-digit numeric string, for example "10482736".

OAuth 2.0 with PKCE

1. Create a code verifier and its S256 challenge. 2. Send the user to /api/v1/oauth/authorize. 3. They approve on our consent page and come back to your redirect_uri with a code. 4. Exchange it at /api/v1/oauth/token from your server.

PKCE (browser or Node)
function base64url(bytes) {
  return btoa(String.fromCharCode(...new Uint8Array(bytes)))
    .replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
}
const verifier = base64url(crypto.getRandomValues(new Uint8Array(32)));
const challenge = base64url(
  await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier))
);
app_idRequiredstringin query

Your 8-digit app_id.

redirect_uriRequiredstringin query

Must exactly equal one of the app's registered redirect_uris.

code_challengeRequiredstringin query

base64url(SHA-256(code_verifier)) with no padding.

code_challenge_methodOptionalstringin query

Only S256 is accepted. May be omitted; the challenge is always verified as S256.

response_typeOptionalstringin query

Only code is accepted. May be omitted.

scopeOptionalstringin query

Space or comma separated. Must be a subset of the app's registered scopes. Defaults to all of the app's scopes.

stateOptionalstringin query

Opaque value echoed back on the redirect. Use it for CSRF protection.

The server renders an HTML consent page listing the requested scopes. If the browser has no session on the API origin, the page asks for email and password. Approving POSTs the form back to /api/v1/oauth/authorize.

Approved
https://example.com/callback?code=mpc_EXAMPLEauthCode000000000000000&state=Xy7pQ2
Denied
https://example.com/callback?error=access_denied&state=Xy7pQ2

Invalid input on the authorize request (unknown app_id, unregistered redirect_uri, wrong response_type or code_challenge_method, missing code_challenge, scope beyond the app's scopes) renders an HTML "Can't authorize" page. It never redirects to an unvalidated URI.

grant_typeRequiredstringin form

Must be authorization_code. No other grant type exists (no refresh_token, no client_credentials).

codeRequiredstringin form

The mpc_ code from the redirect.

redirect_uriRequiredstringin form

Must equal the redirect_uri used on the authorize request.

code_verifierRequiredstringin form

The PKCE verifier whose S256 hash was sent as code_challenge.

app_idOptionalstringin form

Optional. If sent, must match the app the code was issued to.

400unsupported_grant_typegrant_type is not authorization_code.
400invalid_grantCode unknown, already used or expired; app_id mismatch; redirect_uri mismatch; PKCE verification failed.
500server_errorThe token could not be issued.
  • Parameters are read from a form body (application/x-www-form-urlencoded) or the query string. A JSON body is not read.
  • No expires_in and no refresh_token are returned: the token does not expire.
  • Each successful exchange creates a new token named oauth:<app_id> in the user's token list.

Personal tokens and revocation

A signed-in user can create personal tokens with POST /api/v1/tokens, list them with GET /api/v1/tokens and delete them with DELETE /api/v1/tokens/{id}. See the API tokens group. You can also make and delete them on the API tokens page.

There is no OAuth revocation endpoint. A token stops working only when the user deletes it (DELETE /api/v1/tokens/{id}). OAuth-issued tokens appear in that list with the name oauth:<app_id>. Deleting an app does not delete tokens already issued for it.

Introduction

Scopes

Request only the scopes your app needs. The user sees each one on the consent page.

ScopeThe user seesGrants
readView your markets, balance, portfolio and historyGateway: balance, portfolio, proposal, proposal_open_contract, statement, profit_table, transaction, account_status, account_list, set_account. REST has no endpoint gated on read: every signed-in REST read accepts any valid token.
tradeBuy and sell contracts on your behalfGateway: buy, new_account_real, new_account_virtual. REST: POST /api/v1/contracts, POST /api/v1/contracts/bulk, POST /api/v1/accounts.
paymentsDeposit and withdraw from your accountGateway: transfer_between_accounts. REST: every deposit and withdrawal initiation (POST /api/v1/deposits/*, POST /api/v1/withdrawals/*), POST /api/v1/accounts/transfer, POST /api/v1/apps/{app_id}/claim, POST /api/v1/partner/claim, POST /api/v1/ib/transfer.
adminManage your API apps and tokensREST: satisfies every REST scope check (read, trade, payments). Gateway: grants nothing by itself, because the gateway checks for the exact scope name.

REST API

Using REST

Base URL https://api.miletrades.site. Send JSON bodies with Content-Type: application/json; unknown fields are rejected.

OAuth 2.0

Authorization code flow with mandatory PKCE (S256). The authorize endpoints are browser pages; only the token endpoint is called by your server.

OAuth 2.0

Show the consent page.

GET/api/v1/oauth/authorize
Browser page

Open this URL in the user's browser. It renders an HTML login and consent page. See AUTH.oauth for parameters.

app_idRequiredstringin query

Your 8-digit app_id.

redirect_uriRequiredstringin query

Must exactly equal one of the app's registered redirect_uris.

code_challengeRequiredstringin query

base64url(SHA-256(code_verifier)) with no padding.

code_challenge_methodOptionalstringin query

Only S256 is accepted. May be omitted; the challenge is always verified as S256.

response_typeOptionalstringin query

Only code is accepted. May be omitted.

scopeOptionalstringin query

Space or comma separated. Must be a subset of the app's registered scopes. Defaults to all of the app's scopes.

stateOptionalstringin query

Opaque value echoed back on the redirect. Use it for CSRF protection.

OAuth 2.0

Consent form submission (posted by the consent page).

POST/api/v1/oauth/authorize
Browser page

Not for direct use. The consent page posts app_id, redirect_uri, scope, state, code_challenge, action (approve or deny) and, when the browser has no session, email and password. On approve it redirects with code and state; on deny it redirects with error=access_denied and state.

actionRequired"approve" | "deny"in form

deny redirects with error=access_denied. Any other value is treated as approve.

emailOptionalstringin form

Only when the browser has no session.

passwordOptionalstringin form

Only when the browser has no session.

OAuth 2.0

Exchange an authorization code for an API token.

POST/api/v1/oauth/token
No auth
grant_typeRequiredstringin form

Must be authorization_code. No other grant type exists (no refresh_token, no client_credentials).

codeRequiredstringin form

The mpc_ code from the redirect.

redirect_uriRequiredstringin form

Must equal the redirect_uri used on the authorize request.

code_verifierRequiredstringin form

The PKCE verifier whose S256 hash was sent as code_challenge.

app_idOptionalstringin form

Optional. If sent, must match the app the code was issued to.

  • Parameters are read from a form body (application/x-www-form-urlencoded) or the query string. A JSON body is not read.
  • No expires_in and no refresh_token are returned: the token does not expire.
  • Each successful exchange creates a new token named oauth:<app_id> in the user's token list.

Developer apps

Register and manage OAuth apps, and read and claim app earnings. Intended for the app owner's signed-in browser session (the Developer apps page); these routes also accept the owner's API token.

Developer apps

Register an app.

POST/api/v1/apps
Bearer token
nameRequiredstring

Display name shown on the consent page.

redirect_urisRequiredstring[]

At least one. Matched exactly on authorize and token requests.

scopesOptionalstring[]

Any of read, trade, payments, admin. Defaults to ["read"].

homepageOptionalstring

Linked from the consent page.

markup_bpOptionalinteger

Your markup in basis points, 0..300 (0% to 3%). Default 0. Added to the price of every real USD trade placed through the app; you earn it on every settled trade.

  • app_secret is returned only once.

Developer apps

List the caller's apps, newest first.

GET/api/v1/apps
Bearer token

No parameters.

Developer apps

Change an app's markup.

PATCH/api/v1/apps/{app_id}/markup
Bearer token
app_idRequiredstringin path

One of the caller's apps.

markup_bpRequiredinteger

0..300 (0% to 3%); higher values are held at 300.

  • New prices use the change within 30 seconds. Contracts already bought keep the price they were bought at.

Developer apps

Delete an app.

DELETE/api/v1/apps/{app_id}
Bearer token
app_idRequiredstringin path

One of the caller's apps.

  • Tokens already issued for the app are not deleted and keep working.

Developer apps

Revenue-share earnings for each of the caller's apps.

GET/api/v1/apps/earnings
Bearer token

ngr_cents is lifetime stake minus payout over settled (won or lost) contracts attributed to the app, counting only real-money USD accounts. commission_cents is ngr_cents times the platform rate (app_profit_share_bp, default 1000 = 10%), floored at 0. claimable_cents = commission_cents minus paid_cents, floored at 0.

No parameters.

Developer apps

Claim an app's outstanding earnings to the owner's real USD account.

POST/api/v1/apps/{app_id}/claim
Bearer tokenscope: payments
app_idRequiredstringin path

One of the caller's apps.

API tokens

Personal API tokens for the signed-in user. OAuth-issued tokens for that user also appear here and can be deleted here.

API tokens

Create a token. The plaintext is returned once.

POST/api/v1/tokens
Bearer token
nameOptionalstring

Label for the token.

scopesOptionalstring[]

Any of read, trade, payments, admin. Defaults to ["read"].

app_idOptionalstring

Binds the token to an app_id for revenue attribution. Not validated.

  • display is the first 9 characters followed by an ellipsis character.
  • app_id is omitted from meta when empty; last_used_at is omitted until first use.

API tokens

List the caller's tokens, newest first. Plaintext is never returned.

GET/api/v1/tokens
Bearer token

No parameters.

API tokens

Delete (revoke) one of the caller's tokens.

DELETE/api/v1/tokens/{id}
Bearer token
idRequireduuidin path

Token id from the list.

Account and balances

The user's profile, options accounts (wallets) and multi-currency transfers. Account ids (loginid) are MP followed by 10 hex characters for real accounts and VR followed by 10 hex characters for demo accounts.

Account and balances

The caller's user record, wallets and verification state.

GET/api/v1/auth/me
Bearer token

No parameters.

  • user also carries phone, display_name and admin_role when set (omitted when empty).

Account and balances

Supported account currencies with live USD rates and crypto networks.

GET/api/v1/currencies
Bearer token

No parameters.

  • usd_rate is units of the currency per 1 USD; omitted when no rate is available.

Account and balances

Open a currency account.

POST/api/v1/accounts
Bearer tokenscope: trade

Real accounts start empty. Demo accounts are seeded with the equivalent of 10,000 USD in their own currency.

kindOptional"real" | "demo"

Default real.

currencyRequiredstring

A supported code from /api/v1/currencies, for example EUR or BTC.

Account and balances

Move money between two of the caller's accounts, converting by FX when currencies differ.

POST/api/v1/accounts/transfer
Bearer tokenscope: payments
from_loginidRequiredstring

Source account.

to_loginidRequiredstring

Destination account. Same kind (real or demo) as the source.

amountRequirednumber

Amount in the source currency, major units (for example 25.50).

Account and balances

Ledger history of one options account, newest first.

GET/api/v1/accounts/{loginid}/transactions
Bearer token
loginidRequiredstringin path

One of the caller's options accounts.

limitOptionalintegerin query

Default 50, max 200.

beforeOptionalintegerin query

Ledger id cursor: return rows older than this id. Use next_before from the previous page.

  • category is one of deposit, withdrawal, refund, transfer, trade, commission, adjustment.
  • next_before is omitted on the last page.

Contracts (REST trading)

Price, place and list contracts over REST. Trades placed with an OAuth-issued token are attributed to that token's app, and a real USD trade carries the app's markup in its price. Digit contracts: even, odd, match, differ, over, under (synthetic indices only). Price contracts: rise, fall (any instrument). Amounts are integer minor units (cents) of the account currency.

Contracts (REST trading)

Price a prospective contract. Changes nothing.

POST/api/v1/contracts/proposal
Bearer token
symbolOptionalstring

Instrument, for example volatility_100. Defaults to the first registered index.

contract_typeRequiredstring

even, odd, match, differ, over, under, rise or fall (lowercase).

paramsOptional{ digit?: integer; threshold?: integer }

match and differ: digit 0..9. over: threshold 0..8. under: threshold 1..9. even, odd, rise, fall: none.

stake_centsOptionalinteger

When greater than 0, payout_cents is computed.

wallet_kindOptional"real" | "demo"

Selects the RTP tier. Defaults to the user's kind.

  • Called with an app's token on a real account, the multiplier already includes the app's markup, and app_markup_bp says what it is.

Contracts (REST trading)

Buy a contract. The stake is debited immediately.

POST/api/v1/contracts
Bearer tokenscope: trade

The contract enters at the latest tick and settles a number of ticks later (the platform default, currently 3, unless duration_ticks is given). Settlement is pushed on the price feed WebSocket as contract.settled.

symbolOptionalstring

Instrument. Defaults to the first registered index.

contract_typeRequiredstring

even, odd, match, differ, over, under, rise or fall.

stake_centsRequiredinteger

Stake in minor units of the account currency. Must be greater than 0.

paramsOptional{ digit?: integer; threshold?: integer }

Same rules as the proposal endpoint.

wallet_kindOptional"real" | "demo"

Defaults to the user's kind. Selects that kind's USD account when loginid is not given.

loginidOptionalstring

Stake from this specific options account (and in its currency).

duration_ticksOptionalinteger

Ticks after entry until settlement, clamped to 1..3600.

Contracts (REST trading)

Place up to 60 contracts in one request. Each item succeeds or fails on its own.

POST/api/v1/contracts/bulk
Bearer tokenscope: trade
itemsRequiredobject[]

1..60 items with the same fields as POST /api/v1/contracts. The loginid field is accepted but ignored: bulk items always use the USD account of wallet_kind.

  • Each placed result carries a full contract object (abbreviated in the example).
  • Item error strings: unknown symbol, demo users can only trade the demo wallet, price feed not ready, invalid contract type, invalid params, invalid stake, wallet not found, insufficient balance, could not create contract.

Contracts (REST trading)

List the caller's contracts, newest first.

GET/api/v1/contracts
Bearer token
statusOptional"open" | "closed"in query

open = pending. closed = won, lost or cancelled. Omitted or any other value = all.

symbolOptionalstringin query

Filter by instrument.

fromOptionalstringin query

RFC 3339 time or YYYY-MM-DD. Unparseable values are ignored.

toOptionalstringin query

RFC 3339 time or YYYY-MM-DD. Unparseable values are ignored.

limitOptionalintegerin query

Default 50. Values above 1000 fall back to 50.

  • status values: pending, won, lost, cancelled. settle_price, settle_digit, payout_cents and settled_at are omitted until settlement.

Market data (public)

Read-only prices with no authentication and CORS open to any origin (Access-Control-Allow-Origin: *). /api/v1/quotes covers the platform's own instruments (synthetic indices plus display-only real-feed prices). /api/v1/markets/* is the MT5 trade server's symbol catalog.

Market data (public)

Latest price for every live platform instrument.

GET/api/v1/quotes
No auth

No parameters.

  • asset_class is one of synthetic, forex, crypto, indices, commodities. Non-synthetic entries here are display-only and cannot be traded.

Market data (public)

Market categories with symbol counts.

GET/api/v1/markets/paths
No auth

No parameters.

Market data (public)

One page of symbols with live prices.

GET/api/v1/markets/symbols
No auth
pathOptionalstringin query

Category prefix. Empty = all.

qOptionalstringin query

Case-insensitive match on name, symbol or description.

offsetOptionalintegerin query

Default 0.

limitOptionalintegerin query

Default 50, max 200.

Market data (public)

Latest prices for named symbols.

GET/api/v1/markets/quotes
No auth
symbolsRequiredstringin query

Comma-separated trade-server symbols, 1..200. Unknown names are skipped.

  • Each row has the full shape shown on /api/v1/markets/symbols (abbreviated here).

Market data (public)

One instrument with every account tier's specification and price.

GET/api/v1/markets/instruments/{name}
No auth
nameRequiredstringin path

Client-facing name without tier suffix, for example EURUSD (case-insensitive).

  • The top level also carries every field of a /symbols row (abbreviated here).
  • tier is standard, pro or vip. sessions has 7 entries, Sunday first; times are minutes since 00:00 trade-server time. swap_3day: 0 = Sunday, -1 = none. The example values are illustrative.

Market data (public)

Liveness check.

GET/health
No auth

No parameters.

WebSockets

Trading gateway

Open wss://<api-origin>/ws/v1. Any Origin is accepted. Optional ?app_id=<app_id> on the URL sets attribution for tokens that are not bound to an app; a token bound to an app always uses its own app_id.

Send {"authorize": "mp_..."} first. Market calls (active_symbols, ticks, ticks_history, ping, time, forget, forget_all) work without it. Every other call returns AuthorizationRequired until authorized, and PermissionDenied if the token lacks the exact scope (admin does not stand in for other scopes here).

A request is one JSON object. The first recognised call key names the call. Envelope fields: req_id (integer, echoed back), subscribe (1 to stream, where supported), passthrough and app_id (ignored by the server; passthrough is not echoed separately, but appears inside echo_req). A response is {"msg_type": <type>, "echo_req": <your request>, <type>: <payload>, "req_id"?: <int>, "subscription"?: {"id": <id>}}.

The server sends a WebSocket ping control frame every 25 seconds; standard clients answer with pong automatically. The server does not close idle connections itself. You can also send {"ping": 1}.

DIGITOVER or OVER, DIGITUNDER or UNDER, DIGITMATCH or MATCH, DIGITDIFF or DIFFER or DIFF, DIGITEVEN or EVEN, DIGITODD or ODD (case-insensitive). Rise and fall are not available on the gateway. Responses always use the DIGIT... names.

Error frame
{
  "msg_type": "proposal",
  "echo_req": { "proposal": 1, "contract_type": "DIGITOVER", "symbol": "volatility_100", "amount": 1, "barrier": 12, "req_id": 7 },
  "error": { "code": "InputValidationFailed", "message": "barrier must be 0-9 for over/under" },
  "req_id": 7
}

Calls

authorizeYou sendNo auth

Authenticate the connection with an API token.

authorizeRequiredstring

The mp_ token.

  • Sets the active account to the user's USD account of their kind (real, or demo for demo-only users).
pingYou sendNo auth

Application-level ping.

pingRequiredany

Value is ignored, for example 1.

timeYou sendNo auth

Server time.

timeRequiredany

Value is ignored.

active_symbolsYou sendNo auth

List tradeable markets.

active_symbolsRequiredany

Value is ignored (for example "brief").

ticksYou sendNo authSubscribable

Latest tick, or a tick stream with subscribe: 1.

ticksRequiredstring

Symbol.

  • Replies have msg_type tick. Errors: UnknownSymbol; InternalError "no price yet".
ticks_historyYou sendNo authSubscribable

Recent ticks; with subscribe: 1 also streams new ticks.

ticks_historyRequiredstring

Symbol.

countOptionalinteger

Default 100, max 5000.

  • Replies have msg_type history. Error: UnknownSymbol.
forgetYou sendNo auth

Stop one subscription.

forgetRequiredstring

Subscription id.

forget_allYou sendNo auth

Stop every subscription of one type, or all.

forget_allRequiredstring

ticks, balance, transaction, proposal or proposal_open_contract. An empty string stops all. A non-string value (an array, for example) is read as empty and also stops all.

balanceYou sendscope: readSubscribable

Account balance; with subscribe: 1, re-sent after every account event for the user.

balanceRequiredany

Value is ignored.

accountOptionalstring

Operate on this account: a loginid, "real" or "demo". Defaults to the connection's active account. Demo-only users are always pinned to their demo account.

account_listYou sendscope: read

List the user's options accounts.

account_listRequiredany

Value is ignored.

set_accountYou sendscope: read

Switch the connection's active account.

set_accountRequiredstring

A loginid, "real" or "demo".

  • Errors: InputValidationFailed ("no such account"), PermissionDenied for a demo-only user picking a real account.
new_account_realYou sendscope: trade

Open a real currency account.

new_account_realRequiredany

Value is ignored.

currencyOptionalstring

Default USD.

  • Errors: PermissionDenied for demo-only users; InputValidationFailed for an unsupported currency or an account that already exists.
new_account_virtualYou sendscope: trade

Open a demo currency account, seeded with the equivalent of 10,000 USD.

new_account_virtualRequiredany

Value is ignored.

currencyOptionalstring

Default USD.

transfer_between_accountsYou sendscope: payments

Transfer between two of the user's accounts (same kind). Without both account ids, returns the account list.

transfer_between_accountsRequiredany

Value is ignored.

account_fromOptionalstring

Source loginid.

account_toOptionalstring

Destination loginid.

amountOptionalnumber

Source currency, major units. Required when both ids are given.

  • Errors: InputValidationFailed (same account, bad amount, unknown account, real to demo); PermissionDenied (insufficient balance); InternalError (no exchange rate).
account_statusYou sendscope: read

Verification tier and withdrawal limit.

account_statusRequiredany

Value is ignored.

accountOptionalstring

Operate on this account: a loginid, "real" or "demo". Defaults to the connection's active account. Demo-only users are always pinned to their demo account.

statementYou sendscope: read

Ledger rows of one account, newest first.

statementRequiredany

Value is ignored.

limitOptionalinteger

Default 50, max 200.

accountOptionalstring

Operate on this account: a loginid, "real" or "demo". Defaults to the connection's active account. Demo-only users are always pinned to their demo account.

profit_tableYou sendscope: read

Settled contracts on the active (or chosen) account.

profit_tableRequiredany

Value is ignored.

limitOptionalinteger

Default 50, max 200. Drawn from the user's 200 most recent settled contracts.

accountOptionalstring

Operate on this account: a loginid, "real" or "demo". Defaults to the connection's active account. Demo-only users are always pinned to their demo account.

transactionYou sendscope: readSubscribable

Stream of the user's money events. Must be sent with subscribe: 1.

transactionRequiredany

Value is ignored.

  • Without subscribe: 1 the reply is {"info": "add \"subscribe\":1 to stream transactions"} and nothing streams.
portfolioYou sendscope: read

Open (pending) contracts across all accounts, up to 100.

portfolioRequiredany

Value is ignored.

proposalYou sendscope: readSubscribable

Price a digit contract. With subscribe: 1, re-priced on every tick.

proposalRequiredany

Value is ignored, for example 1.

contract_typeRequiredstring

See GATEWAY.contractTypes.

symbolRequiredstring

Market.

amountRequirednumber

Stake, account currency, major units, greater than 0.

barrierOptionalinteger | string

0..9 for over, under, match, differ. Ignored for even, odd. Over 9 and under 0 pass here but fail at buy.

accountOptionalstring

Operate on this account: a loginid, "real" or "demo". Defaults to the connection's active account. Demo-only users are always pinned to their demo account.

  • Errors: InputValidationFailed, UnknownSymbol. The proposal id is valid only on this connection; the subscription id equals the proposal id.
buyYou sendscope: trade

Buy a proposal by id, or buy directly with parameters.

buyRequiredstring

Proposal id from this connection. Any value when parameters is used.

priceOptionalnumber

Maximum price. Rejected if the stake is higher.

parametersOptionalobject

Used when buy is not a known proposal id: contract_type, symbol, amount, barrier, account (same meanings as proposal).

  • Errors: InputValidationFailed (unknown proposal, bad parameters, price moved, invalid contract), UnknownSymbol, PermissionDenied (insufficient balance), InternalError.
proposal_open_contractYou sendscope: readSubscribable

State of one contract. With subscribe: 1 on an open contract, updates every tick and once more on settlement, then the subscription ends.

proposal_open_contractRequiredstring

Contract UUID.

  • Errors: InputValidationFailed (not a UUID, contract not found), InternalError.

Replies

authorizeServer sends

Authorization result.

loginidRequiredstring

Primary account.

emailRequiredstring | null

User email.

scopesRequiredstring[]

Token scopes.

balanceRequirednumber

Primary account balance.

currencyRequiredstring

Primary account currency.

is_virtualRequired0 | 1

Primary account is demo.

account_listRequiredobject[]

Every account: loginid, currency, is_crypto, is_virtual, balance.

  • Error: InvalidToken ("invalid or expired token").
pingServer sends

Ping reply.

pingRequired"pong"

Always pong.

timeServer sends

Server time as Unix seconds.

timeRequiredinteger

Unix seconds.

active_symbolsServer sends

Tradeable markets. Display-only instruments are excluded.

symbolRequiredstring

Market id, for example volatility_100.

display_nameRequiredstring

Label.

marketRequiredstring

Always synthetic_index.

submarketRequiredstring

Always random_index.

pipRequirednumber

Always 0.01.

exchange_is_openRequired1

Always 1.

spotOptionalnumber

Latest price, when available.

spot_timeOptionalinteger

Unix seconds of spot.

tickServer sends

One tick (reply to ticks, and stream frames for ticks and ticks_history subscriptions).

symbolRequiredstring

Symbol.

idRequiredstring

Subscription id, empty for a one-off.

epochRequiredinteger

Unix seconds.

quoteRequirednumber

Price.

pip_sizeRequiredinteger

Always 2.

digitRequiredinteger

Last digit used for settlement.

historyServer sends

Tick history as parallel arrays, oldest first.

pricesRequirednumber[]

Prices.

timesRequiredinteger[]

Unix seconds.

digitsRequiredinteger[]

Last digits.

forgetServer sends

1 if a subscription was removed, else 0.

forgetRequired0 | 1

Removed count.

forget_allServer sends

Ids of the removed subscriptions.

forget_allRequiredstring[]

Removed ids.

balanceServer sends

Balance of the resolved account.

balanceRequirednumber

Major units.

currencyRequiredstring

Currency.

loginidRequiredstring

Account.

account_listServer sends

Accounts and count.

countRequiredinteger

Number of accounts.

accountsRequiredobject[]

loginid, currency, is_crypto, is_virtual, balance.

set_accountServer sends

The new active account.

loginidRequiredstring

Account id (MP... real, VR... demo).

currencyRequiredstring

Account currency.

is_cryptoRequired0 | 1

1 for crypto currencies.

is_virtualRequired0 | 1

1 for demo accounts.

balanceRequirednumber

Balance in major units.

new_account_realServer sends

The new account (same shape as set_account).

loginidRequiredstring

Account id (MP... real, VR... demo).

currencyRequiredstring

Account currency.

is_cryptoRequired0 | 1

1 for crypto currencies.

is_virtualRequired0 | 1

1 for demo accounts.

balanceRequirednumber

Balance in major units.

new_account_virtualServer sends

The new demo account (same shape as set_account).

loginidRequiredstring

Account id (MP... real, VR... demo).

currencyRequiredstring

Account currency.

is_cryptoRequired0 | 1

1 for crypto currencies.

is_virtualRequired0 | 1

1 for demo accounts.

balanceRequirednumber

Balance in major units.

transfer_between_accountsServer sends

Transfer result (or {"accounts": [...]} when no ids were given).

account_fromRequiredstring

Source loginid.

account_toRequiredstring

Destination loginid.

amountRequirednumber

Debited, source currency.

amount_creditedRequirednumber

Credited, destination currency.

from_currencyRequiredstring

Source currency.

to_currencyRequiredstring

Destination currency.

rateRequirednumber

FX rate used (1 for same currency).

from_balance_afterRequirednumber

Source balance after.

to_balance_afterRequirednumber

Destination balance after.

account_statusServer sends

Status summary.

kyc_tierRequiredinteger

Verification tier.

is_virtualRequired0 | 1

Demo-only user.

statusRequiredstring[]

One of unverified (tier 0 to 1), fully_authenticated (tier 2), withdrawal_locked (tier 3 or more).

daily_withdrawal_limitRequiredstring

"100.00", "unlimited" or "0.00".

currencyRequiredstring

Resolved account currency.

statementServer sends

Ledger rows with running balance.

countRequiredinteger

Rows returned.

transactionsRequiredobject[]

transaction_id, type (ledger kind), amount, balance_after, currency, transaction_time (Unix seconds), description, longcode (ledger note, optional), contract_id (optional).

profit_tableServer sends

Settled contracts.

countRequiredinteger

Rows returned.

transactionsRequiredobject[]

contract_id, contract_type, symbol, buy_price, sell_price, payout, currency, profit, is_win (0 or 1), purchase_time, sell_time, longcode.

transactionServer sends

First an ack {"action": "subscribed"}, then one frame per event.

actionRequiredstring

subscribed (ack), buy, sell, deposit, withdrawal, withdrawal_refund.

transaction_timeOptionalinteger

Unix seconds (server time when sent).

currencyOptionalstring

Contract currency; USD for cashier events.

balance_afterOptionalnumber

When the event carries a new balance.

contract_idOptionalstring

buy and sell.

amountOptionalnumber

buy: negative stake. sell: payout.

longcodeOptionalstring

buy only.

portfolioServer sends

Open contracts.

contractsRequiredobject[]

contract_id, symbol, contract_type, buy_price, payout, currency, longcode, date_start.

proposalServer sends

A priced proposal you can buy.

idRequiredstring

Proposal id (prop_...). Pass to buy.

ask_priceRequirednumber

Equals your amount.

payoutRequirednumber

Payout if the contract wins.

currencyRequiredstring

Account currency.

spotRequirednumber

Latest price.

spot_timeRequiredinteger

Unix seconds.

display_valueRequirednumber

Equals your amount.

payout_multiplierRequirednumber

payout / stake, for example 1.95.

longcodeRequiredstring

Human description.

buyServer sends

The purchased contract.

contract_idRequiredstring

Contract UUID.

transaction_idRequiredstring

Same value as contract_id.

buy_priceRequirednumber

Stake.

balance_afterRequirednumber

Balance after the stake.

payoutRequirednumber

Payout if won.

currencyRequiredstring

Currency.

start_timeRequiredinteger

Unix seconds.

longcodeRequiredstring

Description.

proposal_open_contractServer sends

Contract state.

contract_idRequiredstring

Contract UUID.

symbolRequiredstring

Market.

contract_typeRequiredstring

DIGIT... name.

longcodeRequiredstring

Description.

buy_priceRequirednumber

Stake.

currencyRequiredstring

Currency.

payoutRequirednumber

Payout if won.

entry_spotRequirednumber

Entry price.

current_spotRequirednumber

Latest price.

current_spot_timeRequiredinteger

Unix seconds.

statusRequired"open" | "won" | "lost"

Contract status.

is_soldRequired0 | 1

1 once settled.

profitRequirednumber

0 while open.

date_startRequiredinteger

Unix seconds.

tick_countRequiredinteger

Ticks from entry to settlement.

exit_spotOptionalnumber

After settlement.

exit_digitOptionalinteger

After settlement.

(error)Server sends

Any call can fail with this envelope instead of its payload.

msg_typeRequiredstring

The call's reply type (for unknown calls, the unknown key).

echo_reqRequiredobject

Your request.

error.codeRequiredstring

See ERRORS.gatewayCodes.

error.messageRequiredstring

Human-readable reason.

req_idOptionalinteger

Echoed when sent.

WebSockets

Price feed

Open wss://<api-origin>/api/v1/feed/ws. Without credentials you get market data only. Add ?token=mp_... (or have a browser session cookie) to also receive the user's account events and to use user channels. Connections that carry ?token= are accepted from any Origin; connections without a token must come from an allow-listed Origin or send no Origin.

The server immediately sends one symbols message, then one history message per tradeable symbol (up to 300 ticks each), then streams tick messages for every symbol. There is no per-symbol subscription for ticks.

The server sends a WebSocket ping control frame every 20 seconds.

symbolsServer sends

Catalog of tradeable platform instruments. First message after connect.

symbolsRequiredobject[]

symbol, label, asset_class, submarket (optional), price_precision, trade_types.

  • trade_types lists contract families for the instrument's asset class. Only even/odd, match/differ, over/under and rise/fall can actually be traded through the API.
historyServer sends

Initial tick snapshot for one symbol (up to 300 ticks).

symbolRequiredstring

Symbol.

historyRequiredobject[]

Ticks: id, symbol, ts (RFC 3339), price, digit.

tickServer sends

One new tick for any symbol.

tickRequiredobject

id, symbol, ts, price, digit.

  • Ticks are dropped for a slow client rather than queued.
contract.openedServer sends

Authenticated only. A contract was bought (web, REST or gateway).

contractRequiredobject

Event data: { contract: <Contract>, new_balance_cents }. The outer key is named contract for every event type.

contract.settledServer sends

Authenticated only. A contract settled.

contractRequiredobject

Event data: { contract: <Contract>, new_balance_cents, won }.

(payment event)Server sends

Authenticated only. Cashier events: deposit.completed, deposit.failed, ugx_deposit.completed, ugx_deposit.failed, withdrawal.opened, withdrawal.completed, withdrawal.failed, crypto_withdrawal.updated, transfer.completed.

typeRequiredstring

The event name.

contractRequiredobject

Event data, despite the key name. Usually { deposit: {...} } or { withdrawal: {...} }, sometimes with new_balance_cents. transfer.completed carries { from_wallet_id, to_wallet_id }.

subscribeYou send

Subscribe to a channel. User channels need a token or session.

typeRequired"subscribe"

Literal.

channelRequiredstring

mt5.state (the user's MT5 account balance and equity) or mt5.positions (full open-position list of one of the user's MT5 accounts). Other names are staff-only or unknown.

loginidOptionalstring

Only deliver events for this MT5 loginid.

unsubscribeYou send

Unsubscribe from a channel. No reply is sent.

typeRequired"unsubscribe"

Literal.

channelRequiredstring

Channel name.

subscribedServer sends

Subscription confirmed. A repeat subscribe to the same channel gets no reply.

channelRequiredstring

Channel name.

errorServer sends

Subscribe refused.

channelRequiredstring

Channel name.

codeRequiredstring

unknown_channel, forbidden (staff channel) or unauthenticated (user channel without a token or session).

(channel event)Server sends

One event on a subscribed channel. Note: this frame has no type field.

channelRequiredstring

mt5.state or mt5.positions.

loginidOptionalstring

MT5 account (MTR... real, MTD... demo).

tsRequiredstring

RFC 3339 time.

user_idOptionalstring

Owner user id.

payloadRequiredobject

mt5.state: balance_minor, equity_minor, margin_minor, margin_free_minor, profit_minor, currency. mt5.positions: { positions: [ticket, symbol, side, volume_units, price_open, price_current, digits, open_time, profit_minor, swap_minor, ...] }.

Reference

Errors

REST errors are JSON {"error": "<message>"} with an HTTP status. A few routes add fields, for example the withdrawal step-up 401 (code, stepup_id, ...) and the prelive allow-list 403 ({"error": "prelive_not_allowlisted"}). The scope gate message is "token is missing the `<scope>` scope".

REST
{ "error": "insufficient balance" }
OAuth
{
  "error": "invalid_grant",
  "error_description": "invalid or expired authorization code"
}
Gateway
{
  "msg_type": "proposal",
  "echo_req": { "proposal": 1, "contract_type": "DIGITOVER", "symbol": "volatility_100", "amount": 1, "barrier": 12, "req_id": 7 },
  "error": { "code": "InputValidationFailed", "message": "barrier must be 0-9 for over/under" },
  "req_id": 7
}

HTTP statuses

200Success.
201Created (app registration, token creation).
202Accepted: a deposit or withdrawal was started and completes asynchronously.
302OAuth consent redirect back to your redirect_uri.
400Invalid input, including JSON with unknown fields or a body over 1 MB.
401Not authenticated, or a withdrawal step-up is required.
402Insufficient balance (contracts, transfers, withdrawals).
403Token is missing the required scope, or the action is not allowed for this user.
404Not found, or not owned by the caller.
409Conflict, for example the currency account already exists.
429Too soon: repeated withdrawal or step-up code request.
500Server error.
502Payment provider call failed.
503Temporarily unavailable: price feed not ready, no FX rate, market browser not available, Kenyan deposits switched off.

Gateway error codes

InvalidTokenauthorize with an unknown or deleted token.
AuthorizationRequiredA call that needs a token before authorize succeeded.
PermissionDeniedToken lacks the exact scope; demo-only restrictions; insufficient balance on buy or transfer.
UnrecognisedRequestNo known call key in the message, or an unknown call.
InputValidationFailedBad or missing parameters.
UnknownSymbolSymbol not found.
RateLimitMore than the per-connection message budget (see LIMITS).
InternalErrorServer-side failure, no price yet, no account, no exchange rate.

OAuth error codes

unsupported_grant_typegrant_type is not authorization_code.
invalid_grantBad, used or expired code; app_id or redirect_uri mismatch; PKCE failed.
server_errorToken could not be issued.
access_deniedRedirect parameter when the user cancels on the consent page.

Feed error codes

unknown_channelSubscribe to a channel name that does not exist.
forbiddenSubscribe to a staff channel.
unauthenticatedSubscribe to a user channel without a token or session.

Reference

Limits

Gateway message rateToken bucket per connection: 30 messages per second sustained, burst 60. Over the limit returns a RateLimit error for that message.
REST rate limitingNone found. No HTTP rate limiter is mounted on the router.
Withdrawal frequencyAbout one withdrawal initiation per minute per user (429).
REST JSON body1 MB maximum; unknown fields are rejected.
Bulk contracts1 to 60 items per request.
Contract durationPlatform default 3 ticks (admin setting contract_duration_ticks). REST duration_ticks clamped to 1..3600. Gateway contracts always use the default.
Contract listGET /api/v1/contracts limit default 50, max 1000.
Gateway historyticks_history count default 100, max 5000. statement and profit_table limit default 50, max 200. portfolio up to 100 open contracts.
Feed snapshotUp to 300 ticks per symbol on connect.
Market catalog/markets/symbols limit default 50, max 200. /markets/quotes up to 200 symbols.
Account transactionslimit default 50, max 200.
Unified depositslimit default 30, max 100.
App earnings claimMinimum 500 cents (5 USD) claimable.
App markupmarkup_bp 0..300 (0% to 3%), default 0.
Authorization codeSingle use, 5 minute lifetime.
Access token lifetimeNo expiry.

Introduction

Markup commission

An app earns its markup. The markup (0% to 3%) is added to the price of every real USD trade placed through the app, as a share of the payout: the multiplier becomes 1 / (1/base + markup), so the trader receives a slightly lower payout. The app earns markup × payout on every settled trade, won or lost. Trades placed before markup pricing earn the old flat share (app_profit_share_bp, default 10%) of their net house revenue instead.

A contract is attributed to an app when it is bought with a token bound to that app (an OAuth-issued token, or a personal token created with app_id), on the gateway buy call, REST POST /api/v1/contracts or REST POST /api/v1/contracts/bulk. On the gateway, a token with no app binding uses ?app_id= from the connection URL.

Endpoints: GET /api/v1/apps/earnings, POST /api/v1/apps/{app_id}/claim. See Developer apps, and your figures in the commission report.