Skip to main content

xmlstats-py

Build Status

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

Tested against Python 2.7, 3.2-3.6

Usage

Instantiate an XmlStats object using a valid access token and user agent, obtained from the xmlstats API.

stats = Xmlstats(access_token=MY_ACCESS_TOKEN, user_agent=MY_USER_AGENT)

This object exposes a number of methods (one for each API endpoint) that return a NamedTuple representation of the data provided by the API. The JSON response is processed with json.loads, and a custom object_hook is used to convert JSON objects into NamedTuples when they are encountered. This means fields can be accessed using dot notation.

Methods

Each method exposed by the Xmlstats class aims to mirror an the endpoint provided by the API. See the API documentation for a complete explanation of parameters and results.

API Endpoint

Class Method

Events

events

Roster

roster

Standings

standings

Teams

teams

Team Schedule/Results

team_results

NBA Box Score

nba_box_score

NBA Draft

nba_draft

NBA Daily Leaders

nba_daily_leaders

NBA Team Stats

nba_team_stats

MLB Box Score

mlb_box_score

MLB Wild Card Standings

mlb_wild_card_standings

Examples

Get Boxscores for a given date - yyyymmdd

stats = Xmlstats(access_token=MY_ACCESS_TOKEN, user_agent=MY_USER_AGENT)
events = stats.events(date="20141028", sport="nba")  # returns NamedTuple "Events" which mirrors data structure explained in API documentation, containing all NBA events on given date
event_ids = [event.event_id for event in events.event]
boxscores = [
        stats.nba_box_score(eid) for eid in event_ids
]

Changelog

1.0.1 (2017-08-09)

  • Fixed bugs in multiple NBA and MLB specific methods related to added parameters for method requests.

1.0.0 (2017-03-17)

  • Complete overhaul of the way data is returned and represented when using this library. Data is now returned as NamedTuples, rather than as either simple dictionaries/lists or “objectified” data as in previous versions.

  • Methods were reimplimented to match the endpoints of the xmlstats API. Each method exposed by the XmlStats class corresponds to a single endpoint provided by the API, and accepts the same arguments and parameters. This means users of this library can essentially refer to the already existing xmlstats API documentation.

0.1.5 (2015-11-03)

Fixes:

  • Fixed http_get bug that prevented including paramaters in the next request after a 429 response code from xlmstats server.

0.1.4 (2015-11-02)

Fixes:

  • Fixed format_result bug that prevented higher level API functions from working.

Testing:

  • Added some basic tests, with Travis CI integration

Documentation:

  • Added Travis CI embedded status image to READMEg

0.1.3 (2015-11-02)

Fixes:

  • Fixed bugs in http_get handling of 429 response from xmlstats API server. http_get now waits for the amount of time specified by server 429 response before continuing to make requests.

Metadata

Release files for Xmlstats-py 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Xmlstats-py 1.0.1
File Size Uploaded
Xmlstats-py-1.0.1.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Xmlstats-py 1.0.1
File Interpreter ABI Platform
Xmlstats_py-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 17.1 kB

Release files / Xmlstats-py-1.0.1.tar.gz

Download URL Xmlstats-py-1.0.1.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a4a5e3e7406e100dff07f68971e8f70766f3a2d47d5666d26470fbe2e3928020
BLAKE2b-256 checksum
How to use checksums
0c7b75c6db7c45aa1259d2137e082a35f80c86f7e759c73bf223b5be423d0aa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / Xmlstats_py-1.0.1-py2.py3-none-any.whl

Download URL Xmlstats_py-1.0.1-py2.py3-none-any.whl
Size 7.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8a26ecdcbb60ead25364fe78cc17baed4564114268f52d0f74cb093ebf577e9c
BLAKE2b-256 checksum
How to use checksums
87cf3f486aaedeb6467863c86520723d783b217190b8d80ec0103ecf770364ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

1 release file

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.0.2

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page