GET /user/{pubkey}
Returns account information for a user including balances, positions, and open orders.
Request
Path Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
pubkey | string | Yes | Base58-encoded user public key |
curl https://zo-mainnet.n1.xyz/user/YourBase58PubkeyHereResponse
{
"pubkey": "YourBase58PubkeyHere",
"accountId": 12345,
"balances": [
{
"tokenId": 1,
"available": 10000.0,
"locked": 500.0,
"total": 10500.0
}
],
"positions": [
{
"marketId": 0,
"size": 0.5,
"entryPrice": 92000.0,
"unrealizedPnl": 250.0,
"liquidationPrice": 75000.0
}
],
"orders": [
{
"orderId": 12345,
"marketId": 0,
"side": "bid",
"price": 90000.0,
"size": 0.1,
"filledSize": 0.0,
"status": "open"
}
]
}Response Fields
Balances
| Field | Type | Description |
|---|---|---|
tokenId | number | Token identifier |
available | number | Balance available for trading |
locked | number | Balance locked in open orders |
total | number | Total balance (available + locked) |
Positions
| Field | Type | Description |
|---|---|---|
marketId | number | Market identifier |
size | number | Position size (positive = long, negative = short) |
entryPrice | number | Average entry price |
unrealizedPnl | number | Current unrealized profit/loss |
liquidationPrice | number | Estimated liquidation price |
Orders
| Field | Type | Description |
|---|---|---|
orderId | number | Unique order identifier |
marketId | number | Market identifier |
side | string | ”bid” (buy) or “ask” (sell) |
price | number | Order price |
size | number | Order size |
filledSize | number | Amount already filled |
status | string | Order status (“open”, “partial”, etc.) |
Example: Python
import requests
from base58 import b58encode
API_URL = "https://zo-mainnet.n1.xyz"
def get_user_info(user_pubkey: bytes):
"""Fetch user account information."""
pubkey_b58 = b58encode(user_pubkey).decode()
resp = requests.get(f"{API_URL}/user/{pubkey_b58}")
return resp.json()
info = get_user_info(user_pubkey)
# Print balances
for balance in info["balances"]:
print(f"Token {balance['tokenId']}: {balance['available']:.2f} available")
# Print positions
for pos in info["positions"]:
if pos["size"] != 0:
print(f"Market {pos['marketId']}: {pos['size']:+.4f} @ ${pos['entryPrice']:,.2f}")
# Print open orders
for order in info["orders"]:
side = "BUY" if order["side"] == "bid" else "SELL"
print(f"Order {order['orderId']}: {side} {order['size']:.4f} @ ${order['price']:,.2f}")Example: cURL + jq
# Get user balances
curl -s "https://zo-mainnet.n1.xyz/user/YOUR_PUBKEY" | jq '.balances'
# Get open positions only
curl -s "https://zo-mainnet.n1.xyz/user/YOUR_PUBKEY" | jq '.positions | map(select(.size != 0))'
# Get open order count
curl -s "https://zo-mainnet.n1.xyz/user/YOUR_PUBKEY" | jq '.orders | length'Last updated on