panzarino/mlbgame


A Python API to retrieve and read MLB GameDay data

http://panz.io/mlbgame/

License: MIT

Language: Python

Keywords: api, baseball, mlb, mlb-gameday, python, python-api, sports, sports-stats


mlbgame

Build Status Code Climate Coverage Status

Join Slack

mlbgame is a Python API to retrieve and read MLB GameDay data. mlbgame works with real time data, getting information as games are being played.

mlbgame uses the same data that MLB GameDay uses, and therefore is updated as soon as something happens in a game.

mlbgame documentation

mlbgame on Github (Source Code)

If you have a question or need help, the quickest way to get a response is to file an issue on the Github issue tracker

mlbgame's submodules should not really be used other than as used by the main functions of the package (in __init__.py).

Use of mlbgame must follow the terms stated in the license and on mlb.com.

Installation

mlbgame is in the Python Package Index (PyPI). Installing with pip is recommended for all systems.

mlbgame can be installed by running:

pip install mlbgame

Alternatively, the latest release of mlbgame can be downloaded as a zip or tarball. If you do not install with pip, you must also install lxml as specified in setup.py.

If you want to help develop mlbgame, you must also install the dev dependencies, which can be done by running pip install -e .[dev] from within the directory.

Examples

Here is a quick teaser to find the scores of all home Mets games for the month of June, 2015:

from __future__ import print_function
import mlbgame

month = mlbgame.games(2015, 6, home='Mets')
games = mlbgame.combine_games(month)
for game in games:
    print(game)

And the output is:

Giants (5) at Mets (0)
Giants (8) at Mets (5)
Giants (4) at Mets (5)
Braves (3) at Mets (5)
Braves (5) at Mets (3)
Braves (8) at Mets (10)
Blue Jays (3) at Mets (4)
Blue Jays (2) at Mets (3)
Reds (1) at Mets (2)
Reds (1) at Mets (2)
Reds (1) at Mets (2)
Reds (2) at Mets (7)
Cubs (1) at Mets (0)

Maybe you want to know the pitchers for the Royals game on April 30th, 2015:

from __future__ import print_function
import mlbgame

day = mlbgame.day(2015, 4, 12, home='Royals', away='Royals')
game = day[0]
output = 'Winning pitcher: %s (%s) - Losing Pitcher: %s (%s)'
print(output % (game.w_pitcher, game.w_team, game.l_pitcher, game.l_team))

And the output is:

Winning pitcher: Y. Ventura (Royals) - Losing Pitcher: C. Wilson (Angels)

You can easily print a list of the Mets batters in the final game of the 2015 World Series:

from __future__ import print_function
import mlbgame

game = mlbgame.day(2015, 11, 1, home='Mets')[0]
stats = mlbgame.player_stats(game.game_id)
for player in stats.home_batting:
    print(player)

And the output is:

Curtis Granderson (RF)
David Wright (3B)
Daniel Murphy (2B)
Yoenis Cespedes (CF)
Juan Lagares (CF)
Lucas Duda (1B)
Travis d'Arnaud (C)
Michael Conforto (LF)
Wilmer Flores (SS)
Matt Harvey (P)
Jeurys Familia (P)
Kelly Johnson (PH)
Jonathon Niese (P)
Addison Reed (P)
Bartolo Colon (P)

Project Statistics

Sourcerank 9
Repository Size 2.51 MB
Stars 277
Forks 62
Watchers 35
Open issues 11
Dependencies 1
Contributors 11
Tags 25
Created
Last updated
Last pushed

Top Contributors See all

Zach Panzarino digitalSaint Robert Simione John Watterlond Christian Wyglendowski Brad Hurley Andrew Bowler Brian S Pertempto Disce Daniel Russo Greg Reda

Packages Referencing this Repo

mlbgame
An API to retrieve and read MLB GameDay data
Latest release 2.5.0 - Updated - 277 stars

Recent Tags See all

v2.5.0 April 16, 2018
v2.4.2 February 06, 2018
v2.4.1 January 17, 2018
v2.4.0 September 08, 2017
v2.3.3 May 13, 2017
v2.3.2 April 18, 2017
v2.3.1 November 22, 2016
v2.3.0 November 09, 2016
v2.2.1 July 30, 2016
v2.2.0 July 19, 2016
v2.1.0 July 05, 2016
v2.0.2 April 07, 2016
v2.0.1 April 01, 2016
v2.0.0 March 25, 2016
v1.0.3 February 05, 2016

Interesting Forks See all

CNXTEoE/mlbgame
A Python API to retrieve and read MLB GameDay XML data
Python - Updated - 1 stars
hungryducks/mlbgame
A Python API to retrieve and read MLB GameDay XML data
Python - Updated - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2018-04-16 16:34:29 UTC

Login to resync this repository