depth
Build an app

SDK reference

The public methods you need for accounts, trades, and private reads.

On this page

Clients

ExportPurpose
create_depth · @depthhq/sdkApp registration, trader accounts, orders, and private views.
create_depth_data · @depthhq/sdk/dataPublic markets, candles, and price updates.
create_depth_maker · @depthhq/maker-sdkMaker quotes, operators, fills, automation, and hedges.

Units

ValueRepresentationExample
USDC and notionalbigint · 6 decimals25 USDC = 25_000_000n
Price · E8bigint · 8 decimals$200 = 20_000_000_000n
SOL position sizebigint · 9 decimals1 SOL = 1_000_000_000n
Basis pointsinteger1 bp = 0.01%
ExpiryUnix secondsUse validForSeconds for a relative duration.

Amount selectors accept a bigint, "all", or a percentage such as "50%" where the method supports them. Do not pass decimal JavaScript numbers for token amounts.

Account and position

MethodUse
depth.account.deposit(amount)Deposit wallet USDC into the private balance.
depth.account.allocate({ marketId, amount })Move free balance into market collateral.
depth.account.release({ marketId, amount })Return releasable margin to free balance.
depth.account.withdraw(amount)Withdraw free balance to the wallet.
depth.account.summary()Read the authorized private balance.
depth.position.summary() / pnl()Read private market state or value the position.
depth.position.addMargin(amount) / removeMargin(amount)Adjust margin within market limits.

Trade and recovery

MethodUse
depth.trade.submit(input)Increase long or short exposure.
depth.trade.reduce(input) / close(input) / reverse(input)Manage existing exposure.
operation.status() / confirm()Inspect the receipt or wait for a filled outcome.
operation.privateResult() / transaction()Read the authorized fill or settlement transaction.
depth.trade.operation(nonce) / flow(nonce)Restore an order or its allocation/submission flow.
depth.account.pending() / history()Discover canonical funding receipts.

Read sessions

Authorize and revoke
await depth.views.authorize();
const balance = await depth.account.summary();
const permission = await depth.views.status();

await depth.views.revoke();
Documentation
8 results