API reference / Account REST API (/users/current)
Account state
Account REST API (/users/current). Generated from the OpenAPI document the services export (/openapi.json).
Samples use the placeholders YOUR_API_KEY and YOUR_ACCOUNT_ID.
Paste a sandbox key (twsk_…) to fill them in and to use Try it.
It stays in this browser tab and is only sent to the sandbox, never to the live API.
Try it is off in this build: No sandbox URL is configured for this build of the docs.
GET /users/current/accounts/{account_id}/account-information
Get account information Auth: auth-token
Balance, equity, margin, free margin, leverage and the other account values.
They are read live from the terminal on every call, so
refreshTerminalState is accepted but changes nothing. marginLevel is
only present while margin is in use. investorMode is only present when
it is known. Works on MT4 and MT5.
| Parameter | In | Type | Description |
|---|---|---|---|
account_id required | path | string | |
refreshTerminalState | query | string | null |
Responses
200The account's live values. ·AccountInformation400Bad request. On the account API paths a body or query validation failure is a 400ValidationErrorwithdetails: [{parameter, message}]. ·ErrorEnvelope401No credential was sent, or it is not valid or has expired. ·ErrorEnvelope403The credential is valid but may not do this, for example a read-only key on a change, or a token without the needed role or account. ·ErrorEnvelope404The account does not exist or this credential cannot see it, or the position, order or symbol in the path was not found. ·ErrorEnvelope429Too many requests. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope503The terminal is not connected or not synchronized yet. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope
Errors (common for this kind of call; every error uses one envelope)
401unauthorized429rate_limited400, 422validation_error404account_not_found503not_connected
curl
curl -sS -X GET 'https://api.tickwire.io/users/current/accounts/YOUR_ACCOUNT_ID/account-information' \
-H 'auth-token: YOUR_API_KEY' Python
from tickwire import Tickwire
with Tickwire("https://api.tickwire.io", "YOUR_API_KEY") as tw:
result = tw.request(
"GET",
"/users/current/accounts/YOUR_ACCOUNT_ID/account-information",
)
print(result) TypeScript
import { TickwireClient } from "@tickwire/sdk";
const tw = new TickwireClient({ baseUrl: "https://api.tickwire.io", token: "YOUR_API_KEY" });
const result = await tw.request("GET", "/users/current/accounts/YOUR_ACCOUNT_ID/account-information");
console.log(result);
tw.close(); Try it in the sandbox
Try it is off in this build of the docs: no sandbox URL is configured. The samples above work against the sandbox with your sandbox key.
GET /users/current/accounts/{account_id}/capabilities
Get the account's capabilities Auth: auth-token
What this account supports: features, timeframes and limits.
features lists market depth, tick history, stop-limit orders, close-by
and more. MT4 accounts report no market depth, no tick history and 9
timeframes. brokerTime is the broker time zone detection state.
| Parameter | In | Type | Description |
|---|---|---|---|
account_id required | path | string |
Responses
200What this account supports. ·Capabilities400Bad request. On the account API paths a body or query validation failure is a 400ValidationErrorwithdetails: [{parameter, message}]. ·ErrorEnvelope401No credential was sent, or it is not valid or has expired. ·ErrorEnvelope403The credential is valid but may not do this, for example a read-only key on a change, or a token without the needed role or account. ·ErrorEnvelope404The account does not exist or this credential cannot see it, or the position, order or symbol in the path was not found. ·ErrorEnvelope429Too many requests. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope503The terminal is not connected or not synchronized yet. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope
Errors (common for this kind of call; every error uses one envelope)
401unauthorized429rate_limited400, 422validation_error404account_not_found503not_connected
curl
curl -sS -X GET 'https://api.tickwire.io/users/current/accounts/YOUR_ACCOUNT_ID/capabilities' \
-H 'auth-token: YOUR_API_KEY' Python
from tickwire import Tickwire
with Tickwire("https://api.tickwire.io", "YOUR_API_KEY") as tw:
result = tw.request(
"GET",
"/users/current/accounts/YOUR_ACCOUNT_ID/capabilities",
)
print(result) TypeScript
import { TickwireClient } from "@tickwire/sdk";
const tw = new TickwireClient({ baseUrl: "https://api.tickwire.io", token: "YOUR_API_KEY" });
const result = await tw.request("GET", "/users/current/accounts/YOUR_ACCOUNT_ID/capabilities");
console.log(result);
tw.close(); Try it in the sandbox
Try it is off in this build of the docs: no sandbox URL is configured. The samples above work against the sandbox with your sandbox key.
GET /users/current/accounts/{account_id}/orders
List pending orders Auth: auth-token
Every pending order on the account (limit, stop and stop-limit orders). Filled and cancelled orders are in the order history. Works on MT4 and MT5.
| Parameter | In | Type | Description |
|---|---|---|---|
account_id required | path | string | |
refreshTerminalState | query | string | null |
Responses
200The pending orders. An empty list when there are none. ·Order[]400Bad request. On the account API paths a body or query validation failure is a 400ValidationErrorwithdetails: [{parameter, message}]. ·ErrorEnvelope401No credential was sent, or it is not valid or has expired. ·ErrorEnvelope403The credential is valid but may not do this, for example a read-only key on a change, or a token without the needed role or account. ·ErrorEnvelope404The account does not exist or this credential cannot see it, or the position, order or symbol in the path was not found. ·ErrorEnvelope429Too many requests. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope503The terminal is not connected or not synchronized yet. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope
Errors (common for this kind of call; every error uses one envelope)
401unauthorized429rate_limited400, 422validation_error404account_not_found503not_connected
curl
curl -sS -X GET 'https://api.tickwire.io/users/current/accounts/YOUR_ACCOUNT_ID/orders' \
-H 'auth-token: YOUR_API_KEY' Python
from tickwire import Tickwire
with Tickwire("https://api.tickwire.io", "YOUR_API_KEY") as tw:
result = tw.request(
"GET",
"/users/current/accounts/YOUR_ACCOUNT_ID/orders",
)
print(result) TypeScript
import { TickwireClient } from "@tickwire/sdk";
const tw = new TickwireClient({ baseUrl: "https://api.tickwire.io", token: "YOUR_API_KEY" });
const result = await tw.request("GET", "/users/current/accounts/YOUR_ACCOUNT_ID/orders");
console.log(result);
tw.close(); Try it in the sandbox
Try it is off in this build of the docs: no sandbox URL is configured. The samples above work against the sandbox with your sandbox key.
GET /users/current/accounts/{account_id}/orders/{order_id}
Get a pending order Auth: auth-token
One pending order by its ticket.
An order that is not pending is 404 NotFoundError with
tickwireError: order_not_found. Works on MT4 and MT5.
| Parameter | In | Type | Description |
|---|---|---|---|
account_id required | path | string | |
order_id required | path | string | |
refreshTerminalState | query | string | null |
Responses
200The pending order. ·Order400Bad request. On the account API paths a body or query validation failure is a 400ValidationErrorwithdetails: [{parameter, message}]. ·ErrorEnvelope401No credential was sent, or it is not valid or has expired. ·ErrorEnvelope403The credential is valid but may not do this, for example a read-only key on a change, or a token without the needed role or account. ·ErrorEnvelope404The account does not exist or this credential cannot see it, or the position, order or symbol in the path was not found. ·ErrorEnvelope429Too many requests. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope503The terminal is not connected or not synchronized yet. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope
Errors (common for this kind of call; every error uses one envelope)
401unauthorized429rate_limited400, 422validation_error404account_not_found503not_connected
curl
curl -sS -X GET 'https://api.tickwire.io/users/current/accounts/YOUR_ACCOUNT_ID/orders/ORDER_ID' \
-H 'auth-token: YOUR_API_KEY' Python
from tickwire import Tickwire
with Tickwire("https://api.tickwire.io", "YOUR_API_KEY") as tw:
result = tw.request(
"GET",
"/users/current/accounts/YOUR_ACCOUNT_ID/orders/ORDER_ID",
)
print(result) TypeScript
import { TickwireClient } from "@tickwire/sdk";
const tw = new TickwireClient({ baseUrl: "https://api.tickwire.io", token: "YOUR_API_KEY" });
const result = await tw.request("GET", "/users/current/accounts/YOUR_ACCOUNT_ID/orders/ORDER_ID");
console.log(result);
tw.close(); Try it in the sandbox
Try it is off in this build of the docs: no sandbox URL is configured. The samples above work against the sandbox with your sandbox key.
GET /users/current/accounts/{account_id}/positions
List open positions Auth: auth-token
Every open position on the account.
id is the position identifier. On netting accounts it stays the same
across adds and partial closes. Realized profit, swap and commission come
from the position's deals. Works on MT4 and MT5.
| Parameter | In | Type | Description |
|---|---|---|---|
account_id required | path | string | |
refreshTerminalState | query | string | null |
Responses
200The open positions. An empty list when there are none. ·Position[]400Bad request. On the account API paths a body or query validation failure is a 400ValidationErrorwithdetails: [{parameter, message}]. ·ErrorEnvelope401No credential was sent, or it is not valid or has expired. ·ErrorEnvelope403The credential is valid but may not do this, for example a read-only key on a change, or a token without the needed role or account. ·ErrorEnvelope404The account does not exist or this credential cannot see it, or the position, order or symbol in the path was not found. ·ErrorEnvelope429Too many requests. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope503The terminal is not connected or not synchronized yet. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope
Errors (common for this kind of call; every error uses one envelope)
401unauthorized429rate_limited400, 422validation_error404account_not_found503not_connected
curl
curl -sS -X GET 'https://api.tickwire.io/users/current/accounts/YOUR_ACCOUNT_ID/positions' \
-H 'auth-token: YOUR_API_KEY' Python
from tickwire import Tickwire
with Tickwire("https://api.tickwire.io", "YOUR_API_KEY") as tw:
result = tw.request(
"GET",
"/users/current/accounts/YOUR_ACCOUNT_ID/positions",
)
print(result) TypeScript
import { TickwireClient } from "@tickwire/sdk";
const tw = new TickwireClient({ baseUrl: "https://api.tickwire.io", token: "YOUR_API_KEY" });
const result = await tw.request("GET", "/users/current/accounts/YOUR_ACCOUNT_ID/positions");
console.log(result);
tw.close(); Try it in the sandbox
Try it is off in this build of the docs: no sandbox URL is configured. The samples above work against the sandbox with your sandbox key.
GET /users/current/accounts/{account_id}/positions/{position_id}
Get a position Auth: auth-token
One open position by its id.
A position that is not open is 404 NotFoundError with
tickwireError: position_not_found. Works on MT4 and MT5.
| Parameter | In | Type | Description |
|---|---|---|---|
account_id required | path | string | |
position_id required | path | string | |
refreshTerminalState | query | string | null |
Responses
200The position. ·Position400Bad request. On the account API paths a body or query validation failure is a 400ValidationErrorwithdetails: [{parameter, message}]. ·ErrorEnvelope401No credential was sent, or it is not valid or has expired. ·ErrorEnvelope403The credential is valid but may not do this, for example a read-only key on a change, or a token without the needed role or account. ·ErrorEnvelope404The account does not exist or this credential cannot see it, or the position, order or symbol in the path was not found. ·ErrorEnvelope429Too many requests. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope503The terminal is not connected or not synchronized yet. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope
Errors (common for this kind of call; every error uses one envelope)
401unauthorized429rate_limited400, 422validation_error404account_not_found503not_connected
curl
curl -sS -X GET 'https://api.tickwire.io/users/current/accounts/YOUR_ACCOUNT_ID/positions/POSITION_ID' \
-H 'auth-token: YOUR_API_KEY' Python
from tickwire import Tickwire
with Tickwire("https://api.tickwire.io", "YOUR_API_KEY") as tw:
result = tw.request(
"GET",
"/users/current/accounts/YOUR_ACCOUNT_ID/positions/POSITION_ID",
)
print(result) TypeScript
import { TickwireClient } from "@tickwire/sdk";
const tw = new TickwireClient({ baseUrl: "https://api.tickwire.io", token: "YOUR_API_KEY" });
const result = await tw.request("GET", "/users/current/accounts/YOUR_ACCOUNT_ID/positions/POSITION_ID");
console.log(result);
tw.close(); Try it in the sandbox
Try it is off in this build of the docs: no sandbox URL is configured. The samples above work against the sandbox with your sandbox key.
GET /users/current/accounts/{account_id}/server-time
Get the server time Auth: auth-token
The current time in UTC and on the broker's clock, and the broker's time zone.
brokerUtcOffsetMinutes, dstRule (us, eu, none or unknown),
offsetSource and confidence say how the offset was found. A value
that is not known is null. It is never guessed. ?refresh=true checks
the terminal again.
| Parameter | In | Type | Description |
|---|---|---|---|
account_id required | path | string | |
refresh | query | string | null |
Responses
200Both clocks and the detected broker time zone. ·ServerTime400Bad request. On the account API paths a body or query validation failure is a 400ValidationErrorwithdetails: [{parameter, message}]. ·ErrorEnvelope401No credential was sent, or it is not valid or has expired. ·ErrorEnvelope403The credential is valid but may not do this, for example a read-only key on a change, or a token without the needed role or account. ·ErrorEnvelope404The account does not exist or this credential cannot see it, or the position, order or symbol in the path was not found. ·ErrorEnvelope429Too many requests. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope503The terminal is not connected or not synchronized yet. Wait theRetry-Afterseconds, then try again. ·ErrorEnvelope
Errors (common for this kind of call; every error uses one envelope)
401unauthorized429rate_limited400, 422validation_error404account_not_found503not_connected
curl
curl -sS -X GET 'https://api.tickwire.io/users/current/accounts/YOUR_ACCOUNT_ID/server-time' \
-H 'auth-token: YOUR_API_KEY' Python
from tickwire import Tickwire
with Tickwire("https://api.tickwire.io", "YOUR_API_KEY") as tw:
result = tw.request(
"GET",
"/users/current/accounts/YOUR_ACCOUNT_ID/server-time",
)
print(result) TypeScript
import { TickwireClient } from "@tickwire/sdk";
const tw = new TickwireClient({ baseUrl: "https://api.tickwire.io", token: "YOUR_API_KEY" });
const result = await tw.request("GET", "/users/current/accounts/YOUR_ACCOUNT_ID/server-time");
console.log(result);
tw.close(); Try it in the sandbox
Try it is off in this build of the docs: no sandbox URL is configured. The samples above work against the sandbox with your sandbox key.