Skip to main content

Actions Status PyPI Downloads

nbapy - stats.nba.com API for python

Summary

A python facing API for stats.nba.com

Warning stats.nba.com is notorious for being extremely unreliable. Please report any issues you find.

Usage

All data is returned as a pandas dataframe (check out the starter docs if you're new to pandas). For example:

from nbapy import game
import pandas as pd

game_id = '0021900017'  # taken from 'https://stats.nba.com/game/0021900017/'
stats = pd.DataFrame(game.BoxScore(game_id).players_stats())

If you want to cache results so you don't have to reach the api every time, you can use requests-cache

from nbapy import game
import pandas as pd
import requests_cache

requests_cache.install_cache('nbapy_cache')

game_id = '0021900017'
stats = pd.DataFrame(game.BoxScore(game_id).players_stats())

Documentation

An ongoing process, but check out the jupyter notebook docs, or feel free to poke around the codebase.

Installation

To install from pypi:

$ python -m pip install nbapy

Else:

  • Download from source (git clone, zipped package)
  • Run from the root directory:
$ python -m pip install .

Contributing

1. Fork the repository and create a feature/bug fix branch

2. Install development requirements

$ python -m pip install -e . ".[dev]"

3. Hack away

Coding conventions

Optional (but recommended)

nbapy has a pre-commit file that you can install to automatically enforce these conventions prior to committing via a git hook.

To install: $ pre-commit install

You can also use $ pre-commit run -a to run the checks manually.

For commit messages, I recommend using commtizen. It is automatically installed in the dev dependencies, so to commit, you just run cz c and follow the prompts.

4. Create some tests

5. Make sure everything looks good

$ pytest --cov*

$ pre-commit run -a (if you didn't install the pre-commit git hook)

* note the first time you run this, it may take a few minutes. However, the requests will cache, and subsequent runs should be much faster.

6. Submit a pull request

Other ways to contribute involve submitting any issues or adding some documentation!

To-Do

  • Finish Jupyter Notebook documentation

Authors

This is orginally based off of https://github.com/seemethere/nba_py so a lot of the work was done by those guys. My goal with this project is to clean up the code, add some proper documentation, and keep it up to date.

Release files for nbapy 1.1.8

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

Source distribution (sdist)

Source distribution for nbapy 1.1.8
File Size Uploaded
nbapy-1.1.8.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nbapy 1.1.8
File Interpreter ABI Platform
nbapy-1.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 41.1 kB

Release files / nbapy-1.1.8.tar.gz

Download URL nbapy-1.1.8.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cb8efb303707e5b8673ceb386b7098c0f5ca2271f3fb39049d1a116bdfcf6b7b
BLAKE2b-256 checksum
How to use checksums
b7392c8699f4aeb3ba4bc3cf72eff3115539e510d49b4ecb6ce26630d4f4ecee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Release files / nbapy-1.1.8-py3-none-any.whl

Download URL nbapy-1.1.8-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ecad7ea035f519b3e65e7fb59ac6da58507cec939d908059e0e0185c5f2dc67e
BLAKE2b-256 checksum
How to use checksums
d26a61d10dabc13fa319a2c5c37f786a21387de35c351c35254da2523272f57c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Release history Release notifications | RSS feed

This release

1.1.8 This release

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.0

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.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