Databento.Client 3.0.17-beta

Additional Details

Use version 3.0.29-beta to benefit from more robust package and enhanced features.

This is a prerelease version of Databento.Client.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Databento.Client --version 3.0.17-beta
                    
NuGet\Install-Package Databento.Client -Version 3.0.17-beta
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Databento.Client" Version="3.0.17-beta" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Databento.Client" Version="3.0.17-beta" />
                    
Directory.Packages.props
<PackageReference Include="Databento.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Databento.Client --version 3.0.17-beta
                    
#r "nuget: Databento.Client, 3.0.17-beta"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Databento.Client@3.0.17-beta
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Databento.Client&version=3.0.17-beta&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Databento.Client&version=3.0.17-beta&prerelease
                    
Install as a Cake Tool

databento-dotnet

NuGet NuGet Downloads GitHub Release License

A high-performance .NET client for accessing Databento market data, supporting both real-time streaming and historical data queries.

⚠️ Beta Software: This is a newly developed client library. While functional and tested, it should be thoroughly validated in your specific use case before production deployment. Please report any issues to the issue tracker.

Installation

📦 Package: Databento.Client on NuGet.org

Install via .NET CLI:

dotnet add package Databento.Client --version 3.0.6-beta

Or via Package Manager Console:

Install-Package Databento.Client -Version 3.0.6-beta

Or add directly to your .csproj:

<ItemGroup>
  <PackageReference Include="Databento.Client" Version="3.0.6-beta" />
</ItemGroup>

Build from Source

See Building section below for instructions on building from source.

Features

  • Live Streaming: Real-time market data with async/await and IAsyncEnumerable support
  • Historical Data: Query past market data with time-range filtering
  • Cross-Platform: Works on Windows, Linux, and macOS
  • High Performance: Built on top of Databento's C++ client library
  • Type-Safe: Strongly-typed API with full IntelliSense support
  • .NET 8: Modern C# with nullable reference types

Implementation Status

Record Type Coverage: 100% ✅

All 16 DBN record types from databento-cpp are fully implemented:

Record Type Status Size Description
TradeMessage 48 bytes Trades (RType 0x00)
MboMessage 56 bytes Market by Order (RType 0xA0)
Mbp1Message 80 bytes Market by Price Level 1 (RType 0x01)
Mbp10Message 368 bytes Market by Price Level 10 (RType 0x0A)
OhlcvMessage 56 bytes OHLCV bars - deprecated, 1s, 1m, 1h, 1d, EOD (RType 0x11, 0x20-0x24)
StatusMessage 40 bytes Trading status (RType 0x12)
InstrumentDefMessage 520 bytes Instrument definitions (RType 0x13)
ImbalanceMessage 112 bytes Order imbalances (RType 0x14)
ErrorMessage 320 bytes Error messages (RType 0x15)
SymbolMappingMessage 176 bytes Symbol mappings (RType 0x16)
SystemMessage 320 bytes System messages & heartbeats (RType 0x17)
StatMessage 80 bytes Market statistics (RType 0x18)
BboMessage 80 bytes Best Bid/Offer - 1s, 1m (RType 0xC3-0xC4)
CbboMessage 80 bytes Consolidated BBO - 1s, 1m (RType 0xC0-0xC1)
Cmbp1Message 80 bytes Consolidated Market by Price (RType 0xB1)
TcbboMessage 80 bytes Trade with Consolidated BBO (RType 0xC2)
UnknownRecord Variable Fallback for unrecognized types

API Coverage

Feature databento-cpp databento-dotnet Status
Live Streaming Complete
Subscribe to datasets Complete
Multiple symbol subscription Complete
Schema filtering Complete
Start/Stop streaming Complete
Record Deserialization Complete
All 16 record types Complete
Fixed-point price conversion Complete
Timestamp handling Complete
Helper Utilities Complete
FlagSet (bit flags) Complete
Constants & sentinel values Complete
Schema enums Complete
Historical Client Complete (time-range queries)
Time-range queries Complete with IAsyncEnumerable
Batch downloads Not yet implemented
Metadata & Symbol Mapping Complete
Instrument metadata queries 10+ metadata API methods working
Symbol resolution Full TsSymbolMap & PitSymbolMap support
Advanced Features
Compression (zstd) Handled by native layer
SSL/TLS Handled by native layer
Reconnection logic ⚠️ Delegated to databento-cpp

Implementation Statistics

  • Total Record Types: 16/16 (100%)
  • Enumerations: 11/11 (100%)
    • Schema, RType, Action, Side, InstrumentClass, MatchAlgorithm, UserDefinedInstrument, SecurityUpdateAction, StatType, StatUpdateAction, SType
  • Helper Classes: 3/3 (100%)
    • FlagSet, Constants, BidAskPair/ConsolidatedBidAskPair
  • Live Streaming: Fully functional
  • Binary Deserialization: All DBN formats supported
  • Lines of Code: ~2,500 in high-level API, ~500 in P/Invoke layer, ~800 in native wrapper

Recent Changes

Latest (November 2025) - Production Ready

  • ✅ Reference API implementation (SecurityMaster, AdjustmentFactors, CorporateActions)
  • ✅ OpenTelemetry telemetry with retry policies
  • ✅ Complete metadata & symbol mapping (TsSymbolMap, PitSymbolMap)
  • ✅ All 16 record types with proper deserialization
  • ✅ Thread-safe LiveClient with reconnection support

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Your .NET Application                     │
└────────────────────────┬────────────────────────────────────┘
                         │
┌────────────────────────▼────────────────────────────────────┐
│           Databento.Client (High-Level API)                  │
│   • LiveClient, HistoricalClient                            │
│   • Async/await, IAsyncEnumerable, Events                   │
└────────────────────────┬────────────────────────────────────┘
                         │
┌────────────────────────▼────────────────────────────────────┐
│        Databento.Interop (P/Invoke Layer)                   │
│   • SafeHandles, Marshaling                                 │
└────────────────────────┬────────────────────────────────────┘
                         │ P/Invoke
┌────────────────────────▼────────────────────────────────────┐
│      Databento.Native (C Wrapper - CMake)                   │
│   • C exports wrapping databento-cpp                        │
└────────────────────────┬────────────────────────────────────┘
                         │
┌────────────────────────▼────────────────────────────────────┐
│            databento-cpp (Git Submodule)                    │
│   • Live streaming, Historical queries                      │
│   • DBN encoding/decoding                                   │
└─────────────────────────────────────────────────────────────┘

Prerequisites

For Building

Required:

  • .NET 8 SDK or later
  • CMake 3.24 or later
  • C++17 compatible compiler:
    • Windows: Visual Studio 2019 or later
    • Linux: GCC 9+ or Clang 10+
    • macOS: Xcode 11+

Automatically fetched by CMake:

  • databento-cpp (via FetchContent)
  • OpenSSL 3.0+
  • Zstandard (zstd)
  • nlohmann_json

For Using (NuGet Package)

  • .NET 8 Runtime or later

Quick Start

1. Install Package

dotnet add package Databento.Client --version 3.0.5-beta

2. Set API Key

Set your Databento API key as an environment variable:

Windows:

$env:DATABENTO_API_KEY="your-api-key-here"

Linux/macOS:

export DATABENTO_API_KEY="your-api-key-here"

Get your API key at https://databento.com/portal/keys

3. Write Code - Live Streaming Example

using Databento.Client.Builders;
using Databento.Client.Models;

// Get API key from environment variable (secure)
var apiKey = Environment.GetEnvironmentVariable("DATABENTO_API_KEY")
    ?? throw new InvalidOperationException("DATABENTO_API_KEY environment variable not set");

// Create live client
await using var client = new LiveClientBuilder()
    .WithApiKey(apiKey)
    .Build();

// Subscribe to events
client.DataReceived += (sender, e) =>
{
    Console.WriteLine($"Received: {e.Record}");
};

// Subscribe to NVDA trades
await client.SubscribeAsync(
    dataset: "EQUS.MINI",
    schema: Schema.Trades,
    symbols: new[] { "NVDA" }
);

// Start streaming
await client.StartAsync();

// Stream records using IAsyncEnumerable
await foreach (var record in client.StreamAsync())
{
    // Process records
    if (record is TradeMessage trade)
    {
        Console.WriteLine($"Trade: {trade.InstrumentId} @ {trade.PriceDecimal}");
    }
}

4. Historical Data Example

using Databento.Client.Builders;
using Databento.Client.Models;

// Get API key from environment variable (secure)
var apiKey = Environment.GetEnvironmentVariable("DATABENTO_API_KEY")
    ?? throw new InvalidOperationException("DATABENTO_API_KEY environment variable not set");

// Create historical client
await using var client = new HistoricalClientBuilder()
    .WithApiKey(apiKey)
    .Build();

// Define time range - Static trading day: November 11-12, 2025
var startTime = new DateTimeOffset(2025, 11, 11, 0, 0, 0, TimeSpan.Zero); // 11/11/2025 00:00 UTC
var endTime = new DateTimeOffset(2025, 11, 12, 23, 59, 59, TimeSpan.Zero);   // 11/12/2025 23:59 UTC

// Query historical trades
await foreach (var record in client.GetRangeAsync(
    dataset: "EQUS.MINI",
    schema: Schema.Trades,
    symbols: new[] { "NVDA" },
    startTime: startTime,
    endTime: endTime))
{
    Console.WriteLine($"Historical record: {record}");
}

Try it yourself: Run the included example with:

dotnet run --project examples/Historical.Readme.Example/Historical.Readme.Example.csproj

Building

Build All (Native + .NET)

# Windows
./build/build-all.ps1 -Configuration Release

# Linux/macOS
./build/build-all.sh --configuration Release

Build Native Library Only

# Windows
./build/build-native.ps1 -Configuration Release

# Linux/macOS
./build/build-native.sh --configuration Release

Build .NET Solution Only

dotnet build databento-dotnet.sln -c Release

Project Structure

databento_client/
├── src/
│   ├── Databento.Native/          # C++ native wrapper
│   │   ├── include/               # C API headers
│   │   ├── src/                   # C++ implementation
│   │   └── CMakeLists.txt
│   ├── Databento.Interop/         # P/Invoke layer
│   │   ├── Native/                # P/Invoke declarations
│   │   └── Handles/               # SafeHandle wrappers
│   └── Databento.Client/          # High-level .NET API
│       ├── Live/                  # Live streaming
│       ├── Historical/            # Historical queries
│       ├── Reference/             # Reference data APIs
│       ├── Models/                # Data models
│       └── Builders/              # Builder pattern
├── examples/
│   ├── LiveStreaming.Example/
│   ├── HistoricalData.Example/
│   ├── Reference.Example/
│   └── (26+ examples total)
├── build/
│   ├── build-native.ps1           # Native build (Windows)
│   ├── build-native.sh            # Native build (Linux/macOS)
│   └── build-all.ps1              # Full solution build
└── databento-dotnet.sln           # Visual Studio solution

Running Examples

Prerequisites: Set the DATABENTO_API_KEY environment variable (see API Key Setup above).

# Run live streaming example
dotnet run --project examples/LiveStreaming.Example

# Run historical data example
dotnet run --project examples/HistoricalData.Example

# Run reference data example
dotnet run --project examples/Reference.Example

Supported Schemas

  • MBO: Market by order
  • MBP-1: Market by price (Level 1)
  • MBP-10: Market by price (Level 10)
  • Trades: Trade messages
  • OHLCV: OHLCV bars (1s, 1m, 1h, 1d)
  • Definition: Instrument definitions
  • Statistics: Market statistics
  • Status: Trading status
  • Imbalance: Order imbalances

API Documentation

LiveClient

ILiveClient client = new LiveClientBuilder()
    .WithApiKey(apiKey)
    .Build();

// Events
client.DataReceived += (sender, e) => { /* ... */ };
client.ErrorOccurred += (sender, e) => { /* ... */ };

// Methods
await client.SubscribeAsync(dataset, schema, symbols);
await client.StartAsync();
await client.StopAsync();

// IAsyncEnumerable streaming
await foreach (var record in client.StreamAsync()) { /* ... */ }

HistoricalClient

IHistoricalClient client = new HistoricalClientBuilder()
    .WithApiKey(apiKey)
    .Build();

// Query historical data
await foreach (var record in client.GetRangeAsync(
    dataset, schema, symbols, startTime, endTime))
{
    // Process records
}

ReferenceClient

IReferenceClient client = new ReferenceClientBuilder()
    .SetApiKey(apiKey)
    .Build();

// Get latest security master data
var records = await client.SecurityMaster.GetLastAsync(
    symbols: new[] { "NVDA" },
    stypeIn: SType.RawSymbol
);

// Get security master data for a date range
var historicalRecords = await client.SecurityMaster.GetRangeAsync(
    start: DateTimeOffset.UtcNow.AddDays(-30),
    end: DateTimeOffset.UtcNow,
    symbols: new[] { "NVDA" }
);

// Get adjustment factors
var adjustments = await client.AdjustmentFactors.GetRangeAsync(
    start: DateTimeOffset.UtcNow.AddDays(-90),
    symbols: new[] { "NVDA" }
);

// Get corporate actions
var corporateActions = await client.CorporateActions.GetRangeAsync(
    start: DateTimeOffset.UtcNow.AddYears(-1),
    symbols: new[] { "NVDA" }
);

Performance Considerations

  1. Memory Management: Records are copied from native to managed memory. For high-throughput scenarios, consider batching.

  2. Threading: Callbacks fire on native threads. The library marshals them to the .NET thread pool via Channel<T>.

  3. Backpressure: The Channel<T> is unbounded by default. Consider adding bounds for memory-constrained environments.

  4. Disposal: Always use await using to ensure proper resource cleanup.

Troubleshooting

Native Library Not Found

Ensure the native library is built and copied to the output directory:

# Rebuild native library
./build/build-native.ps1

CMake Configuration Fails

Ensure all prerequisites are installed:

# Windows (with chocolatey)
choco install cmake visualstudio2022buildtools

# Linux (Ubuntu/Debian)
sudo apt-get install cmake build-essential libssl-dev libzstd-dev

# macOS (with Homebrew)
brew install cmake openssl zstd

API Authentication Errors

Verify your API key is correct and has the required permissions:

# Test API key
curl -H "Authorization: Bearer your-api-key" https://api.databento.com/v1/metadata.list_datasets

License

Apache 2.0 License. See LICENSE for details.

Resources

Acknowledgments

Built on top of Databento's official C++ client.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.2.0 19 12/9/2025
4.1.1 110 11/29/2025
4.1.0 96 11/29/2025
4.0.1-beta 180 11/26/2025
4.0.0-beta 181 11/25/2025
3.0.29-beta 206 11/23/2025 3.0.29-beta is deprecated because it is no longer maintained and has critical bugs.
3.0.28-beta 176 11/23/2025 3.0.28-beta is deprecated because it is no longer maintained and has critical bugs.
3.0.26-beta 230 11/22/2025 3.0.26-beta is deprecated because it is no longer maintained.
3.0.24-beta 466 11/21/2025 3.0.24-beta is deprecated because it is no longer maintained.
3.0.23-beta 470 11/19/2025 3.0.23-beta is deprecated because it is no longer maintained.
3.0.22-beta 473 11/19/2025 3.0.22-beta is deprecated because it is no longer maintained.
3.0.21-beta 469 11/18/2025 3.0.21-beta is deprecated because it is no longer maintained.
3.0.20-beta 467 11/18/2025 3.0.20-beta is deprecated because it is no longer maintained.
3.0.19-beta 478 11/18/2025 3.0.19-beta is deprecated because it is no longer maintained.
3.0.18-beta 471 11/18/2025 3.0.18-beta is deprecated because it is no longer maintained.
3.0.17-beta 349 11/17/2025 3.0.17-beta is deprecated because it is no longer maintained.
3.0.16-beta 349 11/16/2025 3.0.16-beta is deprecated because it is no longer maintained.
3.0.15-beta 349 11/16/2025 3.0.15-beta is deprecated because it is no longer maintained.
3.0.14-beta 298 11/16/2025 3.0.14-beta is deprecated because it is no longer maintained.
3.0.13-beta 296 11/16/2025 3.0.13-beta is deprecated because it is no longer maintained.
3.0.12-beta 299 11/16/2025 3.0.12-beta is deprecated because it is no longer maintained.
3.0.11-beta 301 11/16/2025 3.0.11-beta is deprecated because it is no longer maintained.
3.0.10-beta 308 11/16/2025 3.0.10-beta is deprecated because it is no longer maintained.
3.0.9-beta 300 11/16/2025 3.0.9-beta is deprecated because it is no longer maintained.
3.0.8-beta 301 11/16/2025 3.0.8-beta is deprecated because it is no longer maintained.
3.0.7-beta 303 11/16/2025 3.0.7-beta is deprecated because it is no longer maintained.
3.0.6-beta 298 11/16/2025 3.0.6-beta is deprecated because it is no longer maintained.
3.0.5-beta 304 11/16/2025 3.0.5-beta is deprecated because it is no longer maintained.

v3.0.17-beta: Critical fixes - Added ConfigureAwait(false) to prevent deadlocks, fixed race condition in LiveClient.StartAsync, added SafeInvokeEvent for subscriber exception isolation, added Marshal.Copy protection, Channel.Writer.TryWrite check, Parse to TryParse conversions, and eliminated code duplication in Reference APIs.