Skip to main content
The BlockDB .NET SDK targets .NET 10 and covers all EVM API endpoints. It handles OAuth 2.0 token management, cursor-based pagination, retries, and rate-limiting automatically.

Where it’s available

Installation

dotnet add package BlockDb.Api.Sdk

Quick examples

// Program.cs
using BlockDb.Api.Sdk;

builder.Services.AddBlockDbClient(options =>
{
    options.ClientId     = Environment.GetEnvironmentVariable("BLOCKDB_CLIENT_ID")!;
    options.ClientSecret = Environment.GetEnvironmentVariable("BLOCKDB_CLIENT_SECRET")!;
});

// Inject and use anywhere
public class MyService
{
    private readonly BlockDbClient _blockDb;
    public MyService(BlockDbClient blockDb) => _blockDb = blockDb;

    public async Task<IReadOnlyList<Block>> GetRecentBlocksAsync(CancellationToken ct)
    {
        var response = await _blockDb.Primitives.GetBlocksAsync(new GetBlocksRequest
        {
            ChainId   = 1,
            FromBlock = 21_000_000,
            ToBlock   = 21_001_000,
            Limit     = 100
        }, ct);

        return response.Data;
    }
}
// 1-hour OHLCV candles for WETH/USDC
var candles = await client.Prices.Crypto.GetOhlcAsync(new GetPricesOhlcRequest
{
    ChainId           = 1,
    BaseTokenAddress  = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH
    QuoteTokenAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
    FromBlock         = 21_000_000,
    ToBlock           = 21_010_000,
    AggregationInterval = "1h",
});

foreach (var candle in candles.Data)
    Console.WriteLine($"{candle.OpenTimestamp}  O:{candle.Open}  H:{candle.High}  L:{candle.Low}  C:{candle.Close}");

Pagination

Every endpoint returns PagedResponse<T> with a Cursor property. Pass the cursor back to retrieve the next page.
string? cursor = null;
do
{
    var page = await client.Primitives.GetTransactionsAsync(new GetTransactionsRequest
    {
        ChainId   = 1,
        FromBlock = 20_000_000,
        ToBlock   = 20_100_000,
        Limit     = 1000,
        Cursor    = cursor,
    });

    ProcessBatch(page.Data);
    cursor = page.Cursor;
}
while (cursor is not null);

Configuration reference

new BlockDbClientOptions
{
    // Required
    ClientId     = "...",
    ClientSecret = "...",

    // Optional overrides
    ApiBaseUrl                = "https://api.blockdb.io",              // default
    AuthBaseUrl               = "https://user.blockdb.io",             // default
    Scopes                    = "offline_access api",                   // default
    HttpTimeout               = TimeSpan.FromSeconds(30),              // default
    TokenRefreshBufferSeconds = 60,                                     // default
    EnableRetry               = true,
    MaxRetries                = 3,
    RetryBaseDelay            = TimeSpan.FromMilliseconds(500),
    EnableRateLimiting        = true,
    MaxRequestsPerSecond      = 100,
}
Last modified on March 20, 2026