toddrob99 / MLB-StatsAPI

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

Update required params for team_roster endpoint #29

Closed toddrob99 closed 4 years ago

toddrob99 commented 4 years ago

MLB documentation says rosterType and season are required for the team_roster endpoint, but the endpoint works fine without them. Remove the requirements.

Call rejected due to missing required parameters:

>>> statsapi.get('team_roster', {'teamId':143})             
2019-11-05 21:09:51,345 -    DEBUG - statsapi(10988) - URL: https://statsapi.mlb.com/api/{ver}/teams/{teamId}/roster
2019-11-05 21:09:51,345 -    DEBUG - statsapi(10988) - Found path param: teamId
2019-11-05 21:09:51,346 -    DEBUG - statsapi(10988) - path_params: {'teamId': '143'}
2019-11-05 21:09:51,346 -    DEBUG - statsapi(10988) - query_params: {}
2019-11-05 21:09:51,404 -    DEBUG - statsapi(10988) - Replacing {teamId}
2019-11-05 21:09:51,404 -    DEBUG - statsapi(10988) - URL: https://statsapi.mlb.com/api/{ver}/teams/143/roster
2019-11-05 21:09:51,514 -    DEBUG - statsapi(10988) - Replacing {ver} with default: v1.
2019-11-05 21:09:51,517 -    DEBUG - statsapi(10988) - URL: https://statsapi.mlb.com/api/v1/teams/143/roster
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python37\lib\site-packages\statsapi\__init__.py", line 2447, in get
    + note
ValueError: Missing required parameter(s): rosterType, season.
--Required parameters for the team_roster endpoint: [['rosterType', 'season']].
--Note: If there are multiple sets in the required parameter list, you can choose any of the sets.

Same call forced through and successfully returning results:

>>> statsapi.get('team_roster', {'teamId':143}, force=True)
2019-11-05 21:09:06,039 -    DEBUG - statsapi(10988) - URL: https://statsapi.mlb.com/api/{ver}/teams/{teamId}/roster
2019-11-05 21:09:06,039 -    DEBUG - statsapi(10988) - Found path param: teamId
2019-11-05 21:09:06,040 -    DEBUG - statsapi(10988) - path_params: {'teamId': '143'}
2019-11-05 21:09:06,040 -    DEBUG - statsapi(10988) - query_params: {}
2019-11-05 21:09:06,070 -    DEBUG - statsapi(10988) - Replacing {teamId}
2019-11-05 21:09:06,070 -    DEBUG - statsapi(10988) - URL: https://statsapi.mlb.com/api/{ver}/teams/143/roster
2019-11-05 21:09:06,071 -    DEBUG - statsapi(10988) - Replacing {ver} with default: v1.
2019-11-05 21:09:06,103 -    DEBUG - statsapi(10988) - URL: https://statsapi.mlb.com/api/v1/teams/143/roster
{'copyright': 'Copyright 2019 MLB Advanced Media, L.P.  Use of any content on this page acknowledges agreement to the terms posted here http://gdx.mlb.com/components/copyright.txt', 'roster': [{'person': {'id': 605400, 'fullName': 'Aaron Nola', 'link': '/api/v1/people/605400'}, 'jerseyNumber': '27', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 656514, 'fullName': 'Adam Haseley', 'link': '/api/v1/people/656514'}, 'jerseyNumber': '40', 'position': {'code': '8', 'name': 'Outfielder', 'type': 'Outfielder', 'abbreviation': 'CF'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 605388, 'fullName': 'Adam Morgan', 'link': '/api/v1/people/605388'}, 'jerseyNumber': '46', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 595284, 'fullName': 'Andrew Knapp', 'link': '/api/v1/people/595284'}, 'jerseyNumber': '15', 'position': {'code': '2', 'name': 'Catcher', 'type': 'Catcher', 'abbreviation': 'C'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 457705, 'fullName': 'Andrew McCutchen', 'link': 
'/api/v1/people/457705'}, 'jerseyNumber': '22', 'position': {'code': '7', 'name': 'Outfielder', 'type': 'Outfielder', 'abbreviation': 'LF'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 660614, 'fullName': 'Arquimedes Gamboa', 'link': '/api/v1/people/660614'}, 'jerseyNumber': '70', 'position': {'code': '6', 'name': 'Shortstop', 'type': 'Infielder', 'abbreviation': 'SS'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 656354, 'fullName': 'Austin Davis', 'link': '/api/v1/people/656354'}, 'jerseyNumber': '54', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 547180, 'fullName': 'Bryce Harper', 'link': '/api/v1/people/547180'}, 'jerseyNumber': '3', 'position': {'code': '9', 'name': 'Outfielder', 'type': 'Outfielder', 'abbreviation': 'RF'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 514917, 'fullName': 'Cesar Hernandez', 'link': '/api/v1/people/514917'}, 'jerseyNumber': '16', 'position': {'code': '4', 'name': 'Second Base', 'type': 'Infielder', 'abbreviation': '2B'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 608344, 'fullName': 'Cole Irvin', 'link': '/api/v1/people/608344'}, 'jerseyNumber': '47', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 502085, 'fullName': 'David Robertson', 'link': '/api/v1/people/502085'}, 'jerseyNumber': '30', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 620453, 'fullName': 'Deivy Grullon', 'link': '/api/v1/people/620453'}, 'jerseyNumber': '73', 'position': {'code': '2', 'name': 'Catcher', 'type': 'Catcher', 'abbreviation': 'C'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 658305, 'fullName': 'Edgar Garcia', 'link': '/api/v1/people/658305'}, 'jerseyNumber': '66', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 
660853, 'fullName': 'Enyel De Los Santos', 'link': '/api/v1/people/660853'}, 'jerseyNumber': '51', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 593576, 'fullName': 'Hector Neris', 'link': '/api/v1/people/593576'}, 'jerseyNumber': '50', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 592663, 'fullName': 'J.T. Realmuto', 'link': '/api/v1/people/592663'}, 'jerseyNumber': '10', 'position': {'code': '2', 'name': 'Catcher', 'type': 'Catcher', 'abbreviation': 'C'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 453562, 'fullName': 'Jake Arrieta', 'link': '/api/v1/people/453562'}, 'jerseyNumber': '49', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 457803, 'fullName': 'Jay Bruce', 'link': '/api/v1/people/457803'}, 'jerseyNumber': '23', 'position': {'code': '9', 'name': 'Outfielder', 'type': 'Outfielder', 'abbreviation': 'RF'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 670456, 'fullName': 'JD Hammer', 'link': '/api/v1/people/670456'}, 'jerseyNumber': '65', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 516416, 'fullName': 'Jean Segura', 'link': '/api/v1/people/516416'}, 'jerseyNumber': '2', 'position': {'code': '6', 'name': 'Shortstop', 'type': 'Infielder', 'abbreviation': 'SS'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 501625, 'fullName': 'Jose Alvarez', 'link': '/api/v1/people/501625'}, 'jerseyNumber': '52', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 596748, 'fullName': 'Maikel Franco', 'link': '/api/v1/people/596748'}, 'jerseyNumber': '7', 'position': {'code': '5', 'name': 'Third Base', 'type': 'Infielder', 'abbreviation': '3B'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 601713, 'fullName': 'Nick Pivetta', 'link': '/api/v1/people/601713'}, 'jerseyNumber': '43', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 608384, 'fullName': 'Nick Williams', 'link': '/api/v1/people/608384'}, 'jerseyNumber': '5', 'position': {'code': '7', 'name': 'Outfielder', 'type': 'Outfielder', 'abbreviation': 'LF'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 546318, 'fullName': 'Odubel Herrera', 'link': '/api/v1/people/546318'}, 'jerseyNumber': '37', 'position': {'code': '8', 'name': 'Outfielder', 'type': 'Outfielder', 'abbreviation': 'CF'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 624133, 'fullName': 'Ranger Suarez', 'link': '/api/v1/people/624133'}, 'jerseyNumber': '55', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 656555, 'fullName': 'Rhys Hoskins', 'link': '/api/v1/people/656555'}, 'jerseyNumber': '17', 'position': {'code': '3', 'name': 'First Base', 'type': 'Infielder', 'abbreviation': '1B'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 476594, 'fullName': 'Robert Stock', 'link': '/api/v1/people/476594'}, 'jerseyNumber': '', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 596451, 'fullName': 'Roman Quinn', 'link': '/api/v1/people/596451'}, 'jerseyNumber': '24', 'position': {'code': '8', 'name': 'Outfielder', 'type': 'Outfielder', 'abbreviation': 'CF'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 664068, 'fullName': 'Scott Kingery', 'link': '/api/v1/people/664068'}, 'jerseyNumber': '4', 'position': {'code': '8', 'name': 'Outfielder', 'type': 'Outfielder', 'abbreviation': 'CF'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 622554, 'fullName': 'Seranthony Dominguez', 'link': '/api/v1/people/622554'}, 'jerseyNumber': '58', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 644364, 'fullName': 'Victor Arano', 'link': '/api/v1/people/644364'}, 'jerseyNumber': '64', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 592826, 'fullName': 'Vince Velasquez', 'link': '/api/v1/people/592826'}, 'jerseyNumber': '21', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}, {'person': {'id': 621107, 'fullName': 'Zach Eflin', 'link': '/api/v1/people/621107'}, 'jerseyNumber': '56', 'position': {'code': '1', 'name': 'Pitcher', 'type': 'Pitcher', 'abbreviation': 'P'}, 'status': {'code': 'A', 'description': 'Active'}, 'parentTeamId': 143}], 'link': '/api/v1/teams/143/roster', 'teamId': 143, 'rosterType': 'active'}
toddrob99 commented 4 years ago

Addressed in v0.1.5