Skip to main content
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
Time to complete: 5 to 10 minutes Prerequisites: Basic JavaScript or Python knowledge

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:
  1. Search by name or symbol using the Search Endpoint:
  1. Get network list using the Networks Endpoint:

Common Token Addresses

Or use these verified addresses for popular tokens:

Step 2: Test with cURL

First, verify the stream works with a simple cURL command:
Live capture from production, three events back-to-back:
The limit=3 parameter closes the stream after three events, perfect for smoke tests. Drop it for a continuous feed.
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

The EventSource API is the browser’s built-in way to handle SSE:
It automatically handles:
  • Persistent connections
  • Automatic reconnection
  • Event parsing
The onerror callback handles disconnections:
Each token_price event contains:
The legacy t_p method emits a compact {a, c, p, t, t_p} shape and is deprecated.
Beyond token_price, pool_reserves, and token_reserves, the server may push:
  • ping every ~15s (keep-alive). Payload: {"time": <unix>}.
  • warning for non-fatal notices, including deprecation messages. Payload: {"message": "..."}.
  • error for stream-terminating problems (invalid asset, etc.).
Always filter on the 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:
Each pool_reserves 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):
That is a single swap: ~12,019ofUSDCcamein, 12,019 of USDC came in, ~12,010 of WETH went out, net dollar delta to the pool was +$8.80 (the trader paid the trading fee). The whole picture, in one event, no log decoding required.
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

Want the deep dive on what reserves streaming unlocks (impermanent loss tracking, MEV detection, real-time TVL, slippage estimation)? See the Reserves Streaming page for the annotated wire example and use cases broken out by audience.

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.