> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dune.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Market Data Feeds

> Real-time onchain market data from Dune: spot DEX trades, pool liquidity books and perpetual futures trades over WebSocket, with history in DuneSQL and Datashare.

Dune Market Data Feeds are real-time streams of onchain market data. There are three feeds:

| Feed | What one message holds | Chains and venues | Live delivery |
| - | - | - | - |
| [Spot Trades](https://docs.dune.com/market-data-feeds/spot-trades.md) | Every DEX trade in one block, with price, side, USD notional and the transaction behind it | 12 EVM chains and Solana | WebSocket |
| [Spot Liquidity](https://docs.dune.com/market-data-feeds/liquidity.md) | Every liquidity add, remove and limit order in one block, plus a ±2% book for each pool the block changed | 12 EVM chains and Solana, 18 concentrated-liquidity and bin venues | WebSocket |
| [Perpetuals Trades](https://docs.dune.com/market-data-feeds/perp-trades.md) | Every perpetual futures fill in one venue block, with both parties, fees and position effect | Hyperliquid (HyperCore), Lighter, Lighter Robinhood | WebSocket |

Trade history for spot and perpetuals is in two Dune tables, `spot.trades` and `perpetuals.trades`. See [History](#history).

To see the instruments the feeds carry, open the [instrument explorer](https://dune.com/data/feeds).

## Chains

The Spot Trades and Spot Liquidity feeds cover the same 13 chains.

| Chain | `chain.type` | `chain.id` |
| - | - | - |
| Arbitrum | `evm` | `42161` |
| Arc | `evm` | `5042` |
| Avalanche C-Chain | `evm` | `43114` |
| Base | `evm` | `8453` |
| BNB Chain | `evm` | `56` |
| Ethereum | `evm` | `1` |
| HyperEVM | `evm` | `999` |
| Monad | `evm` | `143` |
| Optimism | `evm` | `10` |
| Polygon | `evm` | `137` |
| Robinhood Chain | `evm` | `4663` |
| X Layer | `evm` | `196` |
| Solana | `svm` | `1` |

`chain.id` is scoped by `chain.type`. Ethereum is `{"id": 1, "type": "evm"}` and Solana is `{"id": 1, "type": "svm"}`. Always key on both fields.

## Connect

All live feeds are WebSocket endpoints on `wss://api.dune.com`. Authenticate with your Dune API key in the `X-Dune-Api-Key` header. The key must be enabled for feed access. See [Get access](#get-access).

| Feed | Endpoint |
| - | - |
| Spot Trades, EVM | `wss://api.dune.com/api/feed/dex/trades/evm/{chain_id}` |
| Spot Trades, Solana | `wss://api.dune.com/api/feed/dex/trades/svm/1` |
| Spot Liquidity, EVM | `wss://api.dune.com/api/feed/dex/liquidity/evm/{chain_id}` |
| Spot Liquidity, Solana | `wss://api.dune.com/api/feed/dex/liquidity/svm/1` |
| Perpetuals, Hyperliquid | `wss://api.dune.com/api/feed/perp/trades/1` |
| Perpetuals, Lighter | `wss://api.dune.com/api/feed/perp/trades/lighter/1` |
| Perpetuals, Lighter Robinhood | `wss://api.dune.com/api/feed/perp/trades/lighter/2` |

```bash websocat theme={null}
websocat -B 16777216 -H "X-Dune-Api-Key: $DUNE_API_KEY" \
  "wss://api.dune.com/api/feed/dex/trades/evm/8453"
```

```python Python theme={null}
import asyncio, json, os
import websockets

URL = "wss://api.dune.com/api/feed/dex/trades/evm/8453"

async def main():
    headers = {"X-Dune-Api-Key": os.environ["DUNE_API_KEY"]}
    async with websockets.connect(URL, additional_headers=headers, max_size=None) as ws:
        async for frame in ws:
            block = json.loads(frame)
            print(block["block_number"], block["op"], len(block["trades"]))

asyncio.run(main())
```

### Messages

* One WebSocket message holds one block. Messages arrive in order.
* Each message is a binary frame of UTF-8 JSON. In a browser, set `binaryType = "arraybuffer"` and decode with `TextDecoder`.
* `schema_version` names the message format, for example `dex-trades.json.v2`.
* `sequence_number` is the position of the message in the chain's stream. It is a JSON string, so it stays exact in JavaScript.
* `block_timestamp` and `block_notification_time` are RFC 3339 timestamps in UTC. `block_notification_time` is when Dune first observed the block.

### Resume after a disconnect

* Without a query parameter, a connection starts at the live tip.
* To resume, reconnect with `?resume_after={sequence_number}`, using the last `sequence_number` you processed. The stream continues from the next message, then stays live.
* Do not use a block number as a cursor. A correction of an old block arrives at a later sequence number.
* A `resume_after` value outside the retained range is rejected with HTTP `400`. An unsupported chain is rejected with HTTP `404`.
* Close code `1001` means the server is shutting down. Close code `1008` means your client fell behind the live buffer. In both cases, reconnect with `resume_after`.

## Corrections and provisional blocks

The feeds publish a block when it is first observed, before the chain finalizes it. If the block changes later, for example after a reorg, Dune sends it again.

* `op` is `INSERT` for the first message of a block and `UPDATE` for a correction. The Spot Liquidity feed writes these values in lowercase.
* `incarnation_version` starts at `0` and increases with each correction. Keep the message with the highest `incarnation_version` for each `(chain, block_number)`.
* Every message is the complete content of its block. An `UPDATE` replaces all that you hold for that block. A trade or event that is missing from the `UPDATE` is cancelled. There is no separate cancel message.
* An `UPDATE` can be empty. This tells you to delete everything you hold for that block.
* Trade and event identifiers (`trade_id`, `event_id`) are stable. The same trade seen again carries the same identifier.
* On Solana, trades are published at the *confirmed* commitment level and each slot is checked again at finality.

## History

Dune rebuilds trade history from raw chain data with the same decoders and pricing as the live feeds. One row is one trade.

| Table | Contents | First day |
| - | - | - |
| `spot.trades` | Spot trades on the 13 chains above | Polygon 2022-03-09, Solana 2022-04-07, Ethereum 2023-01-01. See [Spot Trades](https://docs.dune.com/market-data-feeds/spot-trades.md#history) for all chains. |
| `perpetuals.trades` | Perpetuals trades on Hyperliquid, Lighter, Lighter Robinhood and Kalshi | Lighter 2025-01-17, Hyperliquid 2025-07-27. See [Perpetuals Trades](https://docs.dune.com/market-data-feeds/perp-trades.md#history) for all venues. |

* A new day is written each night, after the day is complete on the chain.
* On 19 November 2026, both tables had a partition for every calendar day from each chain's first day to 2026-11-18. A present day does not prove that every trade of that day is present.
* History is available through DuneSQL, through [Datashare](https://docs.dune.com/datashare/datashare.md) to your own warehouse, and as monthly CSV files during a trial. Access is granted per customer.

```sql DuneSQL theme={null}
SELECT block_timestamp, instrument_code, side, executed_price, notional_usd, tx_hash
FROM spot.trades
WHERE block_date = DATE '2026-11-17'
  AND chain_type = 'evm' AND chain_id = 8453
  AND instrument_code = 'WETH-USDC.UNIV3.BASE'
ORDER BY block_timestamp
LIMIT 100
```

## Get access

Market Data Feeds are an Enterprise feature. Access to the live feeds and to the history tables is enabled per Dune team. To request access or a trial, contact [Dune Enterprise](https://dune.com/enterprise) or use **Request a demo** on the [Market Data Feeds page](https://dune.com/feeds). A trial includes the live WebSocket feeds and monthly history files.

## What the feeds do not include

* Centralized exchange trades.
* A consolidated or aggregated price. Each trade and each pool book is published on its own.
* Constant-product pools in the Spot Liquidity feed. See [Spot Liquidity](https://docs.dune.com/market-data-feeds/liquidity.md#venues).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.