Databento Python Client

0.75.0 · active · verified Wed Apr 15

The official Python client library for Databento, providing fast, lightweight access to both live and historical market data from multiple venues and asset classes. It supports various schemas like MBO, MBP, OHLCV, and trades, and features an efficient Databento Binary Encoding (DBN) for data storage. The library is actively maintained with frequent releases, currently at version 0.75.0, offering consistent message schemas across live and historical data.

Warnings

Install

Imports

Quickstart

This quickstart initializes a Databento Historical client using an API key (preferably from an environment variable) and requests 100 trade records for E-mini S&P 500 futures for a specific hour on CME Globex, then converts the result to a pandas DataFrame and prints the head.

import databento as db
import os

api_key = os.environ.get('DATABENTO_API_KEY', 'YOUR_API_KEY')
if api_key == 'YOUR_API_KEY':
    print("Warning: DATABENTO_API_KEY environment variable not set. Using placeholder.")

client = db.Historical(api_key)

try:
    data = client.timeseries.get_range(
        dataset="GLBX.MDP3",
        schema="trades",
        symbols=["ES.FUT"],
        stype_in="parent",
        start="2023-01-01T00:00",
        end="2023-01-01T01:00",
        limit=100
    )
    df = data.to_df()
    print(df.head())
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →