Home > Enterprise >  ESPN API Only showing top 25 college basketball scores
ESPN API Only showing top 25 college basketball scores

Time:11-14

im using the api endpoint'http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard'. It is only returning the games for the top 25 teams. Any idea how to get all division 1 scores? The url for that is https://www.espn.com/mens-college-basketball/scoreboard/_/group/50.

CodePudding user response:

You need to pass in additional parameters as the default is to just get the top 25. The group for division 1 looks to be '50', and you also want to increase the default limit too:

import requests

url = 'http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard'
payload = {
'limit':'500',
'groups':'50'}

jsonData = requests.get(url, params=payload).json()

Output:

import pandas as pd

df = pd.json_normalize(jsonData['events'])
print (df)
           id  ... status.type.altDetail
0   401372032  ...                    OT
1   401372250  ...                   NaN
2   401372164  ...                   NaN
3   401371979  ...                   NaN
4   401369851  ...                   NaN
..        ...  ...                   ...
94  401371252  ...                   NaN
95  401371195  ...                   NaN
96  401373366  ...                   NaN
97  401371131  ...                   NaN
98  401372198  ...                   NaN

[99 rows x 21 columns]
  • Related