Download OpenAPI specification:Download
We provide FX/CFD spot market participants with OMS/EMS sytems and toolset along with API for automated access by traders - to receive market data and manage positions and orders. It consists of REST API, Websocket API and FIX API.
Combination of the very same REST and Websocket API is used in 11B.io Trading GUI. API user will need to have account with 11B.io technology-based firm and, optionally, an API token.
You can also use Swagger-style description.
Check out our Github API examples repository
REST API provides basic set of functions to establish connection, download initial data, create, modify and cancel orders. 11B.io made sure that its REST API is completely sufficient to obtain real-time prices, maintain mirror of your positions and accounts at brokerage via set of simple requests. Ordering requests return completed states and eliminate the need to verify order status and position or account changes caused by execution.
Functionality includes: obtaining account and market data, placing orders, load account exposure. The GET and POST parameters need to be url-encoded. Response details will contain json structures. Certain endpoints are protected from flooding by enforcing 10rps from one IP. For more details - please, see below.
Websocket API is a bit more sophisticated interface as it provides access to streaming prices, messages and lower latency communications. In order to get benefits from being microseconds faster, you will need to implement message handling - prices that you're subscribed for, orders that are executed and positions that created.
The connection can be established using popular socket.io library, check out Javascript and Python implementations. 11B.io Websocket protocol is quite simple, and consists of connecting to wss:// endpoint, subscribing to the data and processing received data in sockets onMessage method.
There is no need to subscribe to messages related to your account; this is implied by connecting. The subscription to market data is done via emiting encoded json request soon after socket is connected. Parameters should contain the list of symbols and quote updates level:
Code | Subscription type |
---|---|
1 | Top of the book quotes (L1) |
2 | Depth quotes (L2) |
{type: 'subscribe', symbols: [{symbol: 'EUR/JPY', level: 1 }] }
You should start receiving messages like this one:
['L1',0,'2019-01-06T19:34:53.828539Z',['EUR/JPY',128.115,128.129,0,0]]
To unsubscribe, please, send the unsubscribe message or disconnect the socket. Please, check below Quote object structure for quote structure. Another type of messages that you will receive using this connection will contain field type
{type: 'unsubscribe', symbols: [{symbol: 'EUR/USD', level: 1 },...] }
Value of type field | Entity field name | Object included |
---|---|---|
OR | order | Order, single record |
AC | account | Account, signle record |
CP | closed_position | Closed Position, single record |
OP | position | Position, single record |
For example, new position:
{type: 'OP', action: 0, seq: 2, time: '2019-01-06T19:40:59.001994Z', position: {position_id: 27, symbol: 'EUR/USD', side: 'SELL', account_id: 'A00-000-00X', open_price: 1.12997, orig_quantity: 10000, quantity: 10000, open_order_id: 35, open_time: '2019-01-06T19:40:59.001994Z'}}
For messages with type field, please, pay attention to action field:
Code | Value | Description |
---|---|---|
0 | New | New object or creation |
1 | Updated | Updated object or change |
2 | Deleted | Deleted object or removal |
Also, you need to watch for socket disconnection using OnClose method to protect yourself from connection interrupptions. Please, see below for the WS opening call parameters.
FIX API is for institutional traders integration convenience but its a bit outside of scope of this description. Please, send us a request to api@11b.io along with your email and account name for docs, rules of engagement and dictionary. We support FIX 4.4 with few custom fields additionals added (optional, needed for retail flow support only: position maintenance orders, STOP_LOSS, TAKE_PROFIT order links, etc.)
To use 11B.io API, you will need to register live or demo account and then obtain API_URL, API_ACCOUNT and API_TOKEN (last is for Bearer authorization and optional, another choice is to use our authority server to obtain JWT token) - all via Trading GUI on System -> Settings page.
For your convenience, you can put tokens in config modules, see our examples:
config.js:
const config = {};
// Replace with your API KEY generated on Trading GUI System -> Settings page:
config.API_KEY = '77632e97-2767-4db2-a756-9f42aa0e7084';
config.API_URL = 'http://api.demo.11b.io/api/v1';
//config.API_URL = 'http://api.live.11b.io/api/v1';
config.API_ACCOUNT = 'XXX-XXX-XXX';
module.exports = config;
Make sure your API_TOKEN is secured and safe as it is sufficient enough to gain full control of trading on your account (provided ACCOUNT_ID is also exposed).
Token maintenance
Token response
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
Trading session data, accounts, symbols, currencies, quotes, positions, orders, closed positions for the day
Trading session data
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/accounts" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Get account information
List of available accounts
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/accounts" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Get list of supporte currencies
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/currencies" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Get list of available symbols
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/symbols" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Get list of active orders
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/orders" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Current financial day list of closed positions
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/closed_positions" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Get list of active positions
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/positions" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Get most recent prices for specified symbols
symbols required | string comma-separated list of symbols, e.g. EUR/USD,USD/JPY |
Quotes snapshot
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/quotes?symbols=EUR%2FUSD%2CUSD%2FJPY" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Get most recent prices for specified symbols
symbol required | string symbol, e.g. EUR/USD, USD/JPY |
duration required | string duration of one candle, M - month, W - Week, D - day, 60m - hour, 30m - 30 minutes, 15m - 15 minutes, 5m - 5 minues, 1m - 1 minute |
number | string number of the most recent candles, default - 300, max - 1000 |
Candles
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/quotes?symbols=EUR%2FUSD%2CUSD%2FJPY" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"
Modify Limit, Stop, StopLimit, Stop Loss or Take Profit order
order_id required | number Pass to modify or delete STOP, LIMIT, STOP_LIMIT, STOP_LOSS, TAKE_PROFIT orders. Example - 12345 |
price required | number Order price for STOP, LIMIT, STOP_LIMIT, STOP_LOSS and TAKE_PROFIT orders. For market orders, this price is just for reference - execution will be done at current market price. Example - 1.15123 |
Order response array
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
Create order
account_id | string Account identifier. Example - '000-0A0-1CE' |
symbol | string Symbol identifier. Example - 'EUR/USD' |
quantity | number Order quantity in contract currency, e.g., EUR for EUR/USD position. Example - 100000 |
side | string Enum:"BUY" "SELL" Buy or Sell. Example - 'BUY' |
order_type | string Enum:"MARKET" "STOP" "LIMIT" "STOP_LOSS" "TAKE_PROFIT" Order type. Can be opening or closing, depending on position_id or order_id parameters passing. Will also depend on underlying account position maintenance type. If hedging is not allowed, order will close earliest opposite position currently open on the account. Example - MARKET |
time_in_force | string Enum:"GTC" "FOK" "IOC" Time-in-force. Example - 'GTC' |
client_order_id | string Order request identifier. 512 bytes max. Example - '000-0A0-1CE:EUR/USD:BUY:Strategy.1' |
price required | number Order price for STOP, LIMIT, STOP_LIMIT, STOP_LOSS and TAKE_PROFIT orders. For market orders, this price is just for reference - execution will be done at current market price. Example - 1.15123 |
position_id | number Optional. Pass for position closing MARKET, STOP or LIMIT orders placement only. Example - 12345 |
order_id | number Optional. Pass to place STOP_LOSS or TAKE_PROFIT orders placement on WAITING STOP, LIMIT or STOP_LIMIT orders only. Example - 12345 |
stop_loss_price | number Optional. Use to attach STOP_LOSS order to the underlying order being created. Subject for validation against underlying opening order price. After underlying order execution, gets attached to newly open position. Example - 12345 |
take_profit_price | number Optional. Use to attach TAKE_PROFIT order to the underlying order being created. Subject for validation against underlying opening order price. After underlying order execution, gets attached to newly open position. Example - 12345 |
Order response array
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
Cancel WAITING or INACTIVE order
order_id required | number Pass to modify or delete STOP, LIMIT, STOP_LIMIT, STOP_LOSS, TAKE_PROFIT orders. Example - 12345 |
Order response array
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
Get report for the account positions, orders, closed positions, transactions for the period
account_id | string Account identifier. Example - '000-0A0-1CE' |
start_time | string Beginning Datetime in ISO 8601 format with 0 UTC offset: YYYY-MM-DDTHH:MI:SS.ffffffZ |
end_time | string Ending Datetime in ISO 8601 format with 0 UTC offset: YYYY-MM-DDTHH:MI:SS.ffffffZ |
Report data
Error: Unauthorized - wrong or expired access token
Error: too many requests, temporarily unavailable
demo trading server
curl -X GET "https://api.demo.11b.io/api/v1/accounts" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"