Skip to main content

A python pacakge for getting baseball stats

Project description

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.

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

statcast_search

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"
)

minor_statcast_search

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"
)

mlbam_id_search

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)

fangraphs_search

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baseball_stats_python-0.3.0.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

baseball_stats_python-0.3.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file baseball_stats_python-0.3.0.tar.gz.

File metadata

  • Download URL: baseball_stats_python-0.3.0.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for baseball_stats_python-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3b93fc6bfee0f726dca794471a3607eb3991855e1b3ee052f8ee519ebc6dc495
MD5 1e9090c7701c7a60310acf09ea164117
BLAKE2b-256 dffd5ea6c8613c501a7a69be0594f5151197feebfa0c7d461c7866c0eae6ed80

See more details on using hashes here.

Provenance

The following attestation bundles were made for baseball_stats_python-0.3.0.tar.gz:

Publisher: publish.yml on ss77995ss/baseball-stats-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file baseball_stats_python-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for baseball_stats_python-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 397b7487e91e0f09aa517ae69e60679834f7b9439a80e51a8d1236f671ecb08f
MD5 063fb4a4475fedfbadab1184e53a5847
BLAKE2b-256 d2ffd915b146e4085d86470dc8697b42fbeb10919eec1d6bde7fde9e39875500

See more details on using hashes here.

Provenance

The following attestation bundles were made for baseball_stats_python-0.3.0-py3-none-any.whl:

Publisher: publish.yml on ss77995ss/baseball-stats-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page