Skip to content

dmsierra11/MLB-StatsAPI

 
 

Repository files navigation

MLB-StatsAPI

A Python wrapper for the MLB Stats API that provides easy access to baseball statistics, game data, and more.

Installation

pip install MLB-StatsAPI

Quick Start

import statsapi

# Get today's games
games = statsapi.schedule()

# Get box score for a specific game
boxscore = statsapi.boxscore(718757)

# Get player statistics
player_stats = statsapi.player_stats(592450)

# Get current standings
standings = statsapi.standings()

Features

  • Game schedules and results
  • Box scores and game details
  • Player statistics and information
  • Team standings and leaders
  • League leaders and rankings
  • Team rosters
  • And much more!

Common Use Cases

Get Game Schedule

# Get games for a specific date
games = statsapi.schedule(date='2024-03-28')

# Get games for a date range
games = statsapi.schedule(start_date='2024-03-28', end_date='2024-03-30')

# Get games for a specific team
games = statsapi.schedule(team='141')  # 141 is the team ID for the Toronto Blue Jays

Look Up Players or Teams

# Look up a player
player = statsapi.lookup_player('Mike Trout')

# Look up a team
team = statsapi.lookup_team('Blue Jays')

Get Statistics

# Get team leaders
leaders = statsapi.team_leaders(141, ['homeRuns', 'rbi', 'avg'])

# Get league leaders
leaders = statsapi.league_leaders(['homeRuns', 'rbi', 'avg'])

Documentation

For detailed documentation and API reference, visit our Wiki.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

Found a bug or have a feature request? Please open an issue.

Copyright Notice

This package and its author are not affiliated with MLB or any MLB team. This API wrapper interfaces with MLB's Stats API. Use of MLB data is subject to the notice posted at http://gdx.mlb.com/components/copyright.txt.

License

This project is licensed under the terms of the license included in the repository.

About

Python wrapper for MLB Stats API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%