-
-
Notifications
You must be signed in to change notification settings - Fork 98
Home
Install from PyPI using pip:
pip install MLB-StatsAPI
or python -m pip install MLB-StatsAPI
Upgrade using pip:
pip install --upgrade MLB-StatsAPI
or python -m pip install --upgrade MLB-StatsAPI
First, import the package:
import statsapi
Then call the applicable function, such as schedule
:
sched = statsapi.schedule(start_date='07/01/2018',end_date='07/31/2018',team=143,opponent=121)
The MLB-StatsAPI module utilizes Python's standard Logging module, with the logger name statsapi
. Set the appropriate log level and attach a log handler to the statsapi
logger in order to see the logs. For example:
import logging
logger = logging.getLogger('statsapi')
logger.setLevel(logging.DEBUG)
rootLogger = logging.getLogger()
rootLogger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
formatter = logging.Formatter("%(asctime)s - %(levelname)8s - %(name)s(%(thread)s) - %(message)s")
ch.setFormatter(formatter)
rootLogger.addHandler(ch)
Note: This information is provided for reference only, without warranty or guarantee, and is not official documentation provided by MLB. 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.