Skip to main content
In this recipe we’ll walk through building a token detail page — the kind of page your users land on after clicking a token from a discovery feed. We’ll combine multiple Codex endpoints to populate every section: metadata, price, holders, top traders, safety signals, trade history, and real-time updates.

This data powers the token pages on Defined.fi:
Token-Dashboard

Step 1: Token Metadata & Safety

Start by fetching the token’s core info — name, symbol, images, social links, and safety signals. This single query gives you everything for the header of your token page.
Token verification: Codex uses isScam rather than isVerified for token safety. isScam: false is the equivalent of a token being “verified.” For Solana tokens, also check mintable and freezable — if these return an address, the token’s supply can be increased or holdings can be frozen.

Step 2: Price & Pair Data

Fetch the token’s current price, volume, and liquidity from its top trading pair using pairMetadata. This gives you the price stats panel for your dashboard.
If you don’t already have the pair ID, use listPairsWithMetadataForToken to find it. Results are sorted by liquidity so the first result is the most active pair.
Use enhancedToken0 and enhancedToken1 to get enriched token metadata directly from the pair query — this saves you an extra call to token.

Step 3: Holders & Top Traders

Build the holders tab. Use holders for the top holder list and tokenTopTraders for the most active traders with PnL data.

Step 4: Trade History

Show recent buys and sells. Use getTokenEvents for the initial load and paginate with cursor for older trades.

Step 5: Chart Data

Fetch OHLCV bars for rendering a price chart. See the Charts recipe for full details on rendering with TradingView.

Step 6: Real-Time Updates

Once the page is loaded, open subscriptions to keep it live. Here are the key subscriptions for a token dashboard:
Subscribe to onPairMetadataUpdated to keep price, volume, and liquidity current without polling.
Subscribe to onTokenEventsCreated to stream new trades as they happen.
Subscribe to onTokenBarsUpdated to keep the chart updating in real time.
Subscribe to onHoldersUpdated to keep the holders list current.
Each subscription uses one connection toward your plan’s limit (300 for Growth plans). A single token dashboard page with all four subscriptions above uses 4 connections. Use ~25 subscriptions per WebSocket connection as a guideline, and share connections across subscriptions where possible.

Putting It All Together

Here’s the recommended data flow for a token dashboard: On page load (queries):
  1. token — metadata, safety, social links
  2. pairMetadata — price, volume, liquidity
  3. holders + tokenTopTraders — holder and trader tabs
  4. getTokenEvents — recent trade history
  5. getTokenBars — chart OHLCV data
After load (subscriptions):
  1. onPairMetadataUpdated — live price and volume
  2. onTokenEventsCreated — live trade feed
  3. onTokenBarsUpdated — live chart updates
  4. onHoldersUpdated — live holder changes
Optimizing calls: You can reduce initial load by running queries 1-5 in parallel — they’re all independent. For the subscriptions, open them on a single WebSocket connection to minimize connection usage.

Subscriptions vs Queries Quick Reference

DataQuery (historical)Subscription (real-time)
Price & volumepairMetadataonPairMetadataUpdated
TradesgetTokenEventsonTokenEventsCreated
Chart barsgetBars / getTokenBarsonBarsUpdated / onTokenBarsUpdated
HoldersholdersonHoldersUpdated
Token pricesgetTokenPricesonPricesUpdated