Source: https://databento.com/docs/api-historical/batch/batch-download



### Historical.batch.download

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]($PLATFORM_HOSTNAME/portal/download-center).

#### API method

```python
Historical.batch.download(
    job_id: str,
    output_dir: PathLike[str] | str | None = None,
    filename_to_download: str | None = None,
    keep_zip: bool = False,
) -> list[Path]
```

#### 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.

#### Example usage

```python
import databento as db

client = db.Historical("$YOUR_API_KEY")

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

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