Skip to content

MLB API Added New Fields - SimplePitchingSplit Missing age and caughtstealingpercentage Fields #232

@coreylane

Description

@coreylane

MLB API Added New Fields to Pitcher Stats - SimplePitchingSplit Missing Fields

Problem Description

The MLB API has added new fields to pitcher statistics responses, but the SimplePitchingSplit dataclass is missing these fields, causing TypeError when trying to initialize the object.

Error Details

Error 1: Missing age field

SimplePitchingSplit.__init__() got an unexpected keyword argument 'age'

Error 2: Missing caughtstealingpercentage field

SimplePitchingSplit.__init__() got an unexpected keyword argument 'caughtstealingpercentage'

How to Reproduce

from mlbstatsapi.mlb_api import Mlb

mlb = Mlb()
# This will fail with the above errors
stats = mlb.get_player_stats(641793, stats=['season'], groups=['pitching'], season=2025)

API Response Analysis

The MLB API now returns these additional fields in pitcher statistics:

  • age: Player's age (integer)
  • caughtStealingPercentage: Caught stealing percentage (string/float)

Example API response: https://statsapi.mlb.com/api/v1/people/641793/stats?stats=season&group=pitching&season=2025

Proposed Fix

Add the missing optional fields to the SimplePitchingSplit dataclass in /mlbstatsapi/models/stats/pitching.py:

@dataclass(repr=False)
class SimplePitchingSplit:
    # ... existing fields ...
    age: Optional[int] = None
    caughtstealingpercentage: Optional[str] = None

Impact

This affects any application consuming pitcher statistics from the current MLB API, causing crashes when trying to process the response data.

Environment

  • Library version: 0.5.26
  • Python version: 3.13+
  • Affected endpoint: https://statsapi.mlb.com/api/v1/people/{playerId}/stats

Test Case

Player ID 641793 consistently reproduces this issue with current season data.

Additional Context

The MLB API frequently adds new statistical fields without notice. Consider implementing a more flexible approach to handle unknown fields in future versions to prevent similar issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions