11B.io Trading API (0.1.0)

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

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

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

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.)

Credentials and access

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).

Authentication

Token

JWT for GUI or Bearer for API

Security scheme type: API Key
header parameter name: Authorization

GUI

GUI only - restricted to JWT Token. Restricted to 1 request per minute.

Revoke or generate API token

Token maintenance

Authorizations:

Responses

200

Token response

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

post /token

demo trading server

http://api.demo.11b.io/token

Response samples

application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Session

Broker and Trader settings and collateral.

Get current trading session data

Trading session data, accounts, symbols, currencies, quotes, positions, orders, closed positions for the day

Authorizations:

Responses

200

Trading session data

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /session

demo trading server

http://api.demo.11b.io/session

Request samples

Copy
curl -X GET "https://api.demo.11b.io/api/v1/accounts" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "currencies":
    [
    ],
  • "symbols":
    [
    ],
  • "accounts":
    [
    ],
  • "positions":
    [
    ],
  • "orders":
    [
    ],
  • "closed_positions":
    [
    ]
}

Get account

Get account information

Authorizations:

Responses

200

List of available accounts

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /accounts

demo trading server

http://api.demo.11b.io/accounts

Request samples

Copy
curl -X GET "https://api.demo.11b.io/api/v1/accounts" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "accounts":
    [
    ]
}

Get currencies

Get list of supporte currencies

Authorizations:

Responses

200
401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /currencies

demo trading server

http://api.demo.11b.io/currencies

Request samples

Copy
curl -X GET "https://api.demo.11b.io/api/v1/currencies" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "currencies":
    [
    ]
}

Get symbols and symbol-related parameters

Get list of available symbols

Authorizations:

Responses

200
401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /symbols

demo trading server

http://api.demo.11b.io/symbols

Request samples

Copy
curl -X GET "https://api.demo.11b.io/api/v1/symbols" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "symbols":
    [
    ]
}

Exposure

Trading activity records - open positions, active orders and history

Get orders

Get list of active orders

Authorizations:

Responses

200
401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /orders

demo trading server

http://api.demo.11b.io/orders

Request samples

Copy
curl -X GET "https://api.demo.11b.io/api/v1/orders" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "orders":
    [
    ]
}

Get closed positions

Current financial day list of closed positions

Authorizations:

Responses

200
401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /closed_positions

demo trading server

http://api.demo.11b.io/closed_positions

Request samples

Copy
curl -X GET "https://api.demo.11b.io/api/v1/closed_positions" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "closed_positions":
    [
    ]
}

Get current positions

Get list of active positions

Authorizations:

Responses

200
401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /positions

demo trading server

http://api.demo.11b.io/positions

Request samples

Copy
curl -X GET "https://api.demo.11b.io/api/v1/positions" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "positions":
    [
    ]
}

Market Data

Trading operations - obtaining market data

Get current prices

Get most recent prices for specified symbols

Authorizations:
query Parameters
symbols
required
string

comma-separated list of symbols, e.g. EUR/USD,USD/JPY

Responses

200

Quotes snapshot

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /quotes

demo trading server

http://api.demo.11b.io/quotes

Request samples

Copy
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"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "quotes_snapshot":
    [
    ]
}

Get price history

Get most recent prices for specified symbols

Authorizations:
query Parameters
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

Responses

200

Candles

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /candles

demo trading server

http://api.demo.11b.io/candles

Request samples

Copy
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"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "candles":
    [
    ]
}

Trading

Trading operations - create, modify and cancel orders

Update Order

Modify Limit, Stop, StopLimit, Stop Loss or Take Profit order

Authorizations:
Request Body schema: application/x-www-form-urlencoded
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

Responses

200

Order response array

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

patch /orders

demo trading server

http://api.demo.11b.io/orders

Response samples

application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Create Order

Create order

Authorizations:
Request Body schema: application/x-www-form-urlencoded
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

Responses

200

Order response array

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

post /orders

demo trading server

http://api.demo.11b.io/orders

Response samples

application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Cancel Order

Cancel WAITING or INACTIVE order

Authorizations:
Request Body schema: application/x-www-form-urlencoded
order_id
required
number

Pass to modify or delete STOP, LIMIT, STOP_LIMIT, STOP_LOSS, TAKE_PROFIT orders. Example - 12345

Responses

200

Order response array

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

delete /orders

demo trading server

http://api.demo.11b.io/orders

Response samples

application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Reports

Account Reports

Get trading activity for the period

Get report for the account positions, orders, closed positions, transactions for the period

Authorizations:
Request Body schema: application/x-www-form-urlencoded
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

Responses

200

Report data

401

Error: Unauthorized - wrong or expired access token

503

Error: too many requests, temporarily unavailable

get /report

demo trading server

http://api.demo.11b.io/report

Request samples

Copy
curl -X GET "https://api.demo.11b.io/api/v1/accounts" -H "accept: application/json" -H "Authorization: Bearer 3657b4ae-a2ae-4e13-bdbd-657e1a1dc12d"

Response samples

application/json
Copy
Expand all Collapse all
{
  • "status": 0,
  • "time": "2019-01-09T01:41:16.501Z",
  • "error":
    {
    },
  • "accounts":
    [
    ],
  • "positions":
    [
    ],
  • "orders":
    [
    ],
  • "closed_positions":
    [
    ],
  • "transactions":
    [
    ]
}