Skip to main content

baseball-stats-python

A package that get baseball data from

Overview

Inspired by pybaseball. This pacakge is mainly focused on getting pitch-by-pitch data from Baseball Data Website like Baseball Savant and provide a easy way to get data for analytics. All credit belong to the data source's organziations.

Installation

Install the package via pip

pip install baseball-stats-python

Download the main branch by git clone

git clone https://github.com/ss77995ss/baseball-stats-python.git

pip with repository url

pip install git+https://github.com/ss77995ss/baseball-stats-python.git

Usage

Get pitch-by-pitch data from Baseball Savant with their search parameters. See documentation here.

from baseball_stats_python import statcast_search

# Get Dodgers's pitcher data in July 2024
statcast_search(
    season="2024",
    team='LAD',
    player_type='pitcher',
    month="7"
)

Get pitch-by-pitch data from Baseball Savant's Minor League Statcast Search with their search parameters. See documentation here.

from baseball_stats_python import minor_statcast_search

# Get all pitch data in Triple-A in July 2024
minor_statcast_search(
    season="2024",
    level="AAA",
    month="7"
)

Search for MLBAM ID(s) by player name. Can be used to get player ID for statcast_batter_search and statcast_pitcher_search. See documentation here.

from baseball_stats_python import (
    mlbam_id_search,
    statcast_batter_search,
    statcast_pitcher_search,
)

# Search for MLBAM ID(s) by player name
molina_mlbam_id = mlbam_id_search('Yadier Molina').iloc[0]['id']

# Get Yadier Molina's Statcast data
statcast_batter_search(batters_lookup=mlbam_id)

darvish_mlbam_id = mlbam_id_search('Yu Darvish').iloc[0]['id']

# Get Yu Darvish's Statcast data
statcast_pitcher_search(pitchers_lookup=darvish_mlbam_id)

Get batting or pitching leaderboard data from Fangraphs' major-league leaders API. fg_batting and fg_pitching are convenience wrappers for single-season queries. See documentation here.

from baseball_stats_python import fangraphs_search, fg_batting, fg_pitching

# Get the 2026 qualified batting leaderboard
fg_batting(season=2026)

# Get the 2026 qualified pitching leaderboard
fg_pitching(season=2026)

# Use fangraphs_search directly for multi-season or finer-grained queries
fangraphs_search(
    stats="bat",
    season1=2024,
    season=2026
)

Contributing

Welcome to open issues or pull requests to contribute to this project. Please read CONTRIBUTING.md for more details.

License

MIT License

Metadata

Release files for baseball-stats-python 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for baseball-stats-python 0.4.0
File Size Uploaded Provenance Actions
baseball_stats_python-0.4.0.tar.gz 22.0 kB With provenance Details for baseball_stats_python-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for baseball-stats-python 0.4.0
File Interpreter ABI Platform Actions
baseball_stats_python-0.4.0-py3-none-any.whl Python 3 none any Details for baseball_stats_python-0.4.0-py3-none-any.whl

Total release size: 43.5 kB

Release files / baseball_stats_python-0.4.0.tar.gz

Download URL baseball_stats_python-0.4.0.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b0a3a6a162dee754554fd3db0d2c78498511064512673115991374ed9e5a10e3
BLAKE2b-256 checksum
How to use checksums
cb5b94adf2e0c6efc7301f22715dccf778a791747321ffbbca70c5b5a2d3b767
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / baseball_stats_python-0.4.0-py3-none-any.whl

Download URL baseball_stats_python-0.4.0-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a76ae75bf6378db1a3d360013741e1d24fea66cd888863aa82407176cee3f12d
BLAKE2b-256 checksum
How to use checksums
ac0690667b2a3c2e7e47cc016f7187a29b198c51476c4c1da2a317c9f170eb96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for baseball-stats-python 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for baseball_stats_python-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page