Python library for the https://api-sports.io/ API
Project description
PyAPISports
A modern Python client for the API-Sports APIs.
This SDK provides a simple, typed interface to interact with API-Sports endpoints such as Football, Basketball, and more.
Features
- Simple and Pythonic API
- Automatic authentication
- Context-managed client
- Structured response objects
- JSON serialization support
- Easy access to request usage and subscription information
Installation
uv add pyapisports
Quick Start
from api_sports import ApiSportsClient
with ApiSportsClient(api_key="YOUR_API_KEY") as client:
status = client.football.get_status()
print(status.account.email)
print(status.subscription.plan)
print(status.subscription.active)
print(status.subscription.end)
print(status.requests.remaining)
print(status.requests.usage_percent)
print(status.to_json(indent=2))
Authentication
You need an API key from API-Sports.
Create a client using your API key:
client = ApiSportsClient(api_key="YOUR_API_KEY")
The client can also be used as a context manager:
with ApiSportsClient(api_key="YOUR_API_KEY") as client:
...
This ensures proper session handling and connection cleanup.
Example: Account Status
Retrieve information about your account, subscription, and request usage.
status = client.football.get_status()
Example fields available:
status.account.email
status.subscription.plan
status.subscription.active
status.subscription.end
status.requests.remaining
status.requests.usage_percent
Convert the response to JSON:
status.to_json(indent=2)
Response Objects
Responses are returned as structured Python objects rather than raw dictionaries.
Example:
status.subscription.plan
instead of:
status["subscription"]["plan"]
Benefits:
- IDE autocomplete
- Type safety
- Cleaner code
Error Handling
Example:
from api_sports import ApiSportsError
try:
with ApiSportsClient(api_key="YOUR_API_KEY") as client:
status = client.football.get_status()
except ApiSportsError as e:
print(e)
Supported APIs
Currently supported:
- Football
Planned support:
- Basketball
- Baseball
- Hockey
- Handball
Development
Clone the repository:
git clone https://github.com/codeshard/pyapisports.git
cd pyapisports
Install dependencies:
uv sync --group dev
Run tests:
uv run pytest --cov --cov-branch
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 pyapisports-0.1.0.tar.gz.
File metadata
- Download URL: pyapisports-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
999bbb1fef32d6d515c7506b4453dd9cc595d1f9bffd8fb6da1411a62cb5ead0
|
|
| MD5 |
af3c80c3339a196c32ba7fd0f24aa843
|
|
| BLAKE2b-256 |
79aeaf89c2f92dbe8cf97a331007d391ee3d288a5a01c4482be8a5c342ab2b40
|
File details
Details for the file pyapisports-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyapisports-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c2a15b2868dd126c354fcfdfb5e55b0f37051c229a79d0f6975a6825fcf7aae
|
|
| MD5 |
36f60f8d461dbdb9ededd91654d5ce9b
|
|
| BLAKE2b-256 |
57c01fdcd9c3dfbc15032786422417ddb2c1ff00002f934ffa043c88654128ce
|