How do I define the endpoints? #5
-
I think I understand the endpoints, but this command: game_list = mlbapi.game([parameters]) Gets me this error: game_list = mlbapi.game('ALS') mlbapi.schedule works but no other endpoints. What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello and thanks for using the code. It looks like you want a list of games. I'm not sure what "ALS" refers to in your code sample, but here is an example of how to use the schedule endpoint to get a list of regular season games for a given team in a specific season.
This gives back a list of regular season games for the 2023 season for the Houston Astros. From that list of games, you can get information about individual games such as the
This gets the boxscore, using the game primary key for the first game of the first date of the schedule. If you have an example of something you're wanting to do, I can help with that. I will be pushing an update that you will need in order to follow the example above. Some breaking changes have occurred with the API since I last pushed a commit. |
Beta Was this translation helpful? Give feedback.
-
Thank you! I’ll try it when I return from my trip.Marianne Sent from my iPhoneOn Jul 17, 2023, at 9:53 AM, Trevor Viljoen ***@***.***> wrote:
The API returns games as a list for each date. Most times there will only be a single game for any given day, but there could be a double header. So you will need to loop through the dates and the games lists.
for day in astros_schedule.dates:
for game in day.games:
game_pk = game.game_pk
box_score = mlbapi.boxscore(game_pk)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hello and thanks for using the code. It looks like you want a list of games. I'm not sure what "ALS" refers to in your code sample, but here is an example of how to use the schedule endpoint to get a list of regular season games for a given team in a specific season.
This gives back a list of regular season games for the 2023 season for the Houston Astros.
From that list of games, you can get information about individual games such as the
game_pk
that is needed for checking aBoxScore
.This gets the boxscore…