Every new account receives $125 in free data credits. These credits allow you to start receiving actual historical data immediately and verify your integration at no cost.
Choose a service
Databento provides two data services: historical and live. These two services are nearly identical, but we separate them due to licensing fees and the differences between response-request and real-time streaming APIs. You can choose to integrate just one or both services.
| Historical | Live | Reference | |
|---|---|---|---|
| Coverage | Data from at least 24 hours ago. | Intraday historical data from within the last 24 hours and real-time data. | Historical with intraday updates. |
| Pricing | Usage-based or flat-rate. No monthly license fees. | Usage-based or flat-rate. Monthly license fees apply. | Dataset license fees apply. |
| Access | Client libraries (C++, Python, and Rust) and API (HTTP). | Client libraries (C++, Python, and Rust) and API (Raw). | Client libraries (Python) and API (HTTP). |
Getting historical data
Select how you will be integrating Databento below to see installation instructions.
If you don't see an official client library for your preferred language, you can still integrate our historical service through its HTTP API.
The easiest way of using our library is by embedding it with CMake FetchContent.
The minimum required CMake version is 3.14.
Create a CMakeLists.txt that looks like the following:
You'll also need to ensure the following dependencies are installed:
- OpenSSL (minimum version 3.0)
- Libcrypto
- Zstandard (zstd)
# CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
project(databento_historical_example)
include(FetchContent)
FetchContent_Declare(
databento
GIT_REPOSITORY https://github.com/databento/databento-cpp
GIT_TAG HEAD
)
FetchContent_MakeAvailable(databento)
add_executable(example main.cpp)
target_link_libraries(example PRIVATE databento::databento)
A simple Databento application looks like this:
#include <databento/constants.hpp>
#include <databento/historical.hpp>
#include <iostream>
using namespace databento;
int main() {
auto client =
Historical::Builder().SetKey("YOUR_API_KEY").Build();
auto print_trades = [](const Record& record) {
const auto& trade_msg = record.Get<TradeMsg>();
std::cout << trade_msg << '\n';
return KeepGoing::Continue;
};
client.TimeseriesGetRange(
"GLBX.MDP3", {"2022-06-10T14:30", "2022-06-10T14:40"},
kAllSymbols, Schema::Trades, SType::RawSymbol,
SType::InstrumentId, {}, {}, print_trades);
}
Copy this to a file named main.cpp in the same directory as the CMakeLists.txt, then compile and run the application.
This replays 10 minutes of trades of the entire CME Globex market event-by-event. You can modify this application to specify particular instruments, and schemas,
Let's get ESM2 and NQZ2 data in 1-second OHLCV bars:
#include <databento/dbn.hpp>
#include <databento/historical.hpp>
#include <databento/symbol_map.hpp>
#include <iostream>
using namespace databento;
int main() {
auto client =
Historical::Builder().SetKey("YOUR_API_KEY").Build();
TsSymbolMap symbol_map;
auto decode_symbols = [&symbol_map](const Metadata& metadata) {
symbol_map = metadata.CreateSymbolMap();
};
auto print_trades = [&symbol_map](const Record& record) {
const auto& trade_msg = record.Get<TradeMsg>();
std::cout << "Received trade for "
<< symbol_map.At(trade_msg) << ": " << trade_msg
<< '\n';
return KeepGoing::Continue;
};
client.TimeseriesGetRange(
"GLBX.MDP3", {"2022-06-10T14:30", "2022-06-10T14:40"},
{"ESM2", "NQZ2"}, Schema::Trades, SType::RawSymbol,
SType::InstrumentId, {}, decode_symbols, print_trades);
}
Rebuild and run the application with:
You have successfully written your first historical data application with Databento! Here are shortcuts to some of the next steps you can take:
- To download a large amount of data to disk, see how to do a batch download of data files.
- To get another dataset, just swap the dataset. You can get a list of datasets and their names from our metadata.
- You can use our symbology API to find other instrument IDs.
- You can also find dataset names and instrument IDs interactively from our search.
To learn more, read the full documentation for our historical service under API reference - Historical.
Getting live data
Select how you will be integrating Databento below to see installation instructions.
If you don't see an official client library for your preferred language, you can still integrate our service via the Raw API.
The easiest way of using our library is by embedding it with CMake FetchContent.
The minimum required CMake version is 3.14.
Create a CMakeLists.txt that looks like the following:
You'll also need to ensure the following dependencies are installed:
- OpenSSL (minimum version 3.0)
- Libcrypto
- Zstandard (zstd)
# CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
project(databento_live_example)
include(FetchContent)
FetchContent_Declare(
databento
GIT_REPOSITORY https://github.com/databento/databento-cpp
GIT_TAG HEAD
)
FetchContent_MakeAvailable(databento)
add_executable(example main.cpp)
target_link_libraries(example PRIVATE databento::databento)
A simple Databento live application looks like this:
Copy this to a file named main.cpp in the same directory as the CMakeLists.txt, then compile and run the application.
This will stream and print trades for E-mini S&P 500 futures contracts, event-by-event, for 10 seconds. You can modify this application to specify other instruments and schemas.
#include <chrono>
#include <databento/live.hpp>
#include <databento/symbol_map.hpp>
#include <iostream>
#include <string>
#include <thread>
using namespace databento;
int main() {
PitSymbolMap symbol_mappings;
auto client = LiveThreaded::Builder()
.SetKey("YOUR_API_KEY")
.SetDataset("GLBX.MDP3")
.BuildThreaded();
auto handler = [&symbol_mappings](const Record& rec) {
symbol_mappings.OnRecord(rec);
if (auto* trade = rec.GetIf<TradeMsg>()) {
std::cout << "Received trade for "
<< symbol_mappings[trade->hd.instrument_id]
<< ':' << *trade << '\n';
}
return KeepGoing::Continue;
};
client.Subscribe({"ES.FUT"}, Schema::Trades, SType::Parent);
client.Start(handler);
std::this_thread::sleep_for(std::chrono::seconds{10});
return 0;
}
Let's get ESZ5 and ESZ5 C6000 data in 1-second OHLCV bars.
We'll also handle unexpected messages and errors in case something goes wrong.
Since we're handling more messages, it makes sense to change to a switch statement based on
the rtype or record type field in the header of each record.
Rebuild and run the application with:
#include <chrono>
#include <databento/live.hpp>
#include <databento/symbol_map.hpp>
#include <iostream>
#include <string>
#include <thread>
using namespace databento;
int main() {
PitSymbolMap symbol_mappings;
auto client = LiveThreaded::Builder()
.SetKey("YOUR_API_KEY")
.SetDataset("GLBX.MDP3")
.BuildThreaded();
auto handler = [&symbol_mappings](const Record& rec) {
if (auto* trade = rec.GetIf<TradeMsg>()) {
std::cout << "Received trade for "
<< symbol_mappings[trade->hd.instrument_id]
<< ':' << *trade << '\n';
} else if (auto* mapping = rec.GetIf<SymbolMappingMsg>()) {
std::cout << "Received symbol mapping: " << *mapping
<< '\n';
symbol_mappings.OnSymbolMapping(*mapping);
} else if (auto* system_msg = rec.GetIf<SystemMsg>()) {
if (!system_msg->IsHeartbeat()) {
std::cout << "Received system msg: " << system_msg->Msg()
<< '\n';
}
} else if (auto* error_msg = rec.GetIf<ErrorMsg>()) {
std::cerr << "Received error from gateway: "
<< error_msg->Err() << '\n';
} else {
std::cerr << "Received unknown record with rtype "
<< std::hex
<< static_cast<std::uint16_t>(rec.RType())
<< '\n';
}
return KeepGoing::Continue;
};
client.Subscribe({"ESZ5", "ESZ5 C6000"}, Schema::Trades,
SType::RawSymbol);
client.Start(handler);
std::this_thread::sleep_for(std::chrono::seconds{10});
return 0;
}
You have successfully written your first live data application with Databento! To learn more, read the full documentation for our live service under API reference - Live.