Historical.batch.download_async

Asynchronously download a batch job or a specific file to {output_dir}/{job_id}/.

Will automatically generate any necessary directories if they do not already exist.

Related: Download center.

Parameters

Parameter
Type
Required
Description
job_id
str
required
The batch job identifier.
output_dir
PathLike[str] or str
optional
The directory to download the file(s) to. If None, defaults to the current working directory.
filename_to_download
str
optional
The specific file to download. If None then will download all files for the batch job.
keep_zip
bool, default False
optional
If True, and filename_to_download is None all job files will be saved as a .zip archive in the output_dir.

Returns

list[Path]

A list of paths to the downloaded files.

API method
1
2
3
4
5
6
Historical.batch.download_async(
    job_id: str,
    output_dir: PathLike[str] | str | None = None,
    filename_to_download: str | None = None,
    keep_zip: bool = False,
) -> Awaitable[list[Path]]
Info

This method is a coroutine and must be used with an await expression.

Example usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import asyncio
import databento as db

client = db.Historical("$YOUR_API_KEY")

# Download all files for the batch job
coro = client.batch.download_async(
    job_id="GLBX-20220610-5DEFXVTMSM",
    output_dir="my_data/",
)
asyncio.run(coro)

# Alternatively, you can download a specific file
coro = client.batch.download_async(
    job_id="GLBX-20220610-5DEFXVTMSM",
    output_dir="my_data/",
    filename_to_download="metadata.json",
)
asyncio.run(coro)