SDK reference
The public methods you need for accounts, trades, and private reads.
On this page
Clients
| Export | Purpose |
|---|---|
| create_depth · @depthhq/sdk | App registration, trader accounts, orders, and private views. |
| create_depth_data · @depthhq/sdk/data | Public markets, candles, and price updates. |
| create_depth_maker · @depthhq/maker-sdk | Maker quotes, operators, fills, automation, and hedges. |
Units
| Value | Representation | Example |
|---|---|---|
| USDC and notional | bigint · 6 decimals | 25 USDC = 25_000_000n |
| Price · E8 | bigint · 8 decimals | $200 = 20_000_000_000n |
| SOL position size | bigint · 9 decimals | 1 SOL = 1_000_000_000n |
| Basis points | integer | 1 bp = 0.01% |
| Expiry | Unix seconds | Use 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
| Method | Use |
|---|---|
| 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
| Method | Use |
|---|---|
| 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();