Skip to content

parentTeamId of player sometimes missing in statsapi.boxscore_data(game_id) #167

@tobiask84

Description

@tobiask84

To reproduce for example store this game into a json:

import json
import statsapi

# Get game data for specific game ID
game_id = "778110"

try:
    # Get game data
    game_data = statsapi.boxscore_data(game_id)
    
    # Write game data to file
    output_file = f"{game_id}.json"
    with open(output_file, "w") as f:
        json.dump(game_data, f, indent=2)

Now check the player Blubaugh:

    "ID805123": {
        "person": {
          "id": 805123,
          "fullName": "AJ Blubaugh"
        },
        "position": {
          "abbreviation": "P"
        },
        "status": {},
        "stats": {
          "batting": {},
          "pitching": {
            "note": "(L, 0-1)",
            "runs": 7,
            "doubles": 0,
            "triples": 0,
            "homeRuns": 2,
            "strikeOuts": 6,
            "baseOnBalls": 1,
            "hits": 5,
            "atBats": 17,
            "stolenBases": 0,
            "numberOfPitches": 84,
            "inningsPitched": "4.0",
            "wins": 0,
            "losses": 1,
            "holds": 0,
            "blownSaves": 0,
            "earnedRuns": 2,
            "pitchesThrown": 84,
            "strikes": 51,
            "rbi": 7
          }
        },
        "seasonStats": {
          "batting": {
            "runs": 0,
            "doubles": 0,
            "triples": 0,
            "homeRuns": 0,
            "strikeOuts": 0,
            "baseOnBalls": 0,
            "hits": 0,
            "avg": ".000",
            "atBats": 0,
            "obp": ".000",
            "slg": ".000",
            "ops": ".000",
            "stolenBases": 0,
            "rbi": 0,
            "leftOnBase": 0
          },
          "pitching": {
            "runs": 7,
            "doubles": 0,
            "triples": 0,
            "homeRuns": 2,
            "strikeOuts": 6,
            "baseOnBalls": 1,
            "hits": 5,
            "atBats": 17,
            "obp": ".316",
            "stolenBases": 0,
            "numberOfPitches": 84,
            "era": "4.50",
            "inningsPitched": "4.0",
            "wins": 0,
            "losses": 1,
            "holds": 0,
            "blownSaves": 0,
            "earnedRuns": 2,
            "pitchesThrown": 84,
            "strikes": 51,
            "rbi": 7
          }
        },
        "gameStatus": {},
        "allPositions": [
          {
            "abbreviation": "P"
          }
        ]
      },```


parentTeamId is missing. All other players in this file have the parentTeamId within the player. Why not Blubauh :) ?

I understand that all players are either under "home" or "away". So I can retrieve the info from there. I'm still wondering why all players except Blubauh in this response have the id within the player json? Is there a reason the info is not present for this specific player?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions