Blockbook API
Purpose
Blockbook API serves as a dedicated controller offering standardized HTTP endpoints that expose blockchain data, focusing on indexing and caching for efficient querying. It addresses the need to provide normalized, consistent access to blockchain primitives—such as blocks, transactions, addresses, and fee estimates—across multiple blockchain networks. This subtopic solves the problem of abstracting diverse blockchain data structures into unified API responses, enabling clients to retrieve comprehensive blockchain information without dealing with chain-specific complexities.
Functionality
The Blockbook API controller implements a RESTful interface exposing a suite of endpoints that deliver blockchain data normalized into a common schema. Key workflows and capabilities include:
Blockchain Status and Info Retrieval
Returns the current synchronization status of the underlying Blockbook indexer and connected backend node, including block heights, mempool info, and versioning data.Block and Transaction Data Access
Provides access to blocks by height or hash, including paginated lists of transactions within blocks. Transactions are returned in a normalized format that spans multiple coin types, including UTXO and account-based chains.Address and XPUB Account Queries
Retrieves balances, transaction histories, tokens, and other details for single addresses or extended public keys (XPUBs). Supports filtering, paging, and varying detail levels to optimize data returned per client needs.UTXO Set Queries
Returns unspent transaction outputs for addresses or XPUBs on UTXO-based coins, supporting confirmation filtering.Transaction Sending
Exposes an endpoint to broadcast raw serialized transactions through the backend indexer infrastructure.Balance History and Fee Estimation
Provides historical balance changes over time and network fee estimates for specified confirmation targets.
Internally, the controller uses an Axios HTTP client with retry logic and timeout handling to communicate with the Blockbook backend services. Each endpoint maps to a corresponding Blockbook API route, capturing parameters and query options to refine returned data.
Example snippet illustrating the HTTP client setup with retry:
this.instance = axios.create({
timeout: timeout ?? 10000,
baseURL: args.httpURL,
headers: {
...(args.apiKey && { 'api-key': args.apiKey }),
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
axiosRetry(this.instance, {
retries,
retryDelay: axiosRetry.exponentialDelay,
retryCondition: axiosRetry.isNetworkOrIdempotentRequestError,
})
Each method wraps the HTTP call in error handling that transforms Axios errors into a unified API error response, while logging request durations for observability.
Integration
Blockbook API is a core subcomponent of the **Blockchain Data Indexing** main topic, focusing specifically on the REST API layer that exposes indexed blockchain data. It complements its sibling subtopic **Blockbook WebSocket**, which manages real-time event subscriptions over WebSocket connections.
Together, these subtopics provide a comprehensive interface for querying blockchain data:
Blockbook API delivers on-demand, paginated, and filtered access to blockchain data snapshots and histories.
Blockbook WebSocket pushes real-time updates about new blocks and transactions to subscribed clients.
The Blockbook API controller integrates with other components by:
Acting as the HTTP gateway to the Blockbook indexer backend, which continuously syncs blockchain data.
Serving as a building block for the Unified API Layer, which abstracts blockchain-specific details into consistent REST endpoints across multiple chains.
Supporting upper-layer services and clients that require blockchain data for wallet balance displays, transaction history, and fee estimation.
Unlike the parent topic’s general focus on indexing and caching, the Blockbook API subtopic uniquely provides the HTTP interface and request orchestration that enables efficient data retrieval tailored to client needs. It introduces detailed query parameters (paging, filtering, detail levels) and handles response normalization and error management, which are not covered by other subtopics.
Diagram
flowchart TD
Client[Client Application]
BlockbookAPI[Blockbook API Controller]
BlockbookBackend[Blockbook Indexer Backend]
Client -->|HTTP REST Request| BlockbookAPI
BlockbookAPI -->|HTTP Request| BlockbookBackend
BlockbookBackend -->|Blockchain Data| Blockchain[Blockchain Network]
BlockbookAPI -->|API Response| Client
This flowchart highlights the core request-response cycle where client applications interact with the Blockbook API controller, which in turn fetches data from the Blockbook backend indexer synchronized with the blockchain network.