Skip to main content

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

EndpointMethodDescription
/healthGETBasic health check
/health/fullGETFull health with indexer status
/api/searchGETUnified search
/api/blocksGETList blocks
/api/blocks/:idGETGet block by height or hash
/api/transactionsGETList transactions
/api/tx/:idGETGet transaction details
/api/contract-actionsGETList contract actions
/api/contract/:addressGETGet latest contract action
/api/viewing-keyPOSTConnect viewing key
/api/viewing-key/:sessionIdDELETEDisconnect session
/api/dust-statusPOSTGet dust status
/api/unshielded/:addressGETGet unshielded address data

Live SSE Endpoints

EndpointEvent TypeDescription
/live/blocksblockReal-time block stream
/live/contract-actionscontractActionContract action stream
/live/zswap-ledger-eventszswapLedgerEventZSwap events
/live/dust-ledger-eventsdustLedgerEventDust events
/live/unshielded-transactionsunshieldedTransactionUnshielded tx stream
/live/shielded-transactionsshieldedTransactionShielded 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:

ParameterTypeDefaultDescription
limitnumber20Items per page (max: 100)
offsetnumber0Items to skip
sortBystringvariesSort field
sortDirstringdescSort direction (asc/desc)

Block Enrichment

Block endpoints support additional data:

ParameterTypeDefaultDescription
enrichedbooleanfalseInclude enriched data
includeNodebooleanfalseInclude node data
includeTransactionsbooleanfalseInclude 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