Skip to content

How do I define the endpoints? #5

Answered by trevor-viljoen
Mpellet771 asked this question in Q&A
Discussion options

You must be logged in to vote

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.

import mlbapi

astros_schedule = mlbapi.schedule(season="2023", game_types="R", team_id=117)

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 a BoxScore.

game_pk = astros_schedule.dates[0].games[0].game_pk
box_score = mlbapi.boxscore(game_pk)

This gets the boxscore…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@Mpellet771
Comment options

@Mpellet771
Comment options

@trevor-viljoen
Comment options

Answer selected by Mpellet771
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants