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.1.tar.gz (22.7 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.1-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyapisports-0.2.1.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","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.1.tar.gz
Algorithm Hash digest
SHA256 c1db96fa79f5bff1ab194c088d10f5036d7141f2ac408277ff5746eb9278b24f
MD5 67c63e69f29cf3b8e48ec2631bab6cee
BLAKE2b-256 890b732bebc03c2dd7b8ed4567614f0cb2cfd5347ef0734aee2978e00b700692

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyapisports-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b88db9765a68cadee908485b00904afb5619004145d824c000c364f0c485957
MD5 e2b10b2519d1fce2b416b96418e9321d
BLAKE2b-256 5179b27af861684382174928f6028b2f22ed360aadfadaf07cfe71511b085865

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