toddrob99 / MLB-StatsAPI

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

How do I determine what options are available for "fields" and "hydrate"? #56

Closed matthewncorrado closed 3 years ago

matthewncorrado commented 3 years ago

Were these originally determined through trial and error, or is there somewhere I can go for more information about how to use these parameters for different endpoints?

toddrob99 commented 3 years ago

There is documentation, but it requires a login which only MLB affiliates have. One way I've had success is finding somewhere on the MLB website that has the data I want and viewing the network log in my browser's developer tools. You can filter on statsapi.mlb.com to see the API calls with their full URLs. That is how I learned about hydrations. There are also a bunch of questions/answers on the r/mlbdata subreddit that might help, and you can post there for help with anything you can't find.

toddrob99 commented 3 years ago

For fields, request the full data (exclude the fields parameter) to see all fields. Then if you only want a subset of the fields, include the fields parameter with a comma-separated list of the ones you want. There are some examples of usage in this repo along with the r/mlbdata.