Skip to main content

V2 API endpoints

QuantDesk’s backend gateway exposes a V2 namespace for aggregated on-chain state and social surfaces. Field-level request and response shapes live in Swagger (/api/docs/); this page explains what each route is for and how to use it safely.

Base path

EnvironmentBase URL
Local devhttp://localhost:3002/api/v2
Productionhttps://api.quantdesk.app/api/v2
Legacy /api/v1 routes are deprecated for new integrations.

Authentication

Route groupAuth required
/portfolio/*Yes — wallet session or Bearer token (see Authentication)
/referrals/validateYes
/markets/orderbook/:marketNo
/leaderboardNo

Portfolio (unified state)

These routes return portfolio state aggregated by the backend gateway (indexed from on-chain PortfolioAccount data). For lowest latency, parse the account buffer directly via RPC.

GET /api/v2/portfolio

Returns the full unified portfolio: balances, positions, and open orders in one payload.
curl -s -H "Authorization: Bearer $QD_TOKEN" \
  "$QD_API/api/v2/portfolio" | jq .
Common response codes
CodeMeaning
200Portfolio found
404PORTFOLIO_NOT_FOUND — wallet has not initialized a V2 portfolio yet
401Missing or expired auth

GET /api/v2/portfolio/positions

Positions slice only — useful when you already cache balances elsewhere.

GET /api/v2/portfolio/orders

Open orders slice only — pairs well with the orderbook route for depth context.
[!TIP] For sub-millisecond on-chain reads, parse the PortfolioAccount buffer directly. See Parsing the PortfolioAccount buffer.

Markets (crankless orderbook)

GET /api/v2/markets/orderbook/:market

Returns global BST depth for a market symbol (for example SOL-PERP).
curl -s "$QD_API/api/v2/markets/orderbook/SOL-PERP" | jq .
Response shape (conceptual)
FieldMeaning
successRequest succeeded
sourceredis (hot path) or supabase (fallback snapshot)
dataBid/ask levels from the on-chain slab monitor
The gateway tries Redis first for sub-millisecond delivery, then falls back to the market_orderbooks table if the cache is cold.

Social (leaderboard)

GET /api/v2/leaderboard

Ranks active Quant Vault leaders by realized P&L from market_maker_vaults. Query parameters:
ParamDefaultDescription
limit10Page size
offset0Pagination offset
curl -s "$QD_API/api/v2/leaderboard?limit=5" | jq '.data[] | {leader, total_pnl, strategy}'
Each row includes vault_address, leader, total_pnl, strategy, and is_active.

Referrals

POST /api/v2/referrals/validate

Checks whether assigning a referrer would create a circular loop before you submit an on-chain SetReferrer transaction.
curl -s -X POST \
  -H "Authorization: Bearer $QD_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"referrerAddress": "LEADER_WALLET_PUBKEY"}' \
  "$QD_API/api/v2/referrals/validate" | jq .
FieldMeaning
isLoop: trueReferral rejected — circular chain detected
isLoop: falseSafe to proceed on-chain