Documentation Index
Fetch the complete documentation index at: https://docs.dexpaprika.com/llms.txt
Use this file to discover all available pages before exploring further.
See it in action: Check out our Live Streaming Dashboard to see real-time updates flow across multiple chains before you build your own.
Tutorial overview
In this tutorial, you’ll learn how to:- Connect to the DexPaprika streaming API
- Receive real-time token price updates
- Receive real-time pool reserve updates (the DexPaprika differentiator)
- Handle connection errors gracefully
- Build a simple live display
Step 1: Choose Your Asset
For this tutorial, we’ll stream the price of Ethereum (WETH).Finding Token Addresses
Use the REST API to find token addresses:- Search by name or symbol using the Search Endpoint:
- Get network list using the Networks Endpoint:
Common Token Addresses
Or use these verified addresses for popular tokens:- Ethereum
- Solana
- BSC
Step 2: Test with cURL
First, verify the stream works with a simple cURL command:Both orderings of
event: and data: lines within a single SSE message are valid per the SSE specification, and the server has used both during rollout. Only the blank-line boundary between messages is significant. EventSource handles either order natively. Custom parsers should buffer one message at a time and dispatch on the parsed event type, not on field order.Step 3: JavaScript Implementation
Here’s how to connect to the streaming API using JavaScript:🎯 Live Example: See this code in action in our Interactive Streaming Dashboard - watch 6 tokens stream live across Ethereum, Solana, and BSC with real-time updates, connection status, and latency monitoring.
Step 4: Customize Your Stream
Stream Different Tokens
Modify the URL parameters to stream any token:Add Multiple Assets
To stream multiple assets, switch to the POST method:Understanding the Code
Key Components
EventSource API
EventSource API
The It automatically handles:
EventSource API is the browser’s built-in way to handle SSE:- Persistent connections
- Automatic reconnection
- Event parsing
Error Handling
Error Handling
The
onerror callback handles disconnections:Price Updates
Price Updates
Each The legacy
token_price event contains:t_p method emits a compact {a, c, p, t, t_p} shape and is deprecated.Other event types
Other event types
Beyond
token_price and reserve_update, the server may push:pingevery ~15s (keep-alive). Payload:{"time": <unix>}.warningfor non-fatal notices, including deprecation messages. Payload:{"message": "..."}.errorfor stream-terminating problems (invalid asset, etc.).
event: line. Treat unknown event names as no-ops so future server-side additions cannot break your handler.Now stream pool reserves
Token prices are useful. Block-level pool reserves are the killer feature. Instead of/sse/prices, point at /sse/reserves and pick one of two methods:
method=pool_reserves: subscribe to a specific pool. You receive events when that pool’s reserves change.method=token_reserves: subscribe to a specific token. You receive events for every pool the token sits in.
Try it with cURL
Subscribe to a Uniswap V3 USDC/WETH pool on Ethereum:reserve_update event tells you the pool, the block it was observed in, both tokens’ raw reserves, the block’s delta, current USD prices, and the dollar value of the change. A live capture from production (block 25,100,507):
The
reserve, delta, block, and previous_block fields all arrive as JSON strings (note the quotes in the example above). The server encodes them that way because they routinely exceed Number.MAX_SAFE_INTEGER: the WETH delta above is a 19-digit integer. Use BigInt(reserve) for exact arithmetic, or Number(block) when you just want a quick block-height comparison. The pre-computed USD fields (reserve_usd, delta_usd, total_reserve_usd, total_delta_usd) and price_usd are regular JSON numbers, safe for floating-point math.Same thing in JavaScript
Implementation Notes
Browser Support
- EventSource API works in all modern browsers
- For direct browser connections, you’ll need to handle CORS (use a backend proxy)
- No issues when streaming from server-side (Node.js, Python, etc.)
Best Practices
- Implement exponential backoff for reconnection
- Handle both connection errors and SSE error events
- Parse prices as floats to maintain precision
- Close connections properly on page unload
See It Live
🚀 Live Streaming Dashboard
Try the API without writing code. The interactive streaming demo lets you pick a chain, pick tokens (or paste a custom contract address), and watch SSE events flow in real time. You can also copy the generated subscription payload to use in your own code.What you’ll see:
- Real-time price updates, sub-second latency
- Multi-chain support (switch chains in the UI)
- Connection status, latency, and update counts
- The exact JSON the server pushes, line by line
Next Steps
Congratulations! You’ve built your first streaming application. Here’s what to explore next:Reserves Streaming Deep Dive
What block-level reserve updates contain, both subscription methods, annotated wire example, and use cases for LPs, MEV builders, and analytics teams.
React Integration
Build streaming components for React and Next.js applications.
Stream Multiple Assets
The POST /sse/prices endpoint for multi-token price subscriptions.
Subscribe to Multiple Reserves
The POST /sse/reserves endpoint for multi-pool and multi-token subscriptions.
Get Help
Join Discord
Get help from our community.
API Reference
Read the complete API documentation.