> ## Documentation Index
> Fetch the complete documentation index at: https://docs.decibel.trade/llms.txt
> Use this file to discover all available pages before exploring further.

# WebSocket API Overview

> Real-time market and account streams via WebSocket

The Decibel WebSocket API provides real-time streaming data for markets, order books, trades, account state, and notifications.

Spot and perp use the same topic patterns where the payload shape is shared. Each market-address topic is scoped to one concrete Decibel market. For example, a BTC spot market and a BTC perp market are different markets with different addresses, so they require separate subscriptions. Mixed account-level row payloads carry `asset_type` with values `perp` or `spot`.

## Payload Semantics

* `depth` and `market_candlestick` payloads do not include `asset_type`; the subscribed market address identifies whether the payload is for a perp or spot market.
* `account_open_orders` and `order_updates` use `OrderDto`. Spot order rows use `time_in_force` and leave perp-only fields such as `client_order_id`, reduce-only, TP/SL, parent, and trigger condition empty, false, or null.
* `trades` and `user_trades` use `TradeDto` with `asset_type`. Spot rows use `action` values `Buy` or `Sell`, leave `client_order_id` empty, set `realized_pnl_amount` and `realized_funding_amount` to `0`, and include `fee_asset` when `fee_amount` is denominated in the base or quote asset.
* `bulk_orders` and `bulk_order_fills` share the perp DTO shape, carry `asset_type`, and normalize spot prices/sizes with the spot market's quote/base decimals.

## Server URL

| Network | URL |
| - | - |
| Testnet | `wss://api.testnet.aptoslabs.com/decibel/ws` |
| Mainnet | `wss://api.mainnet.aptoslabs.com/decibel/ws` |

## Available Channels

### Market Data

| Channel | Description |
| - | - |
| `depth:{marketAddr}` | Orderbook depth updates for one perp or spot market address |
| `depth:{marketAddr}:{level}` | Depth updates for one perp or spot market address with aggregation level `1`, `2`, `5`, `10`, `100`, `1000` (default `1`) |
| `trades:{marketAddr}` | Trade stream for one perp or spot market address; rows carry `asset_type` |
| `market_price:{marketAddr}` | Perp-only price/funding/open-interest stream |
| `all_market_prices` | Perp-only price updates for all markets |
| `all_spot_mids` | Spot-only full-market snapshot of book mid and last trade price for every registered spot market |
| `all_market_contexts` | Perp-only. Same payload as `GET /api/v1/asset_contexts` (24h volume, 24h change, open interest) for every perp market, refreshed on a fixed interval |
| `market_candlestick:{marketAddr}:{interval}` | OHLCV candlestick data for one perp or spot market address (`1m`, `5m`, `15m`, `30m`, `1h`, `2h`, `4h`, `1d`, `1w`, `1mo`) |

### Account

| Channel | Description |
| - | - |
| `account_open_orders:{accountAddr}` | Open perp and spot orders for an account; rows carry `asset_type` |
| `order_updates:{accountAddr}` | Perp and spot order status/update events; nested orders carry `asset_type` |
| `account_positions:{accountAddr}` | Perp positions for an account |
| `account_overview:{accountAddr}` | Perp account overview and margin updates |
| `user_trades:{accountAddr}` | Perp and spot user trade fills; rows carry `asset_type` |
| `notifications:{accountAddr}` | User notifications |
| `withdraw_queue:{accountAddr}` | Incremental withdrawal queue updates |
| `protected_trial_update:{accountAddr}` | First Trade On Us (protected trial) status updates |

### Bulk Orders

| Channel | Description |
| - | - |
| `bulk_orders:{accountAddr}` | Perp and spot bulk-order status updates, including placed and rejected submissions |
| `bulk_order_fills:{accountAddr}` | Perp and spot bulk-order fill events; rows carry `asset_type` |

### TWAP

| Channel | Description |
| - | - |
| `user_active_twaps:{accountAddr}` | Active TWAP orders for a user |

## Topic Compatibility Notes

The server still accepts legacy topic names for backward compatibility:

* `user_open_orders:{accountAddr}` (legacy) -> canonical `account_open_orders:{accountAddr}`
* `user_positions:{accountAddr}` (legacy) -> canonical `account_positions:{accountAddr}`

Spot markets do not publish `market_price` or `all_market_prices` rows because they do not have oracle price, mark price, funding, or open interest. Use `all_spot_mids` for a full-market spot display-price snapshot, or `depth:{marketAddr}` and its `best_bid` / `best_ask` fields for one market's live book mid.

## Message Format

See [Connection Management](https://docs.decibel.trade/api-reference/websocket/connection.md#subscribe-unsubscribe) for subscribe/unsubscribe payloads, auth headers, and error responses.

## Next Steps

> [card] [Connection Management](https://docs.decibel.trade/api-reference/websocket/connection.md)
>
> Connect, authenticate, subscribe, reconnect

> [card] [TypeScript SDK](https://docs.decibel.trade/typescript-sdk/overview.md)
>
> Managed WebSocket connections via SDK


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.