Skip to main content

A lightweight, dynamic Python client to pull NBA data from stats.nba.com.

Project description

A lightweight (6 KB), dynamic Python client to pull NBA data from [stats.nba.com](https://stats.nba.com/).

## Overview

This client utilizes error messages from the stats.nba.com API to:

  • check whether parameter passed is valid

  • check whether endpoint is valid or possibly deprecated

  • return list of parameters for endpoint

  • return list of possible values for any parameters and whether required for endpoint

  • automatically pass required parameters with default value if not given

It is possible to build a documentation of the API given possible endpoints with this client.

Inspired by [nba_py](https://github.com/seemethere/nba_py).

## Installation

# stable version
pip install dlo

# latest version
git clone https://github.com/avkondepudi/dlo.git
cd ./dlo
pip install .

## Dependencies

## Usage

A list of endpoints can be found [here](https://github.com/seemethere/nba_py/wiki/Completed-Work-Log) and [here](https://any-api.com/nba_com/nba_com/docs/API_Description). IDs (PlayerID, GameID, etc.) can be found on [stats.nba.com](https://stats.nba.com/).

>>> from dlo import Data                            # import module
>>> LOCAL = {                                       # set local parameters
... "PlayerID": 1626156,
... "Season": "2018-19",
... "SeasonType": "Regular Season"
... }
>>> d = Data(**LOCAL)                               # create instance of Data class with local parameters
>>> d.local = LOCAL                                 # another way to pass local parameters (recommended; deletes previous local parameters)
>>> d.local                                         # returns local parameters passed
{"PlayerID": 1626156, "Season": "2018-19", "SeasonType": "Regular Season"}
>>> d.endpoint = "playergamelog"                    # set endpoint
>>> d.endpoint                                      # returns current endpoint
"playergamelog"
>>> d.getEndpointParams()                           # returns list of parameters for current endpoint
['PlayerID', 'Season', 'SeasonType']
>>> d.getParamInfo("SeasonType")                    # returns list of values for parameter and whether required
{'regex': '^(Regular Season)|(Pre Season)|(Playoffs)|(All-Star)|(All Star)$', 'values': ['Regular Season', 'Pre Season', 'Playoffs', 'All-Star', 'All Star'], 'required': True}
>>> d.getParam("Season")                            # returns parameter value if passed
"2018-19"
>>> d.removeParam("Season")                         # value for Season (2018-19) removed
>>> d.setParam("Season", "2018-19")                 # two ways to set/add parameters
>>> d.Season = "2018-19"
>>> data = d.getData()                              # returns data (game log of D'Angelo Russell for the 2018-19 Regular Season)
>>> data_in_pandas_format = d.getData(pandify=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dlo-0.2.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

dlo-0.2.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file dlo-0.2.0.tar.gz.

File metadata

  • Download URL: dlo-0.2.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.3

File hashes

Hashes for dlo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4cc023725dad47c7919d1926839947d4618ae557c8ccdbf1aa41336f25d86ec2
MD5 8e96383306e9dcdc00438e889b852090
BLAKE2b-256 e9efce891583a3cc30cd33a8d9b81e42c4b97a86ee23ab5dd643e8aea4d46677

See more details on using hashes here.

File details

Details for the file dlo-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dlo-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.3

File hashes

Hashes for dlo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5bc48c4c4944d9bf65cfc3949ac1400ce578a87572cf09c5466167451eb08e2b
MD5 df9ea8bf2ee15412ee9a1459d7814803
BLAKE2b-256 6534d26a6345956d3bb038638b5e416544b42cfa0be70e5c396ebb9d46a4c7a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page