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.2.tar.gz (24.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.2-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyapisports-0.2.2.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.2.tar.gz
Algorithm Hash digest
SHA256 7fb672d1e4136f50dda72c95ad931bde0f0f8cd51b749fe9d6ae2e671b226727
MD5 4c9c698ecf6f1c8136f0660ad50b3fbc
BLAKE2b-256 fc3da99fec5e12c0c7b88c34570621dd0b0858ebe9feb0fa59ef5c5d18e70e16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyapisports-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4cf797267abfa918e19a8a19265fd488b2177d2681d0f96e67bad69288356123
MD5 4cfb8d2b02b1011fb545ad150dfb7876
BLAKE2b-256 0f020a60122e65251e275d3f38fdfb54f3c508b5052f98305b4822a4a2c0aced

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