728x90
반응형
[MLB Stats API] 파이썬 패키지로 MLB Stats API 사용해보기
[MLB Stats API] 파이썬 패키지로 MLB Stats API 사용해보기
Fangraph나 MLB savant 홈페이지에서 직접 csv, DB파일을 다운로드 받는 것이 아닌 MLB서버에 연결된 API로 손쉽게 데이터를 구할 수 있는 방법을 야구공작소 글을 보며 알게되었다. 그 중 파이썬으로 API
minding-deep-learning.tistory.com
- 요청한 경기의 득점 과정에 대한 목록을 딕셔너리로 출력
- 3개의 키가 포함된 딕셔너리 반환
- home : 홈팀에 대한 데이터
- away : 원정팀에 대한 데이터
- plays : 득점 과정에 대한 데이터
statsapi.game_scoring_play_data(567074)
{'home': {'id': 143,
'name': 'Philadelphia Phillies',
'link': '/api/v1/teams/143',
'teamCode': 'phi',
'fileCode': 'phi',
'abbreviation': 'PHI',
'teamName': 'Phillies',
'locationName': 'Philadelphia',
'shortName': 'Philadelphia'},
'away': {'id': 146,
'name': 'Miami Marlins',
'link': '/api/v1/teams/146',
'teamCode': 'mia',
'fileCode': 'mia',
'abbreviation': 'MIA',
'teamName': 'Marlins',
'locationName': 'Miami',
'shortName': 'Miami'},
'plays': [{'result': {'description': 'Rhys Hoskins doubles (6) on a sharp line drive to left fielder Isaac Galloway. Bryce Harper scores.',
'awayScore': 0,
'homeScore': 1},
'about': {'atBatIndex': 6,
'halfInning': 'bottom',
'inning': 1,
'endTime': '2019-04-28T17:25:19.458Z'},
'atBatIndex': 6},
{'result': {'description': 'Jean Segura triples (2) on a sharp ground ball to right fielder Brian Anderson. Andrew McCutchen scores.',
'awayScore': 0,
'homeScore': 2},
'about': {'atBatIndex': 20,
'halfInning': 'bottom',
'inning': 3,
'endTime': '2019-04-28T17:52:28.085Z'},
'atBatIndex': 20},
{'result': {'description': 'Bryce Harper grounds out, shortstop Miguel Rojas to first baseman Martin Prado. Jean Segura scores.',
'awayScore': 0,
'homeScore': 3},
'about': {'atBatIndex': 21,
'halfInning': 'bottom',
'inning': 3,
'endTime': '2019-04-28T17:53:53.570Z'},
'atBatIndex': 21},
{'result': {'description': 'Miguel Rojas singles on a ground ball to second baseman Cesar Hernandez. Martin Prado scores.',
'awayScore': 1,
'homeScore': 3},
'about': {'atBatIndex': 26,
'halfInning': 'top',
'inning': 4,
'endTime': '2019-04-28T18:05:15.318Z'},
'atBatIndex': 26},
{'result': {'description': 'Nick Williams walks.',
'awayScore': 1,
'homeScore': 4},
'about': {'atBatIndex': 44,
'halfInning': 'bottom',
'inning': 6,
'endTime': '2019-04-28T18:45:01.869Z'},
'atBatIndex': 44},
{'result': {'description': 'Rhys Hoskins walks. Andrew McCutchen scores. Jean Segura to 3rd. Wild pitch by pitcher Tayron Guerrero.',
'awayScore': 1,
'homeScore': 5},
'about': {'atBatIndex': 59,
'halfInning': 'bottom',
'inning': 8,
'endTime': '2019-04-28T19:26:23.281Z'},
'atBatIndex': 59}]}
728x90