Chains API
The block at a given time
Which block one chain was on at a Unix timestamp: the last block at or before it and the first after it, with number (the slot on SOL), hash and time.
/api/external/chain-analysis/block-at-time/{chain}What it returns
The block a chain was on at a Unix timestamp: block is the last block produced at or before it, nextBlock the first one after it, each with number, hash and time — so the block nearest the instant is whichever of the two is closer. block is null when the instant is before the chain's first block. nextBlock is null when no block has been produced after the instant yet; block is then the current head and can still change. On the fastest chains several blocks share one timestamp; block is the last of them.
Chains
- Solana SOL
- BNB Chain BNB
- Ethereum ETH
- Stable STABLE
- Base BASE
- Robinhood Chain RHC
- Arc ARC
Request
Send your key in the x-dex-data-key header. Replace each <placeholder> with a real value.
curl -H "x-dex-data-key: $DEXDATA_API_KEY" \ "https://api.dexdata.io/api/external/chain-analysis/block-at-time/SOL?timestamp=<timestamp>"
| Parameter | Description |
|---|---|
timestampquery · integer · required | The instant, Unix SECONDS. A time in the future returns 400. |
chainpath · string · required | Ethereum, BNB, Base, Stable, Arc, RHC or SOL. On SOL the block is the slot, and an instant before 1710975000 (2024-03-20T22:50:00.000Z) returns 400. CELO, ARB, OP and SCROLL return 400 here. |
Response fields
A JSON response. Every field is always present; null means the value could not be established, never zero.
| Field | Type | Description |
|---|---|---|
timestamp | integer | The instant asked about, Unix seconds. |
block | object | null | The last block produced at or before the instant, or null before the chain's first block. |
block.number | integer | The block height — on SOL, the slot. |
block.hash | string | The block hash: 0x-prefixed hex, or the base58 blockhash on SOL. |
block.timestamp | integer | Unix seconds the block was produced at. |
nextBlock | object | null | The first block produced after the instant, or null when there is none yet. |
nextBlock.number | integer | The block height — on SOL, the slot. |
nextBlock.hash | string | The block hash: 0x-prefixed hex, or the base58 blockhash on SOL. |
nextBlock.timestamp | integer | Unix seconds the block was produced at. |
Start building with DexData today
Sign in, create a key and make your first call in a minute. Free credits every month, and you only pay for calls that succeed.
Get a free API key