Skip to content

Function: get

toddrob edited this page Mar 14, 2020 · 4 revisions

Call MLB StatsAPI and return JSON data.

This function is for advanced querying of the MLB StatsAPI, and is used by the functions in this library.

endpoint is one of the keys in the ENDPOINT dict.

params is a dict of parameters, as defined in the ENDPOINT dict for each endpoint.

force=True will force unrecognized parameters into the query string, and ignore parameter requirements.

Note: results from Stats API may not be as expected when forcing.

Example

statsapi.get('team', {'teamId':143}) will call the team endpoint for teamId=143 (Phillies)

Return value will be the raw response from MLB Stats API in json format.

Clone this wiki locally