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:

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:

The Blockbook API controller integrates with other components by:

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.