toddrob99 / MLB-StatsAPI

Python wrapper for MLB Stats API
GNU General Public License v3.0
533 stars 100 forks source link

pitchesThrown key error for 2022 season #70

Closed andersonericw closed 2 years ago

andersonericw commented 2 years ago

File "/usr/local/lib/python3.9/site-packages/statsapi/init.py", line 749, in boxscore_data boxData[side]["players"]["ID" + pitcherId]["stats"]["pitching"][ KeyError: 'pitchesThrown'

!/usr/bin/env python3

import statsapi import json

games = statsapi.schedule(start_date='04/08/2022',end_date='10/30/2022', team="145")

for i in games: box = statsapi.boxscore_data(i['game_id'], timecode=None)

toddrob99 commented 2 years ago

@andersonericw I think the exception was suppressed in v1.4.1 (see latest commit on this repo), but MLB changed the field name from pitchesThrown to numberOfPitches. Therefore, it would just show 0 everywhere. I fixed that in v1.4.2 just now. Please update to the latest version using py -m pip install --upgrade mlb-statsapi.

andersonericw commented 2 years ago

That did it! thanks for the quick turnaround