Skip to main content

Python library for the https://api-sports.io/ API

Project description

PyAPISports

PyPI version PyPI downloads License Tests Codecov

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


Download files

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

Source Distribution

pyapisports-0.2.3.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyapisports-0.2.3-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file pyapisports-0.2.3.tar.gz.

File metadata

  • Download URL: pyapisports-0.2.3.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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

Hashes for pyapisports-0.2.3.tar.gz
Algorithm Hash digest
SHA256 3ef0de5f4026c57eca88e558f8ac3caaffa1466fbca200f7b17466c6435fbf7c
MD5 b327196805e62e1d5d7596f06ca83c96
BLAKE2b-256 bbcc6e21f21bd0ee727ee42480859e0eb5efdb949d952d6e2165daea5870e673

See more details on using hashes here.

File details

Details for the file pyapisports-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pyapisports-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 39.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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

Hashes for pyapisports-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 31d25e2aa8e0eb06902b6ee3ebac593349f757055bdfc1a76d4d481ead1fe455
MD5 a183cb247633174bddc79e13b01db5d6
BLAKE2b-256 e1e7cc3ad73b54c58f05360067f9b9eb4261a29191499fbb079dbd639e6b5630

See more details on using hashes here.

Supported by

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