Python SDK for Soccer Football Info API via RapidAPI
Project description
Soccer Info - Python SDK for Soccer Football Info API
A Python SDK for accessing the Soccer Football Info API via RapidAPI. Provides both synchronous and asynchronous clients with typed request builders and Pydantic response models for soccer championship data.
Scope and Limitations
This SDK currently implements the Championship API endpoints from the Soccer Football Info API:
- Championships List - Browse and filter available soccer championships by country
- Championship Details - Get detailed championship data including seasons, groups, and team standings
The Soccer Football Info API offers 29 total endpoints covering matches, live scores, teams, players, managers, referees, stadiums, and more. This SDK currently focuses on championship data. For the complete API catalog, visit the Soccer Football Info API documentation on RapidAPI.
Future versions may expand to include additional endpoints based on community needs.
Quick Start
Installation
pip install soccer-info
Requirements
- Python 3.13 or higher
- RapidAPI account (free tier available)
- RapidAPI key for Soccer Football Info API
Get your RapidAPI key:
- Sign up at RapidAPI
- Subscribe to Soccer Football Info API
- Find your API key in the API dashboard
Basic Usage
import soccer_info
# Create client with default settings (uses RAPIDAPI_SOCCER_INFO_KEY env var)
client = soccer_info.quick_client()
# Get list of championships
championships = client.championships.get_list()
print(f"Found {len(championships.result)} championships")
# Get detailed championship data
championship_detail = client.championships.get_by_id("5778d8e65b65c7f9")
print(f"Championship: {championship_detail.first_result.name}")
print(f"Country: {championship_detail.first_result.country}")
API Key Setup
The SDK provides multiple flexible ways to configure your RapidAPI key:
Quick Start (Default)
Set the RAPIDAPI_SOCCER_INFO_KEY environment variable and use quick_client():
import soccer_info
client = soccer_info.quick_client()
championships = client.championships.get_list()
All Configuration Options
1. Environment Variable (Default)
import soccer_info
# Uses RAPIDAPI_SOCCER_INFO_KEY environment variable
client = soccer_info.quick_client()
2. Direct API Key
from soccer_info.settings import SettingsBuilder
import soccer_info
settings = SettingsBuilder().with_api_key(key="your-rapidapi-key-here").build()
client = soccer_info.quick_client(settings)
3. Custom Environment Variable
from soccer_info.settings import SettingsBuilder
import soccer_info
settings = SettingsBuilder().with_api_key(environment="MY_CUSTOM_API_KEY").build()
client = soccer_info.quick_client(settings)
4. Provider Function
from soccer_info.settings import SettingsBuilder
import soccer_info
def get_api_key():
# Load from secure vault, file, or other source
return "your-api-key"
settings = SettingsBuilder().with_api_key(key_provider=get_api_key).build()
client = soccer_info.quick_client(settings)
Advanced Usage
Custom Client Configuration
from soccer_info.settings import SettingsBuilder
from soccer_info.client import HTTPXClient
# Build custom settings
settings = (
SettingsBuilder()
.with_api_key(key="your-api-key")
.with_base_url("https://soccer-football-info.p.rapidapi.com")
.with_host("soccer-football-info.p.rapidapi.com")
.build()
)
# Create client with custom settings
client = HTTPXClient(settings)
championships = client.championships.get_list()
Context Manager for Resource Management
import soccer_info
# Automatically closes HTTP client when done
with soccer_info.quick_client() as client:
championships = client.championships.get_list()
for champ in championships.result:
detail = client.championships.get_by_id(champ.id)
print(f"{detail.first_result.name}")
Asynchronous Client
The async client includes built-in request throttling to respect API rate limits. See settings.py for default configuration values.
import asyncio
import soccer_info
async def main():
# Create async client with context manager
async with soccer_info.quick_async_client() as client:
# Fetch data asynchronously
championships = await client.championships.get_list()
# Fetch multiple championships concurrently
# Throttling is automatically handled
tasks = [
client.championships.get_by_id(champ.id)
for champ in championships.result[:5]
]
results = await asyncio.gather(*tasks)
for detail in results:
print(f"{detail.first_result.name}")
asyncio.run(main())
Rate Limit Monitoring
import soccer_info
client = soccer_info.quick_client()
response = client.championships.get_list()
# Access rate limit information from response headers
headers = response.response_headers
print(f"Rate limit: {headers.rate_limit_remaining}/{headers.rate_limit_limit}")
print(f"Resets in: {headers.hours_to_reset} hours")
print(f"Resets in: {headers.rate_limit_reset} seconds")
Saving Responses to JSON
from pathlib import Path
import soccer_info
client = soccer_info.quick_client()
response = client.championships.get_list()
# Save full response to JSON file
response.save_pretty_json(Path("championships.json"))
# Save individual championship detail
detail = client.championships.get_by_id("5778d8e65b65c7f9")
detail.save_pretty_json(Path("championship_detail.json"))
Setting Default Language
from soccer_info.settings import SettingsBuilder
from soccer_info.client import HTTPXClient
settings = SettingsBuilder().with_api_key().build()
# Set default language for all requests
client = HTTPXClient(settings, default_language="es_ES")
# Uses Spanish by default
championships = client.championships.get_list()
# Override for specific request
championships_german = client.championships.get_list(language="de_DE")
API Reference
Client Creation Functions
quick_client()- Create synchronous client with default settingsquick_async_client()- Create asynchronous client with default settings
Championship Methods
get_list(page=None, country=None, language=None)- Retrieve paginated list of championships with optional country filterget_by_id(championship_id, language=None)- Get detailed championship data including seasons, groups, and standings
Response Models
ChampionshipListResponse- Paginated list of championship itemsChampionshipViewResponse- Detailed championship with seasons and standingsChampionshipListItem- Basic championship information (id, name, has_image)ChampionshipDetail- Full championship data with seasonsSeason- Season information with date range and groupsGroup- League group with standings tableTableEntry- Team standing with position, points, wins, draws, losses, goalsTeam- Team reference (id, name)
Response Properties
All responses include:
status- HTTP status codeerrors- List of error messagesresult- List of result itemspagination- Pagination informationresponse_headers- HTTP headers including rate limit infois_success- Boolean property indicating successful responsefirst_result- Convenience property for first result itempagination_info- Convenience property for pagination data
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
We welcome contributions! Here's how you can help:
Getting Started
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/your-username/soccer-info.git cd soccer-info
- Set up development environment:
# Create virtual environment python -m venv .venv # Activate virtual environment # Windows: .venv\Scripts\activate # Linux/Mac: source .venv/bin/activate # Install in development mode with dev dependencies pip install -e . pip install -r requirements-dev.txt
Development Environment
The project includes:
python-dotenvfor managing environment variables during development- Example scripts in the
examples/directory demonstrating both sync and async usage - Type checking support with
py.typedmarker
Create a .env file in the project root for development:
RAPIDAPI_SOCCER_INFO_KEY=your-development-api-key
Project Structure
The SDK follows a clean architecture pattern:
soccer_info/
├── __init__.py # Public API exports and quick_client()
├── py.typed # PEP 561 type marker
├── client/ # Client implementations (sync/async)
├── requests_/ # Request components (headers, parameters)
├── responses/ # Response models (Pydantic)
└── settings/ # Configuration management
Code Style
- Follow PEP 8 guidelines
- Use type hints for all function signatures
- Document public APIs with docstrings
- Keep response models aligned with API structure
Code of Conduct
Be respectful and constructive in all interactions. This project follows standard open source community guidelines.
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 soccer_info-0.1.1.tar.gz.
File metadata
- Download URL: soccer_info-0.1.1.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
984d0b03fd5674128286315235fd62826fc0f2c9ccf091a54bc35c618d82f363
|
|
| MD5 |
8607d48aac65ddd5c5892f98c1467ebb
|
|
| BLAKE2b-256 |
02601a8818a9479a5369e85899d26a63d10d7de17d6b5bbde7854215ebb19a6f
|
Provenance
The following attestation bundles were made for soccer_info-0.1.1.tar.gz:
Publisher:
publish.yml on eliyahuA/soccer-info
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
soccer_info-0.1.1.tar.gz -
Subject digest:
984d0b03fd5674128286315235fd62826fc0f2c9ccf091a54bc35c618d82f363 - Sigstore transparency entry: 815181997
- Sigstore integration time:
-
Permalink:
eliyahuA/soccer-info@49cfd4d4876c846aa9e0a9fe94f628563fb7aab8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/eliyahuA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@49cfd4d4876c846aa9e0a9fe94f628563fb7aab8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file soccer_info-0.1.1-py3-none-any.whl.
File metadata
- Download URL: soccer_info-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c54f93802a96a0cfb27e6b50cdfef1de27dfa649d69e0ae11355c95870803189
|
|
| MD5 |
e6e1861cbc028d6019235d70a23820b0
|
|
| BLAKE2b-256 |
8aad10dc5549c14461c49c6ddc9bba51313ca64148a9dbeece34912865f7fc66
|
Provenance
The following attestation bundles were made for soccer_info-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on eliyahuA/soccer-info
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
soccer_info-0.1.1-py3-none-any.whl -
Subject digest:
c54f93802a96a0cfb27e6b50cdfef1de27dfa649d69e0ae11355c95870803189 - Sigstore transparency entry: 815182007
- Sigstore integration time:
-
Permalink:
eliyahuA/soccer-info@49cfd4d4876c846aa9e0a9fe94f628563fb7aab8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/eliyahuA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@49cfd4d4876c846aa9e0a9fe94f628563fb7aab8 -
Trigger Event:
release
-
Statement type: