Support

Historical data: Introduction

Overview

In this example, we'll show how to:

  • Access metadata about datasets and historical data
  • Request historical data
  • Resolve various symbology types

The first step in using the Historical API is to create an instance of the Historical client. This requires a valid API key, which can be found on the API Keys page.

You can also pass your API key into your environment directly. This is recommended for production applications.

import databento as db

historical_client = db.Historical("YOUR_API_KEY")

Accessing metadata

Before we request any data, there are some helper methods to assist in requesting data.

First, you will need to determine the dataset you are interested in. The dataset ID can be found in the dataset documentation, or from the online portal.

The available schemas for a dataset can be found with metadata.list_schemas. A list of all schemas and the fields for each schema can be found in the schema documentation.

The availability of historical data will vary depending on the dataset, as well as any applicable licensing. The metadata.get_dataset_range method will provide the start and end of historical availability.

The cost of historical data can be determined with metadata.get_cost.

import databento as db

historical_client = db.Historical("YOUR_API_KEY")

schemas = historical_client.metadata.list_schemas("GLBX.MDP3")
print(schemas)

dataset_range = historical_client.metadata.get_dataset_range("GLBX.MDP3")
print(dataset_range)

cost = historical_client.metadata.get_cost(
    dataset="GLBX.MDP3",
    schema="mbo",
    symbols="ESZ5",
    start="2025-11-16",
    end="2025-11-22",
)
print(f"Total cost = ${cost:.2f}")
['mbo', 'mbp-1', 'mbp-10', ..., 'definition', 'statistics', 'status']

{'start': '2010-06-06T00:00:00.000000000Z',
 'end': '2026-01-05T20:50:00.000000000Z',
 'schema': {'mbo': {'start': '2017-05-21T00:00:00.000000000Z',
                    'end': '2026-01-05T20:50:00.000000000Z'},
            ...
            'status': {'start': '2010-06-06T00:00:00.000000000Z',
                       'end': '2026-01-05T20:50:00.000000000Z'}}}

Total cost = $13.26
See also
See also

For a list of all metadata methods available, see our metadata documentation.

Requesting data

There are two primary methods to request data:

  • Streaming requests
  • Batch downloads

While the cost for requesting historical data is the same, these methods are different in how data is accessed. Streaming requests are well suited for smaller requests over short periods of time. Batch downloads are better for large requests over long periods of time. Refer to this FAQ for a detailed explanation on the differences between these two methods.

The first method to request data is with streaming requests using timeseries.get_range.

import databento as db

historical_client = db.Historical("YOUR_API_KEY")

dbn_store = historical_client.timeseries.get_range(
    dataset="GLBX.MDP3",
    schema="ohlcv-1h",
    symbols="ESZ5",
    start="2025-11-16",
    end="2025-11-22",
)

for record in dbn_store:
    print(record)
OhlcvMsg { hd: RecordHeader { length: 14, rtype: Ohlcv1H, publisher_id: GlbxMdp3Glbx, instrument_id: 294973, ts_event: 1763334000000000000 }, open: 6764.750000000, high: 6770.500000000, low: 6740.500000000, close: 6766.750000000, volume: 17691 }
OhlcvMsg { hd: RecordHeader { length: 14, rtype: Ohlcv1H, publisher_id: GlbxMdp3Glbx, instrument_id: 294973, ts_event: 1763337600000000000 }, open: 6766.500000000, high: 6778.750000000, low: 6755.750000000, close: 6776.000000000, volume: 15413 }
OhlcvMsg { hd: RecordHeader { length: 14, rtype: Ohlcv1H, publisher_id: GlbxMdp3Glbx, instrument_id: 294973, ts_event: 1763341200000000000 }, open: 6776.250000000, high: 6780.250000000, low: 6770.000000000, close: 6770.750000000, volume: 11498 }
...
OhlcvMsg { hd: RecordHeader { length: 14, rtype: Ohlcv1H, publisher_id: GlbxMdp3Glbx, instrument_id: 294973, ts_event: 1763751600000000000 }, open: 6654.250000000, high: 6677.500000000, low: 6641.500000000, close: 6649.500000000, volume: 212633 }
OhlcvMsg { hd: RecordHeader { length: 14, rtype: Ohlcv1H, publisher_id: GlbxMdp3Glbx, instrument_id: 294973, ts_event: 1763755200000000000 }, open: 6649.250000000, high: 6654.000000000, low: 6614.000000000, close: 6622.500000000, volume: 314723 }
OhlcvMsg { hd: RecordHeader { length: 14, rtype: Ohlcv1H, publisher_id: GlbxMdp3Glbx, instrument_id: 294973, ts_event: 1763758800000000000 }, open: 6622.500000000, high: 6632.750000000, low: 6621.000000000, close: 6631.500000000, volume: 64542 }

The other method to request data is with batch downloads using batch.submit_job.

import databento as db

historical_client = db.Historical("YOUR_API_KEY")

job = historical_client.batch.submit_job(
    dataset="GLBX.MDP3",
    schema="ohlcv-1m",
    symbols="ESZ5",
    start="2025-11-16",
    end="2025-11-22",
)

This data will first be prepared by our system, then made available for download once complete. See our batch download example for more information on requesting and downloading batch jobs.

Info
Info

Batch downloads are also available for download from the Download Center.

Resolving symbology

All data records will contain an instrument_id field that maps a numerical ID to an instrument for a particular UTC date. Databento also supports other symbology types, which are described in our symbology documentation.

The symbology.resolve method can assist with the mappings between these different symbology types.

When requesting data with timeseries.get_range, these symbology mappings will be found with the DBNStore.symbology attribute.

import databento as db

historical_client = db.Historical("YOUR_API_KEY")

mapping = historical_client.symbology.resolve(
    dataset="GLBX.MDP3",
    symbols=294973,
    stype_in="instrument_id",
    stype_out="raw_symbol",
    start_date="2025-11-16",
    end_date="2025-11-22",
)

print(mapping)
{'end_date': '2025-11-22',
 'message': 'OK',
 'not_found': [],
 'partial': [],
 'result': {'294973': [{'d0': '2025-11-14', 'd1': '2025-11-22', 's': 'ESZ5'}]},
 'start_date': '2025-11-16',
 'status': 0,
 'stype_in': 'instrument_id',
 'stype_out': 'raw_symbol',
 'symbols': ['294973']}