Explorer API
The Explorer API provides comprehensive access to blockchain data on the Midnight network, including blocks, transactions, contracts, and real-time data streams.
Base URL
http://explorer.nocy.io:4000
Overview
The Explorer API offers:
- REST Endpoints - Query blocks, transactions, contracts, and addresses
- Search - Unified search across all blockchain entities
- Live Streams - Real-time data via Server-Sent Events (SSE)
- Viewing Keys - Session-based access to private data
REST Endpoints
| Endpoint | Method | Description |
|---|---|---|
/health | GET | Basic health check |
/health/full | GET | Full health with indexer status |
/api/search | GET | Unified search |
/api/blocks | GET | List blocks |
/api/blocks/:id | GET | Get block by height or hash |
/api/transactions | GET | List transactions |
/api/tx/:id | GET | Get transaction details |
/api/contract-actions | GET | List contract actions |
/api/contract/:address | GET | Get latest contract action |
/api/viewing-key | POST | Connect viewing key |
/api/viewing-key/:sessionId | DELETE | Disconnect session |
/api/dust-status | POST | Get dust status |
/api/unshielded/:address | GET | Get unshielded address data |
Live SSE Endpoints
| Endpoint | Event Type | Description |
|---|---|---|
/live/blocks | block | Real-time block stream |
/live/contract-actions | contractAction | Contract action stream |
/live/zswap-ledger-events | zswapLedgerEvent | ZSwap events |
/live/dust-ledger-events | dustLedgerEvent | Dust events |
/live/unshielded-transactions | unshieldedTransaction | Unshielded tx stream |
/live/shielded-transactions | shieldedTransaction | Shielded tx stream |
Health Check
curl http://explorer.nocy.io:4000/health
Response:
{
"status": "ok",
"timestamp": "2024-12-13T12:00:00.000Z"
}
Full Health Check
curl http://explorer.nocy.io:4000/health/full
Response:
{
"status": "ok",
"timestamp": "2024-12-13T12:00:00.000Z",
"indexer": {
"status": "synced",
"latestBlock": 125000,
"latestBlockTime": "2024-12-13T11:59:50.000Z"
}
}
Common Query Parameters
Pagination
All list endpoints support pagination:
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 20 | Items per page (max: 100) |
offset | number | 0 | Items to skip |
sortBy | string | varies | Sort field |
sortDir | string | desc | Sort direction (asc/desc) |
Block Enrichment
Block endpoints support additional data:
| Parameter | Type | Default | Description |
|---|---|---|---|
enriched | boolean | false | Include enriched data |
includeNode | boolean | false | Include node data |
includeTransactions | boolean | false | Include transactions |
Quick Example
// Search for a block, transaction, or address
const searchRes = await fetch(
'http://explorer.nocy.io:4000/api/search?q=1000'
);
const results = await searchRes.json();
// Get latest blocks
const blocksRes = await fetch(
'http://explorer.nocy.io:4000/api/blocks?limit=10'
);
const blocks = await blocksRes.json();
// Subscribe to new blocks
const eventSource = new EventSource(
'http://explorer.nocy.io:4000/live/blocks'
);
eventSource.addEventListener('block', (event) => {
const block = JSON.parse(event.data);
console.log('New block:', block.height);
});
Next Steps
- Search - Unified search endpoint
- Blocks - Block queries
- Transactions - Transaction queries
- Live Streams - Real-time SSE endpoints