Platforms

Use this method to get a list of platforms available in the B2Core UI.

GET[host]/api/v2/my/platforms

Get a list of platforms

Use these methods to get a list of orders, positions, or deals on MT4 and MT5.

GET[host]/api/v2/my/orders

Get a list of orders

GET[host]/api/v2/my/positions

Get a list of positions

GET[host]/api/v2/my/deals

Get a list of deals

Use these methods to authenticate the client who is signed in to the B2Core UI on the B2Trader platform.

POST[host]/api/v2/my/platforms/{platformId}/auth

Obtain the access token

POST[host]/api/v2/my/platforms/{platformId}/refresh

Refresh the access token

Get a list of platforms

Use this method to obtain a list of available platforms in the B2Core UI.

Request

Header parameters:

  • Authorization: Bearer <access_token>

  • Accept: application/json

GET[host]/api/v2/my/platforms

curl --request GET \
  --url https://host.name/api/v2/my/platforms \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <token>'

Response

A response contains an array of Platform objects providing information about the platforms available in the B2Core UI.

Get a list of orders

Use this method to get a list of orders placed by a client on MT4 and MT5.

Request

Header parameters:

  • Authorization: Bearer <access_token>

  • Accept: application/json

Query parameters:

The following filter parameters are available for this method:

type required

The platform on which orders are placed. Possible values:

  • mt4

  • mt5

accounts

An array of integer values specifying identifiers of trading accounts on which orders are placed.

side

The order type and side. Possible values:

  • 2 — buy limit

  • 3 — sell limit

  • 4 — buy stop

  • 5 — sell stop

from

The start date and time of a period during which orders were created.

to

The end date and time of a period during which orders were created.

The following sorting parameters are available for this method:

open_time

The opening time.

open_price

The opening price.

current_price

The current order price.

volume

The order volume.

take_profit

The price at which an asset must be bought or sold to ensure profit.

Refer to the Query parameters section in the API Overview for details on applying filter and sorting parameters.

GET[host]/api/v2/my/orders

curl --request GET \
  --url 'https://host.name/api/v2/my/orders?type=mt4' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <token>'

Response

A response contains an array of Order objects providing information about the orders matching the request parameters.

Get a list of positions

Use this method to get a list of positions opened to fill in the orders placed by a client on MT4 and MT5.

Request

Header parameters:

  • Authorization: Bearer <access_token>

  • Accept: application/json

Query parameters:

The following filter parameters are available for this method:

type required

The platform on which positions are opened. Possible values:

  • mt4

  • mt5

accounts

An array of integer values specifying identifiers of trading accounts on which positions are opened.

side

The order type and side. Possible values:

  • 2 — buy limit

  • 3 — sell limit

  • 4 — buy stop

  • 5 — sell stop

from

The start date and time of a period during which positions were opened.

to

The end date and time of a period during which positions were opened.

The following sorting parameters are available for this method:

open_time

The opening time.

open_price

The opening price.

current_price

The current price.

volume

The position volume.

take_profit

The price at which an asset must be bought or sold to ensure profit.

Refer to the Query parameters section in the API Overview for details on applying filter and sorting parameters.

GET[host]/api/v2/my/positions

curl --request GET \
  --url 'https://host.name/api/v2/my/positions?type=mt4' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <token>'

Response

A response contains an array of Position objects providing information about the positions matching the request parameters.

Get a list of deals

Use this method to obtain a list of deals executed to fill in the orders placed by a client on MT4 and MT5.

Request

Header parameters:

  • Authorization: Bearer <access_token>

  • Accept: application/json

Query parameters:

The following filter parameters are available for this method:

type required

The platform on which deals are executed. Possible values:

  • mt4

  • mt5

accounts

An array of integer values specifying identifiers of trading accounts on which deals are executed.

side

The order type and side. Possible values:

  • 2 — buy limit

  • 3 — sell limit

  • 4 — buy stop

  • 5 — sell stop

from

The start date and time of a period during which deals were executed.

to

The end date and time of a period during which deals were executed.

The following sorting parameters are available for this method:

open_time

The opening time.

open_price

The opening price.

current_price

The current price.

volume

The deal volume.

take_profit

The price at which an asset must be bought or sold to ensure profit.

Refer to the Query parameters section in the API Overview for details on applying filter and sorting parameters.

GET[host]/api/v2/my/deals

curl --request GET \
  --url 'https://host.name/api/v2/my/deals?type=mt4' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <token>'

Response

A response contains an array of Deal objects providing information about the deals matching the request parameters.

Obtain the access token

Use this method to obtain a pair of access and refresh tokens required for client authentication on B2Trader.

Request

Header parameters:

  • Authorization: Bearer <access_token>

  • Geo-Country-Code: <country_code>

  • Geo-Country-Name: <country_name>

Path parameters:

platformId required

The identifier of a trading platform on which you want to authenticate a client.

Currently, clients can be authenticated only on B2Trader.

POST[host]/api/v2/my/platforms/{platformId}/auth

curl --location --request POST 'https://host.name/api/v2/my/platforms/1/auth' \
--header 'Authorization: Bearer <token>' \
--header 'Geo-Country-Code: +995' \
--header 'Geo-Country-Name: Georgia'

Response

token string

The access token.

refreshToken string

The refresh token.

ttl string

The maximum time the tokens are valid (in seconds).

host string

The URL to which the request for obtaining a pair of access and refresh tokens was sent.

header string

Always Authorization.

RESPONSE EXAMPLE
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjU2MDY3MTU0LCJleHAiOjE2NTYxMDMxNTQsImlzcyI6Imh0dHBzOlwvXC9hcC52ZW5kb3IuY29tIn0.u6HuS_oQ4udk2EEUa-7XutJ0CAKIZty1OcFaqTckLRGYEr3xcWXZEHCfrhDl31N6_t0XP6_m-ESue_NoWx_f1sGMv6XMT0pPg1NQ1XJ1JJ4slaeEWjSuGIl8_Jbj-20zZOvwzUZbed7UQg0jUM11OUt0l1jVVSF19vKJJpVGFDYMIOHkS7tlFeKiypReYRd2af-Pf_au1v6vG3V42SFpZER3eKqALZkoT617B35enJdtUqmyrRgb_rCIOCwAHQdUcOuosyBUk9U-Cz3WEoHx5nqtvFVAeXKqlbn0Cbqk4joFt1FY8nUqlyVZNI9E3-dbjFPzod8Vej6rkAVd312M3w",
  "refreshToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjU2MDY3MTU0LCJleHAiOjE2NTYxMDMxNTQsImlzcyI6Imh0dHBzOlwvXC9hcC52ZW5kb3IuY29tIn0.u6HuS_oQ4udk2EEUa-7XutJ0CAKIZty1OcFaqTckLRGYEr3xcWXZEHCfrhDl31N6_t0XP6_m-ESue_NoWx_f1sGMv6XMT0pPg1NQ1XJ1JJ4slaeEWjSuGIl8_Jbj-20zZOvwzUZbed7UQg0jUM11OUt0l1jVVSF19vKJJpVGFDYMIOHkS7tlFeKiypReYRd2af-Pf_au1v6vG3V42SFpZER3eKqALZkoT617B35enJdtUqmyrRgb_rCIOCwAHQdUcOuosyBUk9U-Cz3WEoHx5nqtvFVAeXKqlbn0Cbqk4joFt1FY8nUqlyVZNI9E3-dbjFPzod8Vej6rkAVd312M3w",
  "ttl": "60",
  "host": "http://example.com",
  "header": "Authorization"
}

Refresh the access token

You can use a valid refresh token to obtain a new pair of access and refresh tokens required for client authentication on B2Trader.

Request

Header parameters:

  • Authorization: Bearer <access_token>

Path parameters:

platformId required

The identifier of a trading platform on which you want to authenticate a client.

Currently, clients can be authenticated only on B2Trader.

Body:

refreshToken string required

The refresh token that was previously issued for a client.

POST[host]/api/v2/my/platforms/{platformId}/refresh

curl --location --request POST 'https://host.name/api/v2/my/platforms/1/refresh' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
  "refreshToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjU2MDY3MTU0LCJleHAiOjE2NTYxMDMxNTQsImlzcyI6Imh0dHBzOlwvXC9hcC52ZW5kb3IuY29tIn0.u6HuS_oQ4udk2EEUa-7XutJ0CAKIZty1OcFaqTckLRGYEr3xcWXZEHCfrhDl31N6_t0XP6_m-ESue_NoWx_f1sGMv6XMT0pPg1NQ1XJ1JJ4slaeEWjSuGIl8_Jbj-20zZOvwzUZbed7UQg0jUM11OUt0l1jVVSF19vKJJpVGFDYMIOHkS7tlFeKiypReYRd2af-Pf_au1v6vG3V42SFpZER3eKqALZkoT617B35enJdtUqmyrRgb_rCIOCwAHQdUcOuosyBUk9U-Cz3WEoHx5nqtvFVAeXKqlbn0Cbqk4joFt1FY8nUqlyVZNI9E3-dbjFPzod8Vej6rkAVd312M3w"
}'

Response

token string

The access token.

refreshToken string

The refresh token.

ttl string

The maximum time the tokens are valid (in seconds).

host string

The URL to which the request for obtaining a pair of access and refresh tokens was sent.

header string

Always Authorization.

RESPONSE EXAMPLE
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjU2MDY3MTU0LCJleHAiOjE2NTYxMDMxNTQsImlzcyI6Imh0dHBzOlwvXC9hcC52ZW5kb3IuY29tIn0.u6HuS_oQ4udk2EEUa-7XutJ0CAKIZty1OcFaqTckLRGYEr3xcWXZEHCfrhDl31N6_t0XP6_m-ESue_NoWx_f1sGMv6XMT0pPg1NQ1XJ1JJ4slaeEWjSuGIl8_Jbj-20zZOvwzUZbed7UQg0jUM11OUt0l1jVVSF19vKJJpVGFDYMIOHkS7tlFeKiypReYRd2af-Pf_au1v6vG3V42SFpZER3eKqALZkoT617B35enJdtUqmyrRgb_rCIOCwAHQdUcOuosyBUk9U-Cz3WEoHx5nqtvFVAeXKqlbn0Cbqk4joFt1FY8nUqlyVZNI9E3-dbjFPzod8Vej6rkAVd312M3w",
  "refreshToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjU2MDY3MTU0LCJleHAiOjE2NTYxMDMxNTQsImlzcyI6Imh0dHBzOlwvXC9hcC52ZW5kb3IuY29tIn0.u6HuS_oQ4udk2EEUa-7XutJ0CAKIZty1OcFaqTckLRGYEr3xcWXZEHCfrhDl31N6_t0XP6_m-ESue_NoWx_f1sGMv6XMT0pPg1NQ1XJ1JJ4slaeEWjSuGIl8_Jbj-20zZOvwzUZbed7UQg0jUM11OUt0l1jVVSF19vKJJpVGFDYMIOHkS7tlFeKiypReYRd2af-Pf_au1v6vG3V42SFpZER3eKqALZkoT617B35enJdtUqmyrRgb_rCIOCwAHQdUcOuosyBUk9U-Cz3WEoHx5nqtvFVAeXKqlbn0Cbqk4joFt1FY8nUqlyVZNI9E3-dbjFPzod8Vej6rkAVd312M3w",
  "ttl": "60",
  "host": "http://example.com",
  "header": "Authorization"
}