Network: Mainnet▼
Account & Balance Management
Manage trading accounts and check asset balances across trading accounts and order books.
1. Create Trading Account
Endpoint: POST /v1/accounts
Description: Create a new trading account contract for a user.
Request Body
curl -X POST \
"https://api.o2.app/v1/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"identity": {
"Address": "0xB54142d25D14E7cf0a9e709556071710E73A9cd184aCf79e60eAF6CCA909dC59"
}
}'Source: packages/api/src/app/routes/v1/accounts.rs:create_account_handler
2. Get Account Information
Endpoint: GET /v1/accounts
Description: Get trading account information.
Query Parameters
curl -X GET \
"https://api.o2.app/v1/accounts" \
-H "Accept: application/json"Source: packages/api/src/app/routes/v1/accounts.rs:get_account_handler
3. Get Account Balance
Endpoint: GET /v1/balance
Description: Get balance for a specific asset in a trading account.
Query Parameters
curl -X GET \
"https://api.o2.app/v1/balance" \
-H "Accept: application/json"Response Structure
Source: packages/api/src/app/routes/v1/coins.rs:38-44
order_books:locked: Balance currently locked in open orders (string)unlocked: Liquid balance available inside the book (string)
total_locked: Total locked balance across all books (string)total_unlocked: Total liquid balance to be settled across all books (string)trading_account_balance: Balance available in the trading account (string)
Example:
json
{
"order_books": {
"0xbook_id": {
"locked": "0",
"unlocked": "34878720000"
}
},
"total_locked": "0",
"total_unlocked": "59878720000",
"trading_account_balance": "25000000000"
}