Midnight
The Midnight Indexer API exposes a GraphQL API that enables clients to query and subscribe to blockchain data — blocks, transactions, contracts, and wallet-related events — indexed from the Midnight blockchain.
Quick Start
- Create a Midnight project on blockfrost.io
- Grab your
project_idfrom the dashboard - Make your first query:
curl -X POST https://midnight-mainnet.blockfrost.io/api/v0 \
-H "project_id: YOUR_PROJECT_ID" \
-H "Content-Type: application/json" \
-d '{"query": "{ block { hash height timestamp } }"}'
{
"data": {
"block": {
"hash": "d193b2686197789ace64962eb3049c5b94c4bbf9b07da04bef034cd75d83afc4",
"height": 192998,
"timestamp": 1770787800000
}
}
}
Endpoints
Blockfrost exposes three Midnight services per network:
- Mainnet
- Preprod
- Preview
| Service | URL |
|---|---|
| Indexer API | https://midnight-mainnet.blockfrost.io/api/v0 |
| Indexer WebSocket | wss://midnight-mainnet.blockfrost.io/api/v0/ws |
| Node RPC | https://rpc.midnight-mainnet.blockfrost.io |
| Service | URL |
|---|---|
| Indexer API | https://midnight-preprod.blockfrost.io/api/v0 |
| Indexer WebSocket | wss://midnight-preprod.blockfrost.io/api/v0/ws |
| Node RPC | https://rpc.midnight-preprod.blockfrost.io |
| Service | URL |
|---|---|
| Indexer API | https://midnight-preview.blockfrost.io/api/v0 |
| Indexer WebSocket | wss://midnight-preview.blockfrost.io/api/v0/ws |
| Node RPC | https://rpc.midnight-preview.blockfrost.io |
Indexer API — Send GraphQL queries and mutations over HTTP POST. This is the main entry point for fetching blockchain data (blocks, transactions, contracts, DUST status).
Indexer WebSocket — Subscribe to real-time events using the graphql-transport-ws protocol. Supports block streaming, contract actions, shielded/unshielded transactions, and ledger events.
Node RPC — Direct JSON-RPC connection to the Midnight Node for low-level runtime access, wallet providers, and transaction submission. Use it with libraries like midnight.js that need a node connection.
Authentication
All requests require a valid project ID. There are two ways to pass it:
HTTP header
Include project_id as a request header.
curl -X POST https://midnight-{network}.blockfrost.io/api/v0 \
-H "project_id: YOUR_PROJECT_ID" \
-H "Content-Type: application/json" \
-d '{"query": "{ block { hash height } }"}'
Replace {network} with mainnet, preprod, or preview.
Query parameter
Append ?project_id=YOUR_PROJECT_ID to the endpoint URL. Use this when your client doesn't support setting custom headers (e.g. Midnight.js SDK).
https://midnight-{network}.blockfrost.io/api/v0?project_id=YOUR_PROJECT_ID
wss://midnight-{network}.blockfrost.io/api/v0/ws?project_id=YOUR_PROJECT_ID
https://rpc.midnight-{network}.blockfrost.io?project_id=YOUR_PROJECT_ID
Replace {network} with mainnet, preprod, or preview.
Full API Reference
For the complete GraphQL schema documentation, query examples, WebSocket subscriptions, and more, see the Blockfrost Midnight API docs.
Learn More
To learn about Midnight's architecture, the Compact smart contract language, zero-knowledge proofs, and available SDKs, see the official Midnight developer documentation.