Deepbook API Overview
The Surflux Deepbook Indexing API provides read access to DeepBook, a decentralized Central Limit Order Book (CLOB) built natively on Sui. Query pool metadata, order book state, historical trades, and OHLCV candlestick data without running your own indexing infrastructure.
With the Deepbook API, you can build trading interfaces, analytics dashboards, market-making bots, and charting tools without the complexity of parsing raw blockchain events or maintaining real-time order book state.
What You Can Build
- Trading Interfaces — Display order books, recent trades, and interactive price charts
- Analytics Platforms — Analyze trading volume, liquidity depth, and market trends
- Market Making Bots — Access order book depth to inform automated trading strategies
- Portfolio Trackers — Fetch historical price data for asset valuation and performance tracking
- Charting Libraries — Build candlestick charts using OHLCV data across multiple timeframes
API Endpoints
The Deepbook Indexing API includes four core endpoints:
- Get Pools — Retrieve all available trading pools with metadata (5 credits)
- Order Book Depth — Get current bids and asks for a specific pool (30 credits)
- Recent Trades — Query historical trade executions (20 credits)
- OHLCV — Fetch candlestick data for charting (25 credits)
All endpoints consume credits based on their computational complexity. See the Credits documentation for detailed pricing.
What is DeepBook?
DeepBook is a decentralized Central Limit Order Book (CLOB) protocol built natively on the Sui blockchain. Unlike automated market makers (AMMs) like Uniswap, DeepBook functions as a traditional order book where buyers and sellers place limit and market orders that are matched by price and time priority.
Key characteristics of DeepBook:
- Central Limit Order Book (CLOB) — Traditional order book mechanics with bid/ask price levels and order matching
- Native Liquidity Layer — Built directly on Sui to serve as the foundational liquidity infrastructure for the ecosystem
- High Performance — Leverages Sui's parallel execution for ultra-low latency (~390ms settlement times)
- Flash Loans & Governance — DeepBookV3 introduces flash loans, the DEEP token, and community governance
- Integration-First Design — No direct UI; designed to be integrated into DEXs, wallets, and trading applications
For more details on Deepbook, see the Sui Deepbook documentation.
How It Differs from Flux Streams
The Deepbook Indexing API provides historical and snapshot data through REST endpoints, while Flux Streams deliver real-time events via Server-Sent Events (SSE).
| Feature | Deepbook Indexing API | Deepbook Flux Stream |
|---|---|---|
| Data type | Historical & current snapshots | Real-time live events |
| Protocol | REST (HTTP GET) | SSE (streaming) |
| Base URL | https://api.surflux.dev | https://flux.surflux.dev |
| Use case | Charting, analytics, initial state | Live trading, instant updates |
| Latency | Low (on-demand queries) | Ultra-low (push notifications) |
| Connection | Stateless requests | Persistent connection |
For live trading interfaces that need instant updates as trades execute and orders change, use the Deepbook Flux Stream. For initial data loading, historical analysis, and periodic polling, use this Indexing API.
Pool Names
Most endpoints require a poolName parameter to specify which trading pair to query. Pool names follow the format BASE_QUOTE:
Examples:
SUI_USDC— SUI/USDC trading pairNS_SUI— NS Token/SUI trading pairDEEP_SUI— DEEP/SUI trading pair
Use the Get Pools endpoint to retrieve all available pool names and their complete metadata including decimals, tick sizes, and lot sizes.
Understanding Price and Quantity Values
All price and quantity values returned by the API are in smallest units based on each asset's decimal precision. This is similar to how Ethereum handles wei for ETH.
Converting Prices
To convert raw prices to human-readable format, you need the base and quote asset decimals from the Get Pools endpoint.
Example for SUI_USDC pool:
- Base asset (SUI): 9 decimals
- Quote asset (USDC): 6 decimals
- Raw price: 3380500
// Calculate human-readable price
const humanPrice = rawPrice / Math.pow(10, quoteDecimals);
// 3380500 / 1,000,000 = 3.3805 USDC per SUI
Converting Quantities
Quantities represent the base asset amount in smallest units:
// For SUI with 9 decimals
const rawQuantity = 443700000000;
const humanQuantity = rawQuantity / Math.pow(10, baseDecimals);
// 443700000000 / 1,000,000,000 = 443.7 SUI
Authentication
All Deepbook Indexing API endpoints require authentication via an API key. Include your API key as a query parameter:
curl "https://api.surflux.dev/deepbook/get_pools?api-key=YOUR_API_KEY"
Don't have an API key yet? Create your Surflux account to get started.
Base URL
All Deepbook Indexing API endpoints use the base API URL:
https://api.surflux.dev/
Next Steps
Ready to start querying Deepbook data? Check out the endpoint documentation:
- Get Pools — List all trading pools
- Order Book Depth — Get current order book state
- Recent Trades — Query historical trades
- OHLCV — Fetch candlestick data