> ## 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.

# Real-Time Streaming API

> Stream live cryptocurrency price updates using Server-Sent Events (SSE) for real-time applications

<Card title="🎬 See Streaming API in Action" icon="desktop" href="https://crypto-streaming-dashboard-v3.vercel.app/" color="#10B981">
  **Live Demo:** Watch our interactive dashboard stream real-time prices for 6 cryptocurrencies across Ethereum, Solana, and BSC. See connection status, latency metrics, and live updates in action. [Open Live Dashboard →](https://crypto-streaming-dashboard-v3.vercel.app/)
</Card>

## Overview

DexPaprika's Streaming API delivers real-time cryptocurrency price updates via Server-Sent Events (SSE). Build responsive applications with live data feeds. Get price updates every second without polling - no API key required.

<CardGroup cols={2}>
  <Card title="No Authentication" icon="unlock">
    Public endpoints with no API keys needed. Start streaming immediately.
  </Card>

  <Card title="Real-Time Updates" icon="bolt">
    Receive price updates approximately every 1 second per asset.
  </Card>

  <Card title="SSE Protocol" icon="signal-stream">
    Standard Server-Sent Events for easy integration with any modern platform.
  </Card>

  <Card title="Multi-Chain Support" icon="link">
    Stream tokens from Ethereum, Solana, BSC, Arbitrum, and more networks.
  </Card>
</CardGroup>

***

## Why Use Streaming?

### Streaming vs Traditional Polling

<Tabs>
  <Tab title="SSE Streaming (Recommended)">
    ```javascript theme={null}
    // Efficient: Server pushes updates only when prices change
    const url = 'https://streaming.dexpaprika.com/stream?method=t_p&chain=ethereum&address=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
    const eventSource = new EventSource(url);

    eventSource.addEventListener('t_p', (event) => {
      const data = JSON.parse(event.data);
      updatePrice(data.p);
    });
    ```

    **Benefits:**

    * Single persistent connection
    * Updates pushed immediately when available
    * Minimal bandwidth usage
    * No rate limiting concerns
  </Tab>

  <Tab title="Polling (Not Recommended)">
    ```javascript theme={null}
    // Inefficient: Constant requests even when prices don't change
    setInterval(async () => {
      const response = await fetch('https://api.dexpaprika.com/networks/ethereum/tokens/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2');
      const data = await response.json();
      updatePrice(data.summary.price_usd);
    }, 1000); // 86,400 requests per day per asset!
    ```

    **Drawbacks:**

    * High server load from repeated requests
    * Wasted bandwidth when prices don't change
    * Potential rate limiting issues
    * Higher latency for updates
  </Tab>
</Tabs>

***

## Use Cases

### What You Can Build

<CardGroup cols={2}>
  <Card title="Trading Dashboards" icon="chart-line" href="https://crypto-streaming-dashboard-v3.vercel.app/">
    Display live prices, volume, and market metrics with sub-second latency. **[See live example →](https://crypto-streaming-dashboard-v3.vercel.app/)**
  </Card>

  <Card title="Portfolio Trackers" icon="wallet">
    Show real-time portfolio values and P\&L as prices fluctuate.
  </Card>

  <Card title="Price Alert Systems" icon="bell">
    Trigger instant notifications when prices hit target levels.
  </Card>

  <Card title="DEX Aggregators" icon="arrows-rotate">
    Compare prices across chains for arbitrage opportunities.
  </Card>

  <Card title="Market Tickers" icon="display">
    Create live price tickers and widgets for websites.
  </Card>

  <Card title="Analytics Platforms" icon="chart-mixed">
    Stream data into time-series databases for real-time analytics.
  </Card>
</CardGroup>

***

## Available Endpoints

We offer two streaming methods optimized for different use cases:

<CardGroup cols={2}>
  <Card title="GET /stream - Single Asset" icon="signal" href="/streaming/streaming-token-prices">
    Stream one token per connection. Simple and straightforward for individual assets.
  </Card>

  <Card title="POST /stream - Multiple Assets" icon="signal-stream" href="/streaming/streaming-post-multiple-assets">
    Stream up to 2,000 tokens in one connection. Optimal for portfolios and dashboards.
  </Card>
</CardGroup>

### Quick Comparison

| Feature                | GET (Single)              | POST (Multiple)        |
| ---------------------- | ------------------------- | ---------------------- |
| **Assets per request** | 1                         | Up to 2,000            |
| **Best for**           | Individual price tracking | Portfolios, dashboards |
| **Setup complexity**   | Minimal                   | Moderate               |
| **Performance**        | Good for 1-10 assets      | Optimal for 10+ assets |
| **Load distribution**  | Per connection            | Automatic balancing    |

***

## Quick Start

### 1. Choose Your Method

<Tabs>
  <Tab title="Single Asset (Simple)">
    Stream Ethereum WETH price:

    ```bash theme={null}
    curl -N "https://streaming.dexpaprika.com/stream?method=t_p&chain=ethereum&address=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
    ```
  </Tab>

  <Tab title="Multiple Assets (Advanced)">
    Stream SOL and USDC prices:

    ```bash theme={null}
    curl -X POST "https://streaming.dexpaprika.com/stream" \
      -H "Accept: text/event-stream" \
      -H "Content-Type: application/json" \
      -d '[
        {"chain": "solana", "address": "So11111111111111111111111111111111111111112", "method": "t_p"},
        {"chain": "ethereum", "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "method": "t_p"}
      ]'
    ```
  </Tab>
</Tabs>

### 2. Parse the Response

Each price update arrives as a JSON event:

```json theme={null}
{
  "a": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",  // Token address
  "c": "ethereum",                                     // Chain
  "p": "2739.792547827768",                           // Price in USD
  "t": 1769778188,                                    // Server send timestamp
  "t_p": 1769778187                                   // Price event timestamp
}
```

### 3. Handle in Your Application

<CodeGroup>
  ```javascript Browser theme={null}
  const eventSource = new EventSource(url);

  eventSource.addEventListener('t_p', (event) => {
    const price = JSON.parse(event.data);
    console.log(`${price.c} ${price.a}: $${price.p}`);
  });

  eventSource.onerror = () => {
    // Reconnect logic
    eventSource.close();
    setTimeout(connectStream, 1000);
  };
  ```

  ```python Python theme={null}
  import requests
  import json

  response = requests.get(url, stream=True)

  for line in response.iter_lines():
      if line and line.startswith(b'data:'):
          data = json.loads(line[5:])
          print(f"{data['c']} {data['a']}: ${data['p']}")
  ```

  ```typescript TypeScript theme={null}
  interface PriceEvent {
    a: string;  // address
    c: string;  // chain
    p: string;  // price
    t: number;  // timestamp
  }

  const stream = new EventSource(url);

  stream.addEventListener('t_p', (event: MessageEvent) => {
    const price: PriceEvent = JSON.parse(event.data);
    updatePrice(price);
  });
  ```
</CodeGroup>

***

## Architecture Overview

```mermaid theme={null}
graph LR
    A[Your App] -->|SSE Connection| B[Streaming API]
    B --> C[Load Balancer]
    C --> D1[Server 1]
    C --> D2[Server 2]
    C --> D3[Server N]
    D1 --> E[Price Feeds]
    D2 --> E
    D3 --> E
    E --> F[Blockchain RPCs]
```

### Key Features

* **Automatic Load Balancing**: Requests distributed across multiple servers
* **Persistent Connections**: Single connection maintained for entire session
* **Efficient Updates**: Only sends data when prices actually change
* **Global Infrastructure**: Low-latency servers in multiple regions

***

## Best Practices

<AccordionGroup>
  <Accordion title="Connection Management">
    * Implement automatic reconnection with exponential backoff
    * Handle both network errors and SSE error events
    * Monitor connection health with heartbeat timeouts
  </Accordion>

  <Accordion title="Error Handling">
    * Validate all assets before streaming (invalid assets cancel entire stream)
    * Parse both HTTP errors and SSE error events
    * Log errors for debugging but don't expose sensitive data
  </Accordion>

  <Accordion title="Performance Optimization">
    * Use POST method for multiple assets (better than multiple GETs)
    * Split large requests across multiple smaller streams
    * Parse price strings carefully to maintain precision
  </Accordion>

  <Accordion title="Production Deployment">
    * Implement proper logging and monitoring
    * Set up alerts for connection drops
    * Use connection pooling for multiple streams
    * Consider WebSocket bridges for incompatible clients
  </Accordion>
</AccordionGroup>

***

## Supported Networks

Stream tokens from multiple blockchain networks. Use the [Networks API](/api-reference/networks/get-a-list-of-available-blockchain-networks) to get the full list of supported networks:

```bash theme={null}
curl https://api.dexpaprika.com/networks
```

Popular networks include:

* Ethereum (`ethereum`)
* Solana (`solana`)
* Binance Smart Chain (`bsc`)
* Arbitrum (`arbitrum`)
* Polygon (`polygon`)
* Base (`base`)
* Avalanche (`avalanche`)

<Note>
  The `chain` parameter in streaming requests must use the exact `id` value from the [Networks endpoint](/api-reference/networks/get-a-list-of-available-blockchain-networks).
</Note>

***

## Finding Token Addresses

Before streaming prices, you need the correct token address for your chosen network. Use these REST API endpoints:

### Search for Tokens

Use the [Search API](/api-reference/search/search-for-tokens-pools-and-dexes) to find tokens by name or symbol:

```bash theme={null}
curl "https://api.dexpaprika.com/search?query=USDC"
```

### Get Token Details

Find all pools for a specific token using the [Token Pools API](/api-reference/tokens/get-top-x-pools-for-a-token):

```bash theme={null}
curl "https://api.dexpaprika.com/networks/ethereum/tokens/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48/pools"
```

### Validate Before Streaming

Use the [Token Prices API](/api-reference/tokens/get-batched-token-prices-on-a-network) to verify your token exists before streaming:

```bash theme={null}
curl "https://api.dexpaprika.com/networks/ethereum/multi/prices?tokens=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
```

<Tip>
  Always verify the token address matches the network you're streaming from. The same token may have different addresses on different chains.
</Tip>

<Warning>
  The streaming API will return a `400 Asset not found` error if the token doesn't exist on the specified network. Validate tokens using the REST API first to avoid stream failures.
</Warning>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="🚀 Live Dashboard Demo" icon="desktop" href="https://crypto-streaming-dashboard-v3.vercel.app/" color="#10B981">
    See the Streaming API in action with our interactive demo. Watch real-time updates across multiple chains.
  </Card>

  <Card title="Quick Start Tutorial" icon="rocket" href="/streaming/tutorials/quick-start">
    Build your first streaming application in 5 minutes.
  </Card>

  <Card title="API Reference" icon="book" href="/streaming/streaming-token-prices">
    Detailed endpoint documentation and parameters.
  </Card>

  <Card title="React Integration" icon="react" href="/streaming/guides/react-integration">
    Create live price components for React applications.
  </Card>
</CardGroup>

***

## Get Support

<CardGroup cols={2}>
  <Card title="Discord Community" icon="discord" href="https://discord.gg/DhJge5TUGM">
    Join our Discord for real-time support and discussions.
  </Card>

  <Card title="Email Support" icon="envelope" href="mailto:support@coinpaprika.com">
    Contact our team for technical assistance.
  </Card>
</CardGroup>
