Live

To access Databento's live API, first create an instance of the Live client. The entire API for a streaming session is exposed through instance methods of the client.

Databento's Live client is built with Python's asyncio module and can be easily integrated into asynchronous applications.

Note that the API key can be passed as a parameter, which is not recommended for production applications. Instead, you can leave out this parameter to pass your API key via the DATABENTO_API_KEY environment variable:

Parameters

Parameter
Type
Required
Description
key
str
optional
32-character API key. Found on your API keys page. If None then DATABENTO_API_KEY environment variable is used.
gateway
str
optional
The url of the remote gateway to connect to. This is for advanced use.
port
int
optional
The port to connect to the remote gateway on. This is for advanced use.
ts_out
bool, default False
optional
Whether the gateway should append the send timestamp (ts_out) to each record.
heartbeat_interval_s
int, default None
optional
The interval in seconds at which the gateway will send heartbeat records if no other data records are sent. By default heartbeats will be sent at the gateway's default interval. Must be between 5 and 1800 seconds.
reconnect_policy
ReconnectPolicy or str, default None
optional
The reconnection policy for automatically resuming a live session when an unexpected disconnection occurs.
slow_reader_behavior
SlowReaderBehavior or str, default None
optional
How the gateway should handle a connection unable to keep up with realtime.
compression
Compression or str, default None
optional
Sets the compression mode for the read stream. Uncompressed by default.
loop
asyncio.AbstractEventLoop, default None
optional
The event loop to run the client connection in. If None, a shared event loop running on a background thread will be used.
API method
1
2
3
4
5
6
7
8
9
10
11
class Live(
    key: str | None = None,
    gateway: str | None = None,
    port: int | None = None,
    ts_out: bool = False,
    heartbeat_interval_s: int | None = None,
    reconnect_policy: ReconnectPolicy | str = ReconnectPolicy.NONE,
    slow_reader_behavior: SlowReaderBehavior | str | None = None,
    compression: Compression | str = Compression.NONE,
    loop: asyncio.AbstractEventLoop | None = None,
)
Example usage
1
2
3
4
5
6
7
import databento as db

# Pass as parameter
client = db.Live(key="$YOUR_API_KEY")

# Or, pass as `DATABENTO_API_KEY` environment variable
client = db.Live()