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: LogMixin

StatsAPI 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_names() list[str][source]

Get list of all loaded endpoint names.

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

list_all_methods() dict[str, list[str]][source]

Get a mapping of all endpoints and their available methods.

Returns:

Dict mapping endpoint names to lists of method names

get_method_info(endpoint_name: str, method_name: str) dict[source]

Get detailed information about a specific method.

Parameters:
  • endpoint_name – The endpoint name (e.g., ‘schedule’)

  • method_name – The method name (e.g., ‘schedule’)

Returns:

Dict with method details (path, parameters, etc.)

pymlb_statsapi.model.registry.create_stats_api(excluded_methods: dict[str, set[str]] | None = None) StatsAPI[source]

Create a new StatsAPI instance.

Parameters:

excluded_methods – Optional custom exclusion mapping

Returns:

StatsAPI instance