A python module for interacting with the xmlstats
API
This module aims to closely mirror the methods provided by the xmlstats API in terms of parameters and output structure.
Installing
pip install xmlstats-py
Usage
Xmlstats can return “objectified” data, in which nested JSON objects from the xmlstats API are accessible as attributes, or it can return data in native python objects, as if parsed with json.load().
stats = Xmlstats(access_token=MY_ACCESS_TOKEN, user_agent=MY_USER_AGENT, objectify=True)
# if objectify=False, data will be returned in native python objects
stats.objectify_off() # set objectify = False
stats.objectify_on() # set objectify = True
Methods
See the API documentation for a complete explanation of parameters and results. #####get_boxscore(sport, event_id) sport = “nba” or “mlb”
get_events(date, sport)
Date must be in YYYYmmdd format
get_teams(sport)
get_roster(sport, team_id, status=None)
status = “expanded” will return the 40-man roster for an MLB team, rather than 25-man roster
get_nba_team_stats(date, team_id=None)
get_team_results(team_id, season=None, since=None, until=None, order=None)
get_nba_draft_results(season=None, team_id=None)
get_nba_leaders(category, limit=None,qualified=None, season_type=None)
For list of category IDs, see here. Qualified parameter (default=True) determines whether players who meet NBA’s minimum qualifications will be returned, or all players.
get_standings(sport, date=None)
get_wildcard_standings(date)
Examples
Get Boxscores for a given date - yyyymmdd
stats = Xmlstats(access_token=MY_ACCESS_TOKEN, user_agent=MY_USER_AGENT)
events = stats.get_events(date=20141028, sport="nba") # returns event objects for all nba events on given date
event_ids = [event.event_id for event in events.event]
boxscores = []
for event_id in event_ids:
boxscores.append(stats.get_boxscore(sport="nba", event_id))
Note: As in the xmlstats API, the get_events() method returns an instance with 2 attributes: events_date is a date string; event is an array of event objects
Release files for Xmlstats-py 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Xmlstats-py-0.1.4.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Xmlstats_py-0.1.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / Xmlstats-py-0.1.4.tar.gz
| Download URL | Xmlstats-py-0.1.4.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aeb63384dd6be35b3b55db141007657abd1b859b3915ec5d3e46388c8753dd22
|
|
BLAKE2b-256 checksum How to use checksums |
7a1eec047cce9588888865a8b37016656810733a4b01d38ca04d30ef2356544f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Xmlstats_py-0.1.4-py2.py3-none-any.whl
| Download URL | Xmlstats_py-0.1.4-py2.py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
bd5330ca4e4920699aa6cd00e7dfa1583909928ba357a0e8ecb9fa01438b057f
|
|
BLAKE2b-256 checksum How to use checksums |
e4ae0657e3787ec2ff06877058ede97e797c0bb4103e4a59e1c5a08cce9867ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |