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.0.tar.gz (22.5 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.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyapisports-0.2.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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.0.tar.gz
Algorithm Hash digest
SHA256 9db5886f948e2739cfd119e0f35e7968004b69e59e7383a6f977a12ee065a3cf
MD5 e0cdacbca33ffcc41b5dc2bda7599878
BLAKE2b-256 4f9754504afc421524274d5945f44cd4425a09974cb592848f85936734a5fbc4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyapisports-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a07febbc0a66993219e4641d81c4c2db5aa5e0e360cfdb1d0873b027d7e63b5
MD5 4dafc6a4e576820a28cd0b588ac63201
BLAKE2b-256 7c2c5b5df7c18a002dce1cb0d8901d5ca20acd052bd434c22f9609e4395fabcf

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