A Python client library for the Sumo API
Project description
PySumoAPI
A Python client library for the Sumo API, providing easy access to sumo wrestling data including rikishi information, statistics, shikona history, measurements, and rank history.
Features
- Asynchronous API client using
httpx - Strongly typed data models using
pydantic - Comprehensive error handling
- Command-line interface for quick data access
- Detailed examples demonstrating API usage
Installation
# Using pip
pip install pysumoapi
# Using uv (recommended)
uv pip install pysumoapi
Quick Start
import asyncio
from pysumoapi.client import SumoClient
async def main():
async with SumoClient() as client:
# Get rikishi information
rikishi = await client.get_rikishi(1511)
print(f"Name: {rikishi.shikona_en}")
# Get rikishi statistics
stats = await client.get_rikishi_stats(1511)
print(f"Total matches: {stats.total_matches}")
# Get shikona history
shikonas = await client.get_shikonas(rikishi_id=1511, sort_order="asc")
for shikona in shikonas:
print(f"Basho: {shikona.basho_id}, Shikona: {shikona.shikona_en}")
if __name__ == "__main__":
asyncio.run(main())
Command-Line Interface
PySumoAPI includes a command-line interface for quick data access:
# Get rikishi information
pysumoapi rikishi 1511
# Get rikishi statistics
pysumoapi stats 1511
# Get shikona history for a rikishi
pysumoapi shikona --rikishi-id 1511
# Get measurements history for a rikishi
pysumoapi measurements --rikishi-id 1511
# Get rank history for a rikishi
pysumoapi ranks --rikishi-id 1511
# Get all shikona changes for a specific basho
pysumoapi shikona --basho-id 202305
API Reference
SumoClient
The main client class for interacting with the Sumo API.
from pysumoapi.client import SumoClient
async with SumoClient() as client:
# Use the client here
Methods
get_rikishi(rikishi_id: str) -> Rikishi: Get information about a rikishiget_rikishi_stats(rikishi_id: str) -> RikishiStats: Get statistics for a rikishiget_rikishis(shikona_en: Optional[str] = None, heya: Optional[str] = None, sumodb_id: Optional[int] = None, nsk_id: Optional[int] = None, intai: Optional[bool] = None, measurements: bool = True, ranks: bool = True, shikonas: bool = True, limit: int = 10, skip: int = 0) -> RikishiList: Get a list of rikishi with optional filtersget_rikishi_matches(rikishi_id: int, basho_id: Optional[str] = None) -> RikishiMatchesResponse: Get all matches for a specific rikishiget_rikishi_opponent_matches(rikishi_id: int, opponent_id: int, basho_id: Optional[str] = None) -> RikishiOpponentMatchesResponse: Get all matches between two specific rikishiget_basho(basho_id: str) -> Basho: Get details for a specific basho tournamentget_banzuke(basho_id: str, division: str) -> Banzuke: Get banzuke details for a specific basho and divisionget_torikumi(basho_id: str, division: str, day: int) -> Torikumi: Get torikumi details for a specific basho, division, and dayget_kimarite(sort_field: Optional[str] = None, sort_order: Optional[str] = "asc", limit: Optional[int] = None, skip: Optional[int] = 0) -> KimariteResponse: Get statistics on kimarite usageget_kimarite_matches(kimarite: str, sort_order: Optional[str] = "asc", limit: Optional[int] = None, skip: Optional[int] = 0) -> KimariteMatchesResponse: Get matches where a specific kimarite was usedget_measurements(basho_id: Optional[str] = None, rikishi_id: Optional[int] = None, sort_order: Optional[str] = "desc") -> MeasurementsResponse: Get measurement changes by rikishi or bashoget_ranks(basho_id: Optional[str] = None, rikishi_id: Optional[int] = None, sort_order: Optional[str] = "desc") -> RanksResponse: Get rank changes by rikishi or bashoget_shikonas(basho_id: Optional[str] = None, rikishi_id: Optional[int] = None, sort_order: Optional[str] = "desc") -> ShikonasResponse: Get shikona changes by rikishi or basho
Data Models
Rikishi: Information about a rikishiRikishiList: List of rikishi with pagination informationRikishiStats: Statistics for a rikishiRikishiMatchesResponse: Response containing rikishi matchesRikishiOpponentMatchesResponse: Response containing matches between two rikishiBasho: Information about a basho tournamentBanzuke: Banzuke details for a divisionRikishiBanzuke: Individual rikishi entry in a banzukeTorikumi: Match schedule for a specific dayYushoWinner: Information about a yusho winnerMatch: Unified model for sumo matches across all endpointsKimariteResponse: Statistics about kimarite usageKimariteMatch: Information about a match where a specific kimarite was usedKimariteMatchesResponse: Response containing matches with a specific kimariteMeasurement: Physical measurements of a rikishiMeasurementsResponse: Response containing measurement recordsRank: Rank information for a rikishiRanksResponse: Response containing rank recordsShikona: Shikona (ring name) informationShikonasResponse: Response containing shikona recordsDivisionStats: Statistics broken down by divisionSansho: Special prize informationRikishiPrize: Information about a rikishi who won a prize
Examples
See the examples directory for more detailed examples:
- Shikona Example: Demonstrates retrieving and displaying shikona history
- Comprehensive Example: Shows how to use multiple endpoints together to create a comprehensive rikishi profile
Development
Setup
# Clone the repository
git clone https://github.com/colebrumley/pysumoapi.git
cd pysumoapi
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install development dependencies
uv pip install -e ".[dev]"
Using Make
This project includes a Makefile to automate common development tasks:
# Show available commands
make help
# Install the package in development mode
make install
# Install development dependencies
make dev
# Clean build artifacts and caches
make clean
# Run tests
make test
# Run linters
make lint
# Format code
make format
# Build the package
make build
# Publish to PyPI (requires PYPI_API_TOKEN environment variable)
make publish
# Build documentation (placeholder)
make docs
# Show current version
make version
# Bump version (major, minor, or patch)
make version-bump TYPE=patch
# Set version explicitly
make version-set VERSION=1.0.0
Version Management
The package includes a version management script to help with versioning:
# Show current version
python scripts/version.py show
# Bump version (major, minor, or patch)
python scripts/version.py bump --type patch
# Set version explicitly
python scripts/version.py set --version 1.0.0
The script automatically updates both pyproject.toml and CHANGELOG.md when changing versions.
Release Process
To create a new release:
-
Ensure you're on the
mainbranch and it's up to date:git checkout main git pull origin main
-
Run the release script:
# For a patch release (0.1.0 -> 0.1.1) make release TYPE=patch # For a minor release (0.1.0 -> 0.2.0) make release TYPE=minor # For a major release (0.1.0 -> 1.0.0) make release TYPE=major
The release script will:
- Run pre-release checks
- Bump the version
- Run tests
- Run linters
- Build the package
- Publish to PyPI (if PYPI_API_TOKEN is set)
- Create a git tag
-
Follow the prompts to:
- Commit the changes
- Push to GitHub
- Push the tag
You can skip certain steps using flags:
# Skip tests and linting
make release TYPE=patch --skip-tests --skip-lint
# Skip publishing to PyPI
make release TYPE=patch --skip-publish
# Skip creating a git tag
make release TYPE=patch --skip-tag
# Skip pre-release checks
make release TYPE=patch --skip-checks
Security
Please see our Security Policy for information about:
- Supported versions
- How to report vulnerabilities
- Security best practices
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
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 pysumoapi-0.1.4.tar.gz.
File metadata
- Download URL: pysumoapi-0.1.4.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d84c7a52cb617b9df01a63c4722ee4634990025f0e678c1c3fbb63ab1eac6d5
|
|
| MD5 |
113d4a65442c92e8a3d8555f8d5fbb27
|
|
| BLAKE2b-256 |
cb339af02280046d84015302e37c608d044cb0384d6ce19119cbca964873c5ed
|
File details
Details for the file pysumoapi-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pysumoapi-0.1.4-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce752eea7ae71dcb05524e5e8c8f1d929d41a00f9142987e317f8f72d6159be7
|
|
| MD5 |
0256c0c9a31ae92e0679f8976236f655
|
|
| BLAKE2b-256 |
f434beb24c1fd68cf1c2009a5c20bdb6b698482019dd8abf9c9190bebe7d4200
|