Endpoints
All available MLB Stats API endpoints.
Schedule
- class pymlb_statsapi.model.factory.Endpoint(endpoint_name: str, schema: dict, endpoint_config: dict, excluded_methods: set[str] | None = None)[source]
Dynamically generated endpoint class that creates methods from JSON schema.
- BASE_URL = 'https://statsapi.mlb.com/api'
- MAX_RETRIES = 3
- TIMEOUT = 30
- __init__(endpoint_name: str, schema: dict, endpoint_config: dict, excluded_methods: set[str] | None = None)[source]
- get_method(method_name: str) EndpointMethod[source]
Get the EndpointMethod object for introspection.
This allows access to all schema methods like: - get_schema() - get_parameter_schema() - list_parameters() - get_long_description()
- Parameters:
method_name – Name of the method
- Returns:
EndpointMethod instance
- Raises:
ValueError – If method not found
Example
>>> method = api.Schedule.get_method("schedule") >>> print(method.get_long_description()) >>> schema = method.get_schema() >>> param = method.get_parameter_schema("sportId")
- get_method_info(method_name: str) dict[source]
Get detailed information about a method.
DEPRECATED: Use get_method() instead for full schema access.
- Parameters:
method_name – Name of the method
- Returns:
dict with method details
Example
>>> info = api.Schedule.get_method_info("schedule") >>> print(info["path"]) >>> print(info["summary"])
- describe_method(method_name: str) str[source]
Get a human-readable description of a method with all its parameters.
This is a convenience wrapper around get_method().get_long_description().
- Parameters:
method_name – Name of the method
- Returns:
Formatted description
- Return type:
Example
>>> print(api.Schedule.describe_method("schedule"))
See Factory Module for full details.