Registry Module
Registry for MLB StatsAPI Endpoints.
This module automatically generates endpoint classes from JSON schemas.
- Usage:
from pymlb_statsapi import api
# Use any endpoint response = api.Schedule.schedule(query_params={“sportId”: 1, “date”: “2025-06-01”}) data = response.json()
# Generate resource paths path = response.get_path(prefix=”mlb-data”)
# Generate URIs for different protocols file_path = response.get_uri(protocol=”file”, prefix=”mlb-data”) s3_uri = response.get_uri(protocol=”s3”, prefix=”raw-data”, gzip=True) redis_key = response.get_uri(protocol=”redis”, prefix=”mlb”)
- class pymlb_statsapi.model.registry.StatsAPI(excluded_methods: dict[str, set[str]] | None = None)[source]
Bases:
LogMixinStatsAPI registry that generates endpoint classes from JSON schemas.
- All endpoint names are available as attributes
- Type:
e.g., .Schedule, .Game, .Team
- __init__(excluded_methods: dict[str, set[str]] | None = None)[source]
Initialize the dynamic API registry.
- Parameters:
excluded_methods – Dict mapping endpoint names to sets of method names to exclude. Defaults to EXCLUDED_METHODS if not provided.
- get_endpoint(endpoint_name: str) Endpoint[source]
Get an endpoint by name.
- Parameters:
endpoint_name – The endpoint name (lowercase, e.g., ‘schedule’)
- Returns:
DynamicEndpoint instance
- Raises:
KeyError – If endpoint not found