Skip to main content
GET
/
api
/
v1
/
balances
Retrieve account balances
curl --request GET \
  --url https://user-account.sandbox.rails.xyz/api/v1/balances \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://user-account.sandbox.rails.xyz/api/v1/balances"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://user-account.sandbox.rails.xyz/api/v1/balances', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://user-account.sandbox.rails.xyz/api/v1/balances",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://user-account.sandbox.rails.xyz/api/v1/balances"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://user-account.sandbox.rails.xyz/api/v1/balances")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://user-account.sandbox.rails.xyz/api/v1/balances")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "balances": {
    "totalBalance": "99996952.15429778",
    "crossMarginBalance": "99234631.40719179",
    "availableBalance": "99521353.92161779",
    "withdrawableBalance": "92673870.38",
    "deposit": "100000000",
    "withdraw": "879.12",
    "withdrawFees": "8.88",
    "fees": "608.02030021",
    "pnl": "-1292.78457349",
    "funding": "-259.04082851",
    "volume": "608020.300274",
    "margin": "7261788.9945241110003337",
    "maintenanceMargin": "475598.23267999",
    "leverage": "5",
    "accountLeverage": "0.081046795550007",
    "promoCredit": "0",
    "transferIn": "0",
    "transferOut": "0",
    "marketBalancesMap": {
      "BTC-USDT": {
        "position": "467782.520726",
        "positionQuantity": "7",
        "liquidationPrice": "126380.268279734335477455",
        "openBuy": "60000",
        "openBuyQty": "1",
        "openSell": "0",
        "openSellQty": "0",
        "pnl": "-1292.78457349",
        "positionPnl": "-1292.7845734999864",
        "funding": "113.21723468000002",
        "positionFunding": "113.21723468000002",
        "volume": "600695.07832",
        "fees": "600.69507826",
        "liquidationFees": "0",
        "margin": "6498468.2474181248786156",
        "maintenanceMargin": "527842.520726",
        "indexPrice": "66826.074",
        "unrealizedPnl": "-456.32",
        "leverage": "2",
        "marginMode": "C"
      },
      "ETH-USDT": {
        "position": "28894.648055999998",
        "positionQuantity": "8",
        "liquidationPrice": "28902.648056",
        "openBuy": "0",
        "openBuyQty": "0",
        "openSell": "8000",
        "openSellQty": "3",
        "pnl": "406.23975999",
        "positionPnl": "406.2397599999995",
        "funding": "-486.82005787000037",
        "positionFunding": "-486.82005787000037",
        "volume": "43545.091964",
        "fees": "43.54509196",
        "liquidationFees": "0",
        "margin": "762320.7471059860003337",
        "maintenanceMargin": "28902.648056",
        "indexPrice": "3611.831",
        "unrealizedPnl": "189.54",
        "leverage": "5",
        "marginMode": "I"
      }
    }
  }
}
{
"message": "Unauthorized"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

market
string

Market name. Example value: ETH-USDT. To get all supported markets, call /api/v1/markets endpoint. Omit this parameter to get results across all markets.

Response

balances
object
required

Account balances and related financial information.