Configure the Databento client with an API key
mainThe library requires an API key (a 32-character string starting with db-) found in your Databento user portal. You can provide the key in two ways:
- As a parameter: Pass the key directly to the
db.Historicalordb.Liveconstructor. This is not recommended for production applications. - Via environment variable: Leave the parameter empty and set the
DATABENTO_API_KEYenvironment variable in your system.
import databento as db
# Pass as parameter (not recommended for production)
client = db.Historical('YOUR_API_KEY')
# Or, pass via `DATABENTO_API_KEY` environment variable
client = db.Historical()