Python SDK for the BALLDONTLIE API
Project description
BALLDONTLIE API
Official Python SDK for the BALLDONTLIE API. Access NBA, NFL, and MLB statistics and data. Check out the official website here.
Installation
# Install the latest version
pip install balldontlie
# Install a specific version
pip install balldontlie==0.1.0
Usage
from balldontlie import BalldontlieAPI
api = BalldontlieAPI(api_key="your-api-key")
# NBA (see documentation for full list of methods)
api.nba.teams.list()
# MLB
api.mlb.teams.list()
# NFL
api.nfl.teams.list()
API Reference
Check out the full API documentation: NBA NFL MLB
Error Handling
from balldontlie import BalldontlieAPI
from balldontlie.exceptions import (
AuthenticationError,
RateLimitError,
ValidationError,
NotFoundError,
ServerError,
BallDontLieException
)
client = BalldontlieAPI(api_key="your_key")
try:
teams = client.nba.teams.list()
except AuthenticationError as e:
print(f"Invalid API key. Status: {e.status_code}, Details: {e.response_data}")
except RateLimitError as e:
print(f"Rate limit exceeded. Status: {e.status_code}, Details: {e.response_data}")
except ValidationError as e:
print(f"Invalid request parameters. Status: {e.status_code}, Details: {e.response_data}")
except NotFoundError as e:
print(f"Resource not found. Status: {e.status_code}, Details: {e.response_data}")
except ServerError as e:
print(f"API server error. Status: {e.status_code}, Details: {e.response_data}")
except BallDontLieException as e:
print(f"General API error. Status: {e.status_code}, Details: {e.response_data}")
except Exception as e:
print(f"Unexpected error: {str(e)}")
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
balldontlie-0.1.6.tar.gz
(10.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file balldontlie-0.1.6.tar.gz.
File metadata
- Download URL: balldontlie-0.1.6.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
739ea4ba6e245b7a0289ff962ceb9124db4de26916e9ca7a9c37ad8606c1e522
|
|
| MD5 |
419de7c80952163ff439b92415eb35c0
|
|
| BLAKE2b-256 |
4bdf2de2cb383b7e25d086ea6226b922dd2baf66cc918b81f81606681ca03652
|
File details
Details for the file balldontlie-0.1.6-py3-none-any.whl.
File metadata
- Download URL: balldontlie-0.1.6-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3baa021bd6346fe129f674a5fedd9e5e2bc0a1dcfd1b3a3291934068959e27a2
|
|
| MD5 |
3da3cb090be5f75c69176a2b63308e60
|
|
| BLAKE2b-256 |
9d35aba11fff14a5dcad529ee213e34ac11ba6dcc4cc99eb2d5cee2ac4e7023c
|