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":
    [