For the complete documentation index, see llms.txt. This page is also available as Markdown.

Settings

Configure account margin settings, get market parameters, trading sessions, asset details, and system preferences for optimal trading setup

Accounts

Get accounts

GET /frontoffice/api/v3/accounts

Summary

Use this method to retrieve a list of all trading accounts with their basic information including account type and total balance.

Request

No request parameters.

Request example
GET /frontoffice/api/v3/accounts HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Accept: */*

Response

In case of success, an array of objects will be returned.

Each object contains the following information:

accountId string

The trading account identifier.

publicAccountId integer

The public account identifier for display purposes.

accountName string

The account name.

accountType string

The account type.

Possible values:

  • Hedging

  • Netting

totalBalanceInRAT decimal string

The total balance, in RAT.

isCopyTradingAccount boolean

Indicates if the account is Copy.

Response example — 200: OK
[
  {
    "accountId": "685a7eaa360f9e7416221a61",
    "publicAccountId": 1234567,
    "accountName": "B2PRIME Hedging account",
    "accountType": "Hedging",
    "totalBalanceInRAT": "6020.12",
    "isCopyTradingAccount": false
  },
  {
    "accountId": "6891e70db552ff9c6fbbccf5",
    "publicAccountId": 1234568,
    "accountName": "B2PRIME Netting account",
    "accountType": "Netting",
    "totalBalanceInRAT": "10987.39",
    "isCopyTradingAccount": false
  }
]

Assets

Get assets

GET /frontoffice/api/v3/assets

Summary

Use this method to retrieve a list of available assets on the platform.

Request

No request parameters.

Response

In case of success, an array of objects will be returned.

Each object contains the following information:

assetId string

The asset identifier.

assetName string

The asset display name.

isRootAsset boolean

Indicates whether this is a root asset.

Markets

Get markets

GET /frontoffice/api/v6/markets

Summary

Use this method to retrieve a list of available markets with their type, subtype, and favorite status.

Request

Query parameters

categoryId

The market category identifier.

dynamicCommissionGroupId

The dynamic commission group identifier.

isFavorite boolean

Filter by favorite status. If set to true, only markets marked as favorites are returned.

Response

In case of success, an array of market objects is returned.

Each market object contains the following information:

marketId string

The market identifier, in the following format: {marketType}.{baseAssetId}_{quoteAssetId}, for example: cfd.eth_eur.

displayName string

The market ticker.

fullName string | nullable

The market full name or description.

type string

The market type.

Possible values:

  • Spot

  • Cfd

  • Perp

subtype string | nullable

Applicable to CFD markets only.

The market subtype.

Possible values:

  • Crypto

  • Fx

  • Metals

  • Indices

  • Energies

  • Ndf

  • Shares

  • Etf

isFavorite boolean

Indicates whether the market is marked as a favorite by the current user.

Get market

GET /frontoffice/api/v6/markets/{marketId}

Summary

Use this method to retrieve detailed information about a specific market using its market identifier.

Request

Path parameters

marketId required

The market identifier, in the following format: {marketType}.{baseAssetId}_{quoteAssetId}, for example: cfd.eth_eur.

Response

In case of success, an object will be returned.

Each object contains the following information:

marketId string

The market identifier, in the following format: {marketType}.{baseAssetId}_{quoteAssetId}, for example: cfd.eth_eur.

displayName string

The market ticker.

fullName string | nullable

The market full name or description (optional).

baseAssetId string

The base asset identifier.

quoteAssetId string

The quote asset identifier.

minAmount decimal string | nullable

Applicable to Spot markets only.

The minimum tradable amount of the base asset.

maxBaseAmount decimal string | nullable

The maximum tradable amount of the base asset.

priceDeviation decimal string

The allowed price deviation for Limit orders placed on the market.

Supports decimal values in the range [0, 1], with up to 4 decimal places, for example:

  • 0.1 = 10%

  • 0.01 = 1%

  • 0.001 = 0.1%

  • 0.0001 = 0.01%

If set to 0, no restriction is applied, the price deviation is ignored.

priceScale integer

The price precision, which is the number of digits after a decimal separator. Also determines the minimum allowed trade price.

Supports only integer values in the range [2, 8]. For example, 2 means the following price format: 0.01, and 8: 0.00000001.

amountScale integer | nullable

Applicable to Spot markets only.

The amount precision, which is the number of digits after a decimal separator. Also determines the minimum trade amount.

Supports only integer values in the range [0, 8]. For example:

  • 0 means 1 (no digits after the decimal separator)

  • 5 means 0.00001 (five digits after the decimal separator)

  • 8 means 0.00000001 (eight digits after the decimal separator)

type string

The market type.

Possible values:

  • Spot

  • Cfd

  • Perp

subtype string | nullable

Applicable to CFD markets only.

The market subtype.

Possible values:

  • Crypto

  • Fx

  • Metals

  • Indices

  • Energies

  • Ndf

  • Shares

  • Etf

swapSettings object | nullable

Applicable to CFD markets only.

The fee type charged for holding open positions overnight. The amount can be negative for rebates.

Possible values:

  • FixPerLot: The fixed amount per lot.

  • Percent: The fixed amount in points which is applied to the position size, in the range [-1, 1], with up to 5 decimal places.

  • Points: The fixed amount of percents which is applied to the position size, with up to 3 decimal places.

Structure:

  • type string — Swap calculation type. Possible values: FixPerLot, Percent, Points.

  • shortPositionSettings object — Settings for Short positions:

    • size decimal string

    • assetId string | nullable

  • longPositionSettings object — Settings for Long positions:

    • size decimal string

    • assetId string | nullable

lotSize integer | nullable

Not applicable to Spot markets.

The standardized quantity of the base asset per lot.

Supports only integer values in the range [1, 1000000].

minLotAmount decimal string | nullable

Not applicable to Spot markets.

The minimum order amount, in lots, that can be placed and executed.

Supports values in the range [0.00000001, 1].

maxLotAmount integer | nullable

Not applicable to Spot markets.

The maximum order amount, in lots, that can be placed and executed.

Supports only integer values in the range [1, 10000].

tickSize decimal string | nullable

Not applicable to Spot markets.

The minimum price increment.

lotStep decimal string | nullable

Not applicable to Spot markets.

The minimum lot amount increment.

Supports values in the range [0.00000001, 1]. By default, equals to the minLotAmount.

slippageRate decimal string

The expected slippage, that is, the difference between the expected execution price and the actual one. This value is used as a multiplier to calculate the funds to be put on hold for a market order execution.

Supports values in the range [1, 10], including decimal values with up to 4 decimal places. The default value is 1 which means that only the current bid/ask price is put on hold. For example, 1.1 means that the current bid or ask price + 10% is put on hold for each order, to cover the 10% slippage.

Mind that the total amount funds to be held depends on the order parameters and takes into account many conditions, the slippage rate is only one of them.

calendar object

The trading calendar defining market trading hours.

Structure:

  • timeZoneId string — IANA time zone identifier.

  • tradingSessions array — Weekly trading sessions:

    • dayOfWeek string — One of: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

    • timeIntervals array — List of intervals with:

      • start string (time) — Start time in calendar.timeZoneId.

      • end string (time) — End time in calendar.timeZoneId.

  • sessionOverrides array — Optional specific-date overrides:

    • date string (date) — In YYYY-MM-DD format.

    • timeIntervals array | nullable — Intervals for that date.

fundingStartTime string | nullable

Applicable to Perpetual markets only.

The time of the first funding settlement, in the following format: HH:MM:SS.

fundingIntervalInHours integer | nullable

Applicable to Perpetual markets only.

The funding settlement interval, in hours.

Possible values: 1, 2, 3, 4, 6, 8, 12, 24.

leverageProfile object

Not applicable to Spot markets.

The leverage profile.

Structure:

  • leverageType string — Leverage type. Possible values: Fixed, Dynamic.

  • leverage object

    • useOnlyMaxLeverage boolean

    • maxLeverage integer — For Fixed leverage type only.

    • tiers array — For Dynamic leverage type only.

      • maxLeverage integer — The maximum allowed leverage for this tier.

      • maxNotionalValueInRAT string | nullable — The maximum position notional for this tier.

commissionSettings object

The commission settings.

Structure:

  • type string — Leverage type. Possible values: Fixed, Dynamic.

  • charge object

    • type string — Possible values: Percent, FixPerLot.

    • assetId string | nullable — For Fixed commission type only.

    • size decimal string — For Fixed commission type only.

    • tiers array — For Dynamic commission type only.

      • size string — The commission amount for this tier.

      • minTradingVolumeInRAT string — The minimum required trading volume for this tier.

    • minCommissionInRAT decimal string | nullable

  • dynamicCommissionGroupId

isFavorite boolean

Indicates whether the market is marked as a favorite by the current user.


Add favorite market

POST /frontoffice/api/v6/markets/favorites/add

Summary

Add a market to the current user's favorites list.

Request

Body

marketId string required

The market identifier to add to favorites.

Response

In case of success (200), an empty object is returned.


Remove favorite market

POST /frontoffice/api/v6/markets/favorites/delete

Summary

Remove a market from the current user's favorites list.

Request

Body

marketId string required

The market identifier to remove from favorites.

Response

In case of success (200), an empty object is returned.

Account margin settings

Get margin assets

GET /frontoffice/api/v4/account-margin-settings/assets

Summary

Use this method to retrieve a list of assets that can be used as collateral for margin trading.

Request

No request parameters.

Response

In case of success, an object will be returned.

Each object contains the following information:

assets array

A list of assets that can be used as a collateral for margin trading.

Each array item contains:

assetId string

The asset identifier.

assetName string

The asset display name.

available decimal string

The available asset balance.

This value is calculated as Total balanceLocked balance.

total decimal string

The overall amount of the asset, including locked funds.

marginRatio decimal string

The percentage of the asset value used as a collateral.

Supports values in the range [0, 1], where 1 represents 100.00%.

isSelected boolean

Indicates whether the asset is selected to be used as collateral.

Can be true only for assets with the marginRatio more than 0.

Select margin asset

POST /frontoffice/api/v4/account-margin-settings/assets/{assetId}

Summary

Use this method to enable a particular asset to be used as collateral for margin trading.

Only assets with the marginRatio more than 0 can be selected.

Request

Path parameters

assetId required

The asset identifier.

Response

In case of success, an empty object will be returned.

Disable margin asset

DELETE /frontoffice/api/v4/account-margin-settings/assets/{assetId}

Summary

Use this method to prohibit a specific asset from being used as collateral for margin trading.

Request

Path parameters

assetId required

The asset identifier.

Response

In case of success, an empty object will be returned.

Info

Get server info

GET /frontoffice/api/v3/info

Summary

Use this method to retrieve current server time and timezone information.

Request

No request parameters.

Response

In case of success, an object will be returned.

Each object contains the following information:

serverTime string

The server time, in the Unix timestamp format.

serverTimeZone string

The server time zone.

Get server time zones

GET /frontoffice/api/v3/info/time-zones

Summary

Use this method to retrieve available server time zones.

Request

No request parameters.

Response

In case of success, an array of objects will be returned.

Each object contains the following information:

id string

The time zone identifier.

offset string

The UTC offset, in the following format: HH:MM:SS.

offsetInMinutes integer · int32

The UTC offset in minutes.

shortLabel string

The short label for the time zone.

label string

The display label for the time zone.

Webhooks

Create webhook API key

POST /frontoffice/api/v3/webhook/api-keys

Summary

Create a new webhook API key for receiving TradingView alerts.

Request

Header parameters

Authorization required

Bearer JWT token with trading-ui permission.

Body

name string required

A descriptive name for the API key, up to 100 characters.

Response

In case of success (201), the created API key object is returned.

id string

The unique identifier of the API key.

apiKey string

The full API key value. The key is shown only once at creation.

name string

The name assigned to the key.

userId string

The user identifier the key is bound to.

status string

The key status: Active.

createdAt string

The timestamp when the key was created.

expiresAt string

The timestamp when the key expires (one year from creation).


List webhook API keys

GET /frontoffice/api/v3/webhook/api-keys

Summary

Retrieve all webhook API keys for the authenticated user along with the webhook URL.

Request

Header parameters

Authorization required

Bearer JWT token with trading-ui permission.

Response

In case of success (200), the webhook URL and a list of API keys are returned.

webhookUrl string

The webhook URL to configure in TradingView alerts.

apiKeys array of objects

The list of API keys.

apiKeys[].id string

The unique identifier of the API key.

apiKeys[].name string

The name assigned to the key.

apiKeys[].status string

The key status.

Possible values:

  • Active

  • Revoked

  • Expired

apiKeys[].createdAt string

The timestamp when the key was created.

apiKeys[].expiresAt string

The timestamp when the key expires.


Revoke webhook API key

DELETE /frontoffice/api/v3/webhook/api-keys/{id}

Summary

Revoke an active webhook API key. After revocation, the key can no longer be used to authenticate webhook requests.

Request

Header parameters

Authorization required

Bearer JWT token with trading-ui permission.

Path parameters

id string required

The unique identifier of the API key to revoke.

Response

In case of success (200), a confirmation object is returned.

success boolean

Indicates whether the key was revoked successfully.

message string

A description of the result.


Receive TradingView alert

POST /frontoffice/api/v3/webhook/alerts/{userId}

Summary

Accept a webhook alert from TradingView and place an order on the specified trading account. TradingView calls this endpoint when an alert triggers.

Request

Path parameters

userId string required

The B2PRIME user identifier (ULID format).

Body

apiKey string required

The webhook API key for authentication.

accountId string required

The trading account identifier.

symbol string required

The market symbol with a type prefix (spot., cfd., or perp.) followed by the pair name. For example: spot.btc_usdt, cfd.eur_usd, perp.btc_usdt.

side string required

The order side.

Possible values:

  • buy

  • sell

quantity decimal string required

The order quantity in the base asset.

orderType string

The order type. Default: market.

Possible values:

  • market

  • limit

  • stop

  • stop_limit

price decimal string

The limit price. Required for limit and stop_limit orders.

stopPrice decimal string

The stop price. Required for stop and stop_limit orders.

leverage decimal string

The leverage ratio. Applicable to CFD and Perpetual Futures markets only.

takeProfit decimal string

The take profit trigger price.

stopLoss decimal string

The stop loss trigger price.

timeInForce string

The time-in-force policy. Default: gtc.

Possible values:

  • gtc

  • ioc

  • fok

  • day

comment string

A custom comment, up to 256 characters.

deduplicationId string

A UUID for idempotency. Duplicate requests with the same ID within five minutes return a cached response.

Response

In case of success (200), an order confirmation is returned.

success boolean

Indicates whether the order was placed successfully.

orderId string

The unique identifier of the created order.

orderStatus string

The initial status of the order.

message string

A description of the result.

timestamp string

The timestamp of the response.

Rate limits

Webhook requests are limited to five requests per second per user. If the limit is exceeded, the response returns a 429 status code with the following headers:

  • X-RateLimit-Limit: Maximum requests per window

  • X-RateLimit-Remaining: Remaining requests in the current window

  • X-RateLimit-Reset: Unix timestamp when the window resets

Last updated

Was this helpful?