View as Markdown

Quickstart

Your first call in under two minutes, in the free sandbox. Then connect your broker account and run the same calls.

Start in the sandbox: no card, no broker login, no terminal to wait for. When your code works there, connect a broker account and change only the key and the account id. Demo, small funded or live: it’s your choice. The examples use curl.

export TW=https://api.tickwire.io

1. Get a sandbox key and account

curl -s -X POST "$TW/v1/sandbox/signup" -H "content-type: application/json" -d '{"platform": "mt5"}'
{
  "sandbox": true,
  "apiKey": "twsk_4b1e…",
  "account": { "id": "acc_7Qx", "server": "Tickwire-Sandbox", "login": "1000",
               "state": "DEPLOYED", "connectionStatus": "CONNECTED" }
}

The key is shown once. Set it, then follow steps 2 to 6 below with acc_7Qx:

export TW_KEY=twsk_4b1e…

Sandbox answers carry X-Tickwire-Sandbox: true. Want to see an order that can’t be confirmed, a rejection or a disconnect? Create accounts with the magic logins.

Or connect a broker account

You need a live Tickwire API key and a broker account (login, password and server name, e.g. YourBroker-Server):

export TW_KEY=your-live-api-key
curl -s -X POST "$TW/users/current/accounts" \
  -H "auth-token: $TW_KEY" \
  -H "transaction-id: $(openssl rand -hex 16)" \
  -H "content-type: application/json" \
  -d '{
    "name": "my account",
    "platform": "mt5",
    "server": "YourBroker-Server",
    "login": "12345678",
    "password": "your-password",
    "magic": 1000
  }'

If broker detection is still running you get 202 with a Retry-After header. Send the same request again, with the same transaction-id, after that many seconds. You end with 201 and the account id:

{ "id": "acc_7Qx", "state": "DEPLOYING" }

If the server name is unknown you get E_SRV_NOT_FOUND with suggested names. See broker onboarding.

The password is write-only. We never return it or write it to logs.

2. Wait for the account to connect

curl -s "$TW/users/current/accounts/acc_7Qx" -H "auth-token: $TW_KEY"

Wait for "connectionStatus": "CONNECTED" and "health": {"status": "healthy", …}. That means the broker link is up and the account was read. Usually this takes under a minute; a sandbox account is ready at once. "prices_live": false means connected, but no price is moving (the market is likely closed). It is not an error. See Health.

3. Read the account

curl -s "$TW/users/current/accounts/acc_7Qx/account-information" -H "auth-token: $TW_KEY"
{
  "platform": "mt5",
  "broker": "Your Broker Ltd",
  "currency": "USD",
  "balance": 10000,
  "equity": 10000,
  "margin": 0,
  "freeMargin": 10000,
  "leverage": 500,
  "tradeAllowed": true
}

The live answer has more fields; this shows the main ones. To read the broker’s clock, call GET /users/current/accounts/acc_7Qx/server-time. It returns time (UTC) and brokerTime (the broker’s local time). Broker time isn’t UTC; see Time zones.

4. Place an order

curl -s -X POST "$TW/users/current/accounts/acc_7Qx/trade" \
  -H "auth-token: $TW_KEY" \
  -H "Idempotency-Key: first-order-1" \
  -H "X-Actor: quickstart" -H "X-Reason: trying Tickwire" \
  -H "content-type: application/json" \
  -d '{"actionType": "ORDER_TYPE_BUY", "symbol": "EURUSD", "volume": 0.01}'
{
  "numericCode": 10009,
  "stringCode": "TRADE_RETCODE_DONE",
  "message": "Request completed",
  "orderId": "46870472",
  "positionId": "46870472",
  "outcome": "applied"
}

Run the same command again: because the Idempotency-Key is the same, you get the same answer and no second position. See Idempotency.

Some brokers suffix symbols (EURUSDm). GET …/symbols lists the exact names.

5. Close it

curl -s -X POST "$TW/users/current/accounts/acc_7Qx/trade" \
  -H "auth-token: $TW_KEY" \
  -H "Idempotency-Key: first-close-1" \
  -H "X-Actor: quickstart" -H "X-Reason: done" \
  -H "content-type: application/json" \
  -d '{"actionType": "POSITION_CLOSE_ID", "positionId": "46870472"}'

6. Watch it live

# websocat, or any WebSocket client
websocat "wss://api.tickwire.io/users/current/accounts/acc_7Qx/ws?auth-token=$TW_KEY"
{"type":"subscribe","marketData":[{"symbol":"EURUSD","subscriptions":[{"type":"quotes"}]}]}

You get a full sync, then prices and health frames. See Streaming.

Next