Skip to main content
The BlockDB Python SDK supports Python 3.x and covers all EVM API endpoints. The primary client is async (built on httpx); a synchronous wrapper is included for scripts and notebooks.

Where it’s available

Installation

pip install blockdb

Quick examples

import asyncio
from blockdb import BlockDbClient
from blockdb.evm.primitives import BlocksRequest

async def main():
    async with BlockDbClient(
        client_id="YOUR_CLIENT_ID",
        client_secret="YOUR_CLIENT_SECRET",
    ) as client:
        page = await client.evm.primitives.get_blocks(
            BlocksRequest(
                chain_id=1,
                from_block=20_000_000,
                to_block=20_000_100,
                limit=100,
            )
        )
        for block in page.data:
            print(block.block_number, block.timestamp_utc)

asyncio.run(main())

Prices example

async with BlockDbClient(client_id="...", client_secret="...") as client:
    candles = await client.evm.prices.get_crypto_ohlc({
        "chain_id": 1,
        "base_token_address":  "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",  # WETH
        "quote_token_address": "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",  # USDC
        "from_block": 21_000_000,
        "to_block":   21_010_000,
    })
    for c in candles.data:
        print(c.open_timestamp, c.open, c.high, c.low, c.close)

Pagination

Every endpoint returns a PagedResponse[T] with a cursor field. Use async_pages to iterate all pages automatically:
async with BlockDbClient(client_id="...", client_secret="...") as client:
    cursor = None
    while True:
        page = await client.evm.primitives.get_blocks(
            {"chain_id": 1, "from_block": 18_000_000, "to_block": 19_000_000, "cursor": cursor}
        )
        process(page.data)
        cursor = page.cursor
        if not page.has_more:
            break

Configuration reference

from blockdb import BlockDbClient
from blockdb._config import ClientConfig, RetryPolicy

client = BlockDbClient(
    client_id="...",
    client_secret="...",
    config=ClientConfig(
        base_url="https://api.blockdb.io/v1",                       # default
        token_url="https://user.blockdb.io/api/authorization/token",# default
        scopes="offline_access api",                                 # default
        timeout=30.0,
        connect_timeout=10.0,
        retry_policy=RetryPolicy(),
        max_requests_per_second=None,  # no limit by default
    ),
)
Last modified on March 20, 2026