Python API Reference
This page contains the complete reference for retrosheetpy's Python module. All primary functions are directly accessible from the root namespace:
retrosheetpy.api
High-level user-facing API for retrosheetpy.
allstar
allstar(
year: int | Sequence[int],
backend: str = "arrow",
force: bool = False,
downloader: Downloader | None = None,
) -> Any
Downloads, parses, and returns All-Star Game play-by-play events.
Source code in src/retrosheetpy/api.py
bio
Downloads and returns the master player and personnel biographical database.
Source code in src/retrosheetpy/api.py
download
download(
years: int | Sequence[int] | None = None,
datasets: Sequence[str] | str = "all",
force: bool = False,
downloader: Downloader | None = None,
) -> dict[str, list[Path]]
Downloads specified Retrosheet archives to local cache without loading them into memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years | int | Sequence[int] | None | Year or sequence of years to download. Defaults to [2024] if not provided. | None |
datasets | Sequence[str] | str | Dataset or comma-separated list of datasets to download ('events', 'postseason', 'allstar', 'gamelogs', 'rosters', 'parks', 'schedules', 'bio', 'ejections', 'transactions', or 'all'). | 'all' |
force | bool | If True, re-downloads even if already cached. | False |
downloader | Downloader | None | Optional custom Downloader instance. | None |
Returns:
| Type | Description |
|---|---|
dict[str, list[Path]] | Dictionary mapping dataset name to list of extracted paths or file locations. |
Source code in src/retrosheetpy/api.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
ejections
ejections(
backend: str = "arrow",
force: bool = False,
downloader: Downloader | None = None,
) -> Any
Downloads and returns the official ejections database.
Source code in src/retrosheetpy/api.py
events
events(
year: int | Sequence[int],
backend: str = "arrow",
force: bool = False,
downloader: Downloader | None = None,
) -> Any
Downloads, parses, and returns play-by-play events as a strongly-typed DataFrame or Arrow Table.
Source code in src/retrosheetpy/api.py
game_logs
game_logs(
year: int | Sequence[int],
backend: str = "arrow",
force: bool = False,
downloader: Downloader | None = None,
) -> Any
Downloads, parses, and returns official game logs as a strongly-typed DataFrame or Arrow Table.
Source code in src/retrosheetpy/api.py
get_ddl
Returns the SQL DDL CREATE TABLE statement for a given dataset and dialect.
parks
Downloads and returns the official ballpark encyclopedia table.
Source code in src/retrosheetpy/api.py
postseason
postseason(
year: int | Sequence[int],
backend: str = "arrow",
force: bool = False,
downloader: Downloader | None = None,
) -> Any
Downloads, parses, and returns postseason play-by-play events.
Source code in src/retrosheetpy/api.py
rosters
rosters(
year: int | Sequence[int],
backend: str = "arrow",
force: bool = False,
downloader: Downloader | None = None,
) -> Any
Downloads event archives to parse and return team rosters as a strongly-typed table.
Source code in src/retrosheetpy/api.py
schedules
schedules(
year: int | Sequence[int],
backend: str = "arrow",
force: bool = False,
downloader: Downloader | None = None,
) -> Any
Downloads, parses, and returns official regular season game schedules.
Source code in src/retrosheetpy/api.py
to_dlt
to_dlt(
destination: str | Any,
years: int | Sequence[int] = 2024,
datasets: Sequence[str] = (
"events",
"gamelogs",
"rosters",
"parks",
),
pipeline_name: str = "retrosheet",
downloader: Downloader | None = None,
**dlt_kwargs: Any,
) -> Any
Runs a full dlt pipeline ingesting Retrosheet datasets into Postgres, Snowflake, BigQuery, etc.
Source code in src/retrosheetpy/api.py
to_duckdb
to_duckdb(
path: Path | str,
years: int | Sequence[int] = 2024,
datasets: Sequence[str] = (
"events",
"gamelogs",
"rosters",
"parks",
),
force: bool = False,
downloader: Downloader | None = None,
) -> None
Ingests selected Retrosheet datasets into a DuckDB database.
Source code in src/retrosheetpy/api.py
to_parquet
to_parquet(
path: Path | str,
dataset: str,
years: int | Sequence[int] = 2024,
force: bool = False,
downloader: Downloader | None = None,
) -> Path
Exports a specified dataset into a Parquet file.
Source code in src/retrosheetpy/api.py
transactions
transactions(
backend: str = "arrow",
force: bool = False,
downloader: Downloader | None = None,
) -> Any
Downloads and returns the official player transactions database.