Skip to content

Instantly share code, notes, and snippets.

@akeaswaran
Last active March 22, 2023 03:12
Embed
What would you like to do?
ESPN hidden API Docs

ESPN's hidden API endpoints

Football

College Football

Latest News: http://site.api.espn.com/apis/site/v2/sports/football/college-football/news

Latest Scores: http://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard

  • query params:

    • calendar: 'blacklist'
    • dates: any date in YYYYMMDD

Game Information: http://site.api.espn.com/apis/site/v2/sports/football/college-football/summary?event=:gameId

  • params:

    • gameId: identifier of some game (EX: 400934572 for 2017 Army vs Navy)

Team Information: http://site.api.espn.com/apis/site/v2/sports/football/college-football/teams/:team

  • params:

    • team: some team abbreviation (EX: 'all' for Allegheny, 'gt' for Georgia Tech, 'wisconsin' for Wisconsin)

Rankings: http://site.api.espn.com/apis/site/v2/sports/football/college-football/rankings

NFL

Scores: http://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard

News: http://site.api.espn.com/apis/site/v2/sports/football/nfl/news

All Teams: http://site.api.espn.com/apis/site/v2/sports/football/nfl/teams

Specific Team: http://site.api.espn.com/apis/site/v2/sports/football/nfl/teams/:team

Baseball

MLB

Scores: http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard

News: http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/news

All Teams: http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/teams

Specific Team: http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/teams/:team

College Baseball

Scores: https://site.api.espn.com/apis/site/v2/sports/baseball/college-baseball/scoreboard

Hockey

Scores: http://site.api.espn.com/apis/site/v2/sports/hockey/nhl/scoreboard

News: http://site.api.espn.com/apis/site/v2/sports/hockey/nhl/news

All Teams: http://site.api.espn.com/apis/site/v2/sports/hockey/nhl/teams

Specific Team: http://site.api.espn.com/apis/site/v2/sports/hockey/nhl/teams/:team

Basketball

NBA

Scores: http://site.api.espn.com/apis/site/v2/sports/basketball/nba/scoreboard

News: http://site.api.espn.com/apis/site/v2/sports/basketball/nba/news

All Teams: http://site.api.espn.com/apis/site/v2/sports/basketball/nba/teams

Specific Team: http://site.api.espn.com/apis/site/v2/sports/basketball/nba/teams/:team

WNBA

Scores: http://site.api.espn.com/apis/site/v2/sports/basketball/wnba/scoreboard

News: http://site.api.espn.com/apis/site/v2/sports/basketball/wnba/news

All Teams: http://site.api.espn.com/apis/site/v2/sports/basketball/wnba/teams

Specific Team: http://site.api.espn.com/apis/site/v2/sports/basketball/wnba/teams/:team

Women's College Basketball

Scores: http://site.api.espn.com/apis/site/v2/sports/basketball/womens-college-basketball/scoreboard

News: http://site.api.espn.com/apis/site/v2/sports/basketball/womens-college-basketball/news

All Teams: http://site.api.espn.com/apis/site/v2/sports/basketball/womens-college-basketball/teams

Specific Team: http://site.api.espn.com/apis/site/v2/sports/basketball/womens-college-basketball/teams/:team

Men's College Basketball

Scores: http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard

News: http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/news

All Teams: http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/teams

Specific Team: http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/teams/:team

Soccer

Scores: http://site.api.espn.com/apis/site/v2/sports/soccer/:league/scoreboard

  • params:

    • league: some league abbreviation (EX: 'eng.1' for EPL, 'usa.1' for MLS)

Latest News: http://site.api.espn.com/apis/site/v2/sports/soccer/:league/news

List of Team Information: http://site.api.espn.com/apis/site/v2/sports/soccer/:league/teams

Will update with more information as I find more...

@brettshumaker
Copy link

What I've been doing for getting game data after weekend's games is using this endpoint https://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard?dates=$start_date-$end_date&limit=200 where $start_date and $end_date are using YYYYMMDD formatting. That lists all games that happened between the given dates (assuming there are less than 200 games between your dates).

@nrnrnr
Copy link

nrnrnr commented Sep 18, 2022

The scheduling endpoint, which returned JSON until a week or two ago, is now suddenly returning a web page. For example, https://www.espn.com/nfl/schedule/_/year/2022/week/2/seasontype/2?xhr=1

Is it still possible to get schedule information in JSON?

@drewcoble
Copy link

The scheduling endpoint, which returned JSON until a week or two ago, is now suddenly returning a web page. For example, https://www.espn.com/nfl/schedule/_/year/2022/week/2/seasontype/2?xhr=1

Is it still possible to get schedule information in JSON?

It looks like you are calling a url for a webpage. It should look something like: “https://sports.core.api.espn.com/v2/sports/football/leagues/nfl/“ and then add the endpoint you are looking for.

@nrnrnr
Copy link

nrnrnr commented Sep 29, 2022

@drewcoble using that base URL I am having trouble composing an endpoint that does anything except "application error." However, the original URL seems to work if the parameter is called _xhr with an initial underscore instead of just xhr.

@rondog
Copy link

rondog commented Sep 29, 2022

@nrnrnr remove the quote at the end of the link drew posted

@famictech2000
Copy link

Does anyone know the API for world cup soccer scores coming soon?

@ZachManno
Copy link

How to know in NFL which team has possession?

@ryanbuckner
Copy link

if (gameStatus == "in") {
try {
situation = game['situation']['downDistanceText'];
possessionId = game['situation']['possession'];
}

You then have to match the possessionId to the teamId to determine which team has the ball

@srivastr14
Copy link

Anyone able to find how you can get the starting lineup either during or before an MLB game? I can't seem to find that at all

@bobgodwin
Copy link

bobgodwin commented Oct 9, 2022

Anyone able to find how you can get the starting lineup either during or before an MLB game? I can't seem to find that at all

http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/summary?event=401246334

rosters[0] (0 = home, 1 = away) roster[n]. Roster has batting order, athlete, position, jersey, stats etc. Be aware that there may be more then 9 entries. But this is the closest I've got.
Edit: Just noticed roster[n]starter(true or false). So loop and check for starter=true or something like that.

@bobgodwin
Copy link

bobgodwin commented Oct 9, 2022

Just going to leave a few of my projects here if it's alright. Other than my football sites (Football Pool and Squares), most every thing I build is to replace the various home pages (Yahoo, MSN, Bing) that I've used throughout the years. Thanks to the ESPN API (And The National Weather Service API), I can pretty much do that. I've built a lot web pages (I guess they call them apps now) that use that datas:

Live games for multiple sports
https://bigearthweb.net/sports/sports-live/
Standings for multiple sports:
https://bigearthweb.net/sports/standings/
And my latest, one I've always wanted to do but never got around to, a live visual representation of a football game (NFL & NCAA):
https://bigearthweb.net/sports/football_field/

I also have multiple ways of extracting data to JSON or SQL (All PHP) if you want to store it locally (One is included in the sports-live archive. JSON only. Schedule and all dates. The JSON-Leagues archives are those files). Here are links to the archives for anyone interested:

https://bigearthweb.net/sports/sports-live.7z
https://bigearthweb.net/sports/standings.7z
https://bigearthweb.net/sports/football_field.7z
https://bigearthweb.net/sports/json-leagues.7z

Just extract to your site. I know Sports-Live is Americentric, but I know nothing about soccer, so they're hard for me to build. Same with the football field. I'd love to see someone build one of those for non-American football based on what I have. I do have Y'all in standings though! I hope these come in handy for someone. I also am building a site to run your office football squares if anyone's interested,

P.S.
Some links that I've put up before may not work anymore. Let me know if somethings gone you may want.

@srivastr14
Copy link

srivastr14 commented Oct 11, 2022

Anyone able to find how you can get the starting lineup either during or before an MLB game? I can't seem to find that at all

http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/summary?event=401246334

rosters[0] (0 = home, 1 = away) roster[n]. Roster has batting order, athlete, position, jersey, stats etc. Be aware that there may be more then 9 entries. But this is the closest I've got. Edit: Just noticed roster[n]starter(true or false). So loop and check for starter=true or something like that.

You are incredible! Thank you so much! Could you also help me look for starting pitcher's losses? I can find their era and wins, but not loses for some reason. Any help from anyone is appreciated!

Essentially I'm looking for the API that shows the "Season stats" that can be seen on this page: https://www.espn.com/mlb/player/_/id/5883/zack-greinke

@bobgodwin
Copy link

Essentially I'm looking for the API that shows the "Season stats" that can be seen on this page: https://www.espn.com/mlb/player/_/id/5883/zack-greinke

Try here:
https://site.web.api.espn.com/apis/common/v3/sports/baseball/mlb/athletes/5883
Look for "statsSummary/statistics." 0 = W/L 1=ERA 2=Ks 3=WHIP. It's the only place I've found.

@lexcraw4d
Copy link

when does it update for cfb http://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard ......
still showing week 7 and the odds went awy

@lexcraw4d
Copy link

image

I guess tomorrow the 18th - (Tuesdays?)

@daviswieck
Copy link

Odds only show for Pregame.
It will update close to midnight just in case any games are played on Monday night.

@bobgodwin
Copy link

bobgodwin commented Oct 21, 2022

I've update the Football Gridiron to include NCAA Football. You can select the games of the week or by conference.

https://bigearthweb.net/sports/football_field/
https://bigearthweb.net/sports/football_field.7z

And a list of NCAA Conference ids if anyone needs it:

Id = 80, Conf = FBS (I-A)
Id = 1, Conf = ACC
Id = 151, Conf = American
Id = 4, Conf = Big 12
Id = 5, Conf = Big Ten
Id = 12, Conf = C-USA
Id = 18, Conf = FBS Indep
Id = 15, Conf = MAC
Id = 17, Conf = Mountain West
Id = 9, Conf = Pac-12
Id = 8, Conf = SEC
Id = 37, Conf = Sun Belt
Id = 81, Conf = FCS (I-AA)
Id = 176, Conf = ASUN
Id = 20, Conf = Big Sky
Id = 40, Conf = Big South
Id = 48, Conf = CAA
Id = 22, Conf = Ivy
Id = 24, Conf = MEAC
Id = 21, Conf = MVFC
Id = 25, Conf = NEC
Id = 26, Conf = OVC
Id = 27, Conf = Patriot
Id = 28, Conf = Pioneer
Id = 31, Conf = SWAC
Id = 29, Conf = Southern
Id = 30, Conf = Southland
Id = 16, Conf = WAC

@nicksiscoe
Copy link

nicksiscoe commented Oct 21, 2022

Anyone else only seeing like the first half of tomorrow's games when hitting https://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard?dates=20221022? is it just me?
cc @reidwatson

@crichmond
Copy link

@akeaswaran,

How is it possible that we are able to access this when ESPN shut down public API support like 8 years ago?

@bobgodwin
Copy link

This seems pretty comprehensive:

https://www.espn.com/apis/devcenter/overview.html

Even has a branding guide and API logos.

@KevinDuganJr
Copy link

@akeaswaran,

How is it possible that we are able to access this when ESPN shut down public API support like 8 years ago?

Maybe they do not support it publicly, but they use it as the back-end for their data?

@munge64
Copy link

munge64 commented Oct 29, 2022 via email

@trueparallels
Copy link

This is just a community effort at documenting what is there now that's publicly available in some capacity. I wouldn't build anything that's not a hobby on it. If you're building a business, you're going to have to find somewhere you can pay for that data or risk getting shut down at any time.

The likely answer is that ESPN doesn't care about a few random hobbyists across the globe using their API for some minor things. It's a drop in the bucket for them. If ESPN drops a v3 GraphQL API at some point, I wouldn't be surprised, but I would be it would not be even slightly public.

@KevinDuganJr
Copy link

I'd like to find out also, because I don't want to build a bunch of code for my website (some of which I've already done) that is going to suddenly disappear...

Develop your website in a manner that it just consumes an object using the API data as middleware. Then when/if the ESPN API changes or fails, you just have to find a new source and your website continues. This is what I had to do with mine. NFL changed their API, or rather closed it down.

@lexcraw4d
Copy link

What is yalls best approach on querying a player by name if you don't know the id?

@slovanos
Copy link

slovanos commented Nov 4, 2022

Hi, and thanks for the list!

Any ideas on how to get boxing Information?

I discover some urls for mma:
https://site.api.espn.com/apis/site/v2/sports/mma/ufc/news
https://site.api.espn.com/apis/site/v2/sports/mma/ufc/scorboard

And for boxing it should be something analogous like:
https://site.api.espn.com/apis/site/v2/sports/boxing/:something/scoreboard

but I'm not getting anything. Any help would be appreciated

@codecatalysts
Copy link

@slovanos If you use this link you can find paths further down the tree by navigating to the url in the $ref. I don't see a top level boxing but there are several in mma, maybe has what you are looking for.

http://sports.core.api.espn.com/v2/sports

@ZachManno
Copy link

Made a parser that will turn the JSON response into a scoreboard object:
https://github.com/ZachManno/sports-scoreboard-ticker-led/blob/master/espn-scores/Scoreboard.py

@slovanos
Copy link

slovanos commented Nov 7, 2022

@slovanos If you use this link you can find paths further down the tree by navigating to the url in the $ref. I don't see a top level boxing but there are several in mma, maybe has what you are looking for.

http://sports.core.api.espn.com/v2/sports

Thanks @codecatalysts for your replay. Unfortunately I still can not find boxing info. I'm just looking for the upcomming fights on boxing to begin with, and, if available, the results (like on the scoreboard for the other sports)

@justingolden21
Copy link

Is there a way to get all college football scores, not just top 25?

@reidwatson
Copy link

reidwatson commented Nov 7, 2022

Is there a way to get all college football scores, not just top 25?

Add ?groups=80 to your call. https://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard?groups=80

Scroll back in this to around August 30th for more discussion on this, I had the same question previously

@justingolden21
Copy link

justingolden21 commented Nov 7, 2022

Thanks for the reply! I see the list of conference IDs above, but that URL you just showed doesn't have every game. It's missing SDSU UNLV for example, which is a div 1 game that just happened. It's actually missing all mountain west games, plus plenty of others. I think it's still only top 25.

In fact, it's only got about 25 games:
image

@reidwatson
Copy link

Again, scroll up and check out this post, you need to specify a limit greater than 25 and even try a date range and you’ll get what you’re looking for.
https://gist.github.com/akeaswaran/b48b02f1c94f873c6655e7129910fc3b?permalink_comment_id=4284805#gistcomment-4284805

@justingolden21
Copy link

justingolden21 commented Nov 7, 2022

Got it by adding a limit, thanks!

https://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard?groups=80&limit=200

@justingolden21
Copy link

justingolden21 commented Nov 10, 2022

Has anyone been able to figure out NFL or MLB rankings? I looked at their docs and used those endpoints, but I get a 404 error. The other end points work fine:

const API_ENDPOINTS = {
	'mens-college-basketball': '/basketball/mens-college-basketball/rankings',
	'womens-college-basketball': '/basketball/womens-college-basketball/rankings',
	'college-football': '/football/college-football/rankings'
	// 'mlb-baseball': '/baseball/mlb/rankings',
	// 'nba-basketball': '/basketball/nba/rankings',
	// 'wnba-basketball': '/basketball/wnba/rankings',
	// 'nfl-football': '/football/nfl/rankings'
};
	
const response = await fetch(`https://site.api.espn.com/apis/site/v2/sports${API_ENDPOINTS[sport]}`);

{"code":404,"message":"Unable to get sport data for sport: baseball and league: mlb"} from https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/rankings

@ITIRadio
Copy link

I've put about 100 hours into a personal project that I thought was possible with this API, a Raspberry Pi Score Ticker to attach to a TV, such as a second TV or a monitor in a TV room. However, I ran into too many issues with the scoreboard & events calls:

  1. With baseball & hockey, there were too many disappearing data points that would come up in the middle of a game, such as the line score for the top of the 3rd inning would vanish in the bottom of the 6th. While it would reappear, sometimes, the errors & inconsistencies made the use of this API, albeit free for now, too frustrating to actually use on an actual project.

  2. The basic scoreboard call for basketball has some stats, plus 3 leaders, so one API call per run through the scores is sufficient, however, football is another story. Both scoreboard (NFL & college) calls for football has literally zero stats, except the 3 leaders (passing, rushing, & receiving) FOR BOTH TEAMS COMBINED (ugh). Team stats, even basic yardages, are non-existant. So, I tested with calling the events API for each game, and I quickly ran into throttling issues. Two quick consecutive calls, one to the scoreboard and one to an event (game) caused the second to be ignored, time out, and cause a cancellation of any other calls. Python sleeps didn't help. This was strange because manually loading the JSON for 2 calls in a browser can be manually done with just a few second gap, but this couldn't be automated.

In short, I have determined that this API might be OK for the simplest of projects, or maybe downloading a few stats occasionally, but it's not worth any investment of time. It's not worth it for anything involving more than a couple of hundreds of lines of code, such as a super-basic score ticker, and certainly not something involving a nice user interface. I have completed Python Linux command line output for basic scoreboards for the NFL, NBA, and college football & basketball. If there is any interest in me posting a cleaned-up version of this code in another project, please let me know.

@ddivins
Copy link

ddivins commented Nov 20, 2022 via email

@bobgodwin
Copy link

In short, I have determined that this API might be OK for the simplest of projects, or maybe downloading a few stats occasionally, but it's not worth any investment of time. It's not worth it for anything involving more than a couple of hundreds of lines of code, such as a super-basic score ticker, and certainly not something involving a nice user interface. I have completed Python Linux command line output for basic scoreboards for the NFL, NBA, and college football & basketball. If there is any interest in me posting a cleaned-up version of this code in another project, please let me know.

I'm not sure what you're trying to accomplish, but I've used it to run a football pool for three years. So far the API has worked fine for me. I've built multi sport live game tickers and other stuff with it. Data's data, so you just have to turn it into what you need (PHP works fine for my uses). And you're not ever going to get what you need with just the scoreboard data. The Pool and football squares are member only but here's a link to some NFL stats. Live it shows info for the game in progress:

https://bigearthweb.net/sports/nfl-stats/

I've other post not to far back with the live sport tickers and whatnot.

@ochawkeye
Copy link

Like @bobgodwin, I've used this API for NFL stats for the better part of three years to run the live scoring for my fantasy football league.

My experience is that it has been a very reliable replacement for the JSON data that used to feed NFL.com game center.

Sample Top Performers
Sample All Scores

@chrisblakley
Copy link

chrisblakley commented Nov 21, 2022

For anyone curious, here is the scoreboard endpoint URL for the FIFA World Cup:
https://site.api.espn.com/apis/site/v2/sports/soccer/fifa.world/scoreboard

The league abbreviation is fifa.world.

For example– specifying a date range plus a limit to try to max out the available data (probably overkill):
https://site.api.espn.com/apis/site/v2/sports/soccer/fifa.world/scoreboard?limit=950&dates=20221121-20221127

@stern1978
Copy link

Any one know how to get World Cup table data?

@YodaLightsabr
Copy link

This isn't ESPN, but someone else made World Cup JSON (GitHub), which is a REST API for World Cup teams and matches. There's also a JS client to go along with it (worldcup.js).

@stern1978
Copy link

For anyone curious, here is the scoreboard endpoint URL for the FIFA World Cup: https://site.api.espn.com/apis/site/v2/sports/soccer/fifa.world/scoreboard

The league abbreviation is fifa.world.

For example– specifying a date range plus a limit to try to max out the available data (probably overkill): https://site.api.espn.com/apis/site/v2/sports/soccer/fifa.world/scoreboard?limit=950&dates=20221121-20221127

One can also be found here.

https://site.api.espn.com/apis/v2/scoreboard/header?sport=soccer&league=fifa.world

@bryanperez43
Copy link

@ITIRadio
Copy link

ITIRadio commented Dec 3, 2022

Let me add a couple of specific responses to replies: the NFL API calls can be slow if event calls & scoreboard calls are done quickly in succession, as in when automated. I abandoned the ticker idea, as Python I/O libraries always have some crucial lack of functionality that make automation unusable. For example, PyAutoGUI has automatic vertical scrolling, which would have been nice, but there's no flag, event, or anything else that reports when PyAutoGUI has scrolled through all of the available text. So, I proceeded with something that dumps text in the Linux Command Line, and that I can simply read, redirect to a file, or cron at specific times throughout the week. I also wanted to be careful about overuse of this for-now free service, such as it is, and at the same time get some nice output, whether it's before games, during games, or after games.

As I previously stated, the NFL API is working well, so I can concur with other reports. College games (full scoreboard, not just Top 25) are performing better, though there are fewer event stats and calls, thanks to the fewer games now being played while I'm testing. If there are more games returned by the scoreboard call, as potentially may be the case during bowl season, throttling may begin again. My Box Scores programs provide pre-game info, such as weather & lines, team season stat averages, team stat leaders, injuries (NFL only), and last 5 game results. During games, there's full team stats, full individual stats (though I didn't parse out special teams), current drive stats, and last play. Post-game, there's all of the in-game stats, plus headlines, quarter scores, and scoring plays, suitable for saving as readable text, or saving some code as snippets for applications, such as fantasy football calculators. I wouldn't wear these out, although, for me, a middleware database is out-of-the-question and pointless for this application. It seems like, given the glacial speed of ESPN.com, that they're loading an in-browser app that builds pages client-side, accessing this data API as it goes. So, their traffic manager may think that I like to hit the refresh button a lot?

The NBA & college basketball scoreboards have nearly identical JSON structures. There's also some basic stats & individual leaders, no matter the game status (pre, during, or post). Since you're making just 1 call to the scoreboard API, you can ask for all Division I games for college, and get the kind of output that I've been looking for, though you get a LOT of games. The events API is throwing inconsistencies like with baseball & hockey, so I stopped working on more detailed output for basketball. The brief football ticker program based on the scoreboard API only is too data-free to bother posting.

I've posted the NFL & college football box score programs to my new repository at:

https://github.com/ITIRadio/ESPN-API

I'll post basketball as I have time. The code is lengthier than expected because there ended up being significantly more error checking than I could have imagined. REST API databases make me love MySQL databases all over again.

@hawkseye76
Copy link

Anybody know how to pull data, events, scores, etc for NCAA Womens Volleyball? API docs say it exists, but it returns a 404.

@stern1978
Copy link

@hawkseye76
Copy link

hawkseye76 commented Dec 6, 2022

@stern1978 That is exactly what i'm looking for! Thank you!

Wonder why https://site.api.espn.com/apis/site/v2/sports/volleyball/womens-college-volleyball/scoreboard doesn't work like the other sports?

Edit: Well, now that link works. Maybe i just had a typo or something. Regardless, Thanks @stern1978!!

@makeniii
Copy link

makeniii commented Dec 14, 2022

Is there a id for a NBA season? Doesn't seem like there is but thought I'd ask anyways.

Also, does anyone know what 4/5 means for this variable for example, schedule_json['events']['competitions'][0]['status']['type']['id']? Currently, I know that:

1 = scheduled
2 = live
3 = completed
6 = postponed

So I'm assuming that 4/5 must mean something too but I haven't come across it yet.

@CyrilNb
Copy link

CyrilNb commented Jan 10, 2023

Does any one succeed to get leader of a soccer league (like Premiere league for example?). Scoreboard endpoint does not give current standings of the season

@CyrilNb
Copy link

CyrilNb commented Jan 10, 2023

Same for NBA, I am trying to get the current standing for both conferences. Is there a way someone managed to get it?

@zhayes84
Copy link

I wrote a Python "handler" (I don't know the proper label) that handles most of the College Football Ranking data:

https://github.com/zhayes84/espn-college-football-rankings-api-python/blob/main/ncaa_rankings_json.py

@nworbdier
Copy link

Does anyone know the endpoints for:

PGA Schedule (List of all tournaments and info for a given year/month/date)

PGA Player Scorecards for a Specific Tournament (Ideally only the details for a single golfer for a specific tournament

@ryanbuckner
Copy link

ryanbuckner commented Jan 24, 2023

Is there a way to use the NCAA Men's Basketball feed to get all March Madness games and scores?
http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard

@ryanbuckner
Copy link

ryanbuckner commented Jan 24, 2023

Let me add a couple of specific responses to replies: the NFL API calls can be slow if event calls & scoreboard calls are done quickly in succession, as in when automated. I abandoned the ticker idea, as Python I/O libraries always have some crucial lack of functionality that make automation unusable. For example, PyAutoGUI has automatic vertical scrolling, which would have been nice, but there's no flag, ......
I'll post basketball as I have time. The code is lengthier than expected because there ended up being significantly more error checking than I could have imagined. REST API databases make me love MySQL databases all over again.

I created a public google sheets that uses the NFL API and updates every 15 minutes
Sheets

@collinstork
Copy link

Just found out you can use "all" for the league, if the team is in multiple leagues.
so if you want to see the nextEvent for USMNT:
https://site.api.espn.com/apis/site/v2/sports/soccer/all/teams/usa

@athleticmistud
Copy link

does anyone know of the link for the live scores for the now depreciated https://feeds.nfl.com/feeds-rs/scores.json is there an alternative for the live scores?

@daverz06
Copy link

Is there a way to use the NCAA Men's Basketball feed to get all March Madness games and scores? http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard

The last "date" is 3-12 but the season end date in column I says 4-05, so I'm hoping we get data for the tournament. Do you know how to get all games right now instead of just ranked games?

@CN120
Copy link

CN120 commented Feb 3, 2023

@makeniii

Is there a id for a NBA season? Doesn't seem like there is but thought I'd ask anyways.

Also, does anyone know what 4/5 means for this variable for example, schedule_json['events']['competitions'][0]['status']['type']['id']? Currently, I know that:

1 = scheduled
2 = live
3 = completed
6 = postponed

So I'm assuming that 4/5 must mean something too but I haven't come across it yet.

Pulled from here

ID ESPN Status
0 TBD
1 SCHEDULED
2 IN PROGRESS
3 FINAL
4 FORFEIT
5 CANCELLED
6 POSTPONED
7 DELAYED
8 SUSPENDED
9 FORFEIT OF HOME TEAM
10 FORFEIT OF AWAY TEAM
17 RAIN DELAY
21 BEGINNING OF PERIOD
22 END OF PERIOD
23 HALFTIME
24 OVERTIME
25 FIRST HALF
26 SECOND HALF
27 ABANDONED
28 FULL TIME
29 RESCHEDULED
30 START LIST
31 INTERMEDIATE
32 UNOFFICIAL
33 MEDAL OFFICIAL
34 GROUPINGS OFFICIAL
35 PLAY COMPLETE
36 OFFICIAL - EVENT SHORTENED
37 CORRECTED RESULT
38 RETIRED
39 BYE
40 WALKOVER
41 VOID
42 PRELIMINARY
43 GOLDEN TIME
44 SHOOTOUT
45 FINAL SCORE - AFTER EXTRA TIME
46 FINAL SCORE - AFTER GOLDEN GOAL
47 FINAL SCORE - AFTER PENALTIES
48 END EXTRA TIME
49 EXTRA TIME HALF TIME
50 FIXTURE - NO LIVE COVERAGE
51 FINAL SCORE - ABANDONED

@ryanbuckner
Copy link

does anyone know of the link for the live scores for the now depreciated https://feeds.nfl.com/feeds-rs/scores.json is there an alternative for the live scores?

Regular Season:
https://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?seasontype=2&week= + weeknumber

Post Season
https://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?seasontype=3&week= + weeknumber

@athleticmistud
Copy link

athleticmistud commented Feb 3, 2023 via email

@ryanbuckner
Copy link

ryanbuckner commented Feb 3, 2023

What week number are we on in post season?...the best is yet to come...

Short answer, 22.

Here's my function for post season to build my live tracker

function getPostWeekName(weeknum) {
  var weekName;
  if (weeknum == 19){
      weekName = "WildCard";
    } else if (weeknum == 20){
      weekName = "Divisional";
    } else if (weeknum == 21){
      weekName = "Conference";
    } else if (weeknum == 22){
      weekName = "Pro Bowl";
    } else if (weeknum == 23){
      weekName = "SuperBowl";
  }
  return weekName;
}

@chrisblakley
Copy link

For anyone who may be interested (doesn't look like this has been mentioned here yet), the XFL works with this API:
Example: https://site.api.espn.com/apis/site/v2/sports/football/xfl/scoreboard

Nothing for the USFL that I can find, however.

@PIC954
Copy link

PIC954 commented Feb 8, 2023

hey!

Does anyone know the nascar/F1 API call?

@chrisblakley
Copy link

Nascar is no longer available, but here is an example endpoint for Formula 1:
https://site.api.espn.com/apis/site/v2/sports/racing/f1/scoreboard

There is a different endpoint for drivers, but you need the competition ID and the driver ID:
https://sports.core.api.espn.com/v2/sports/racing/leagues/f1/events/GAMEIDHERE/competitions/COMPETITIONIDHERE/competitors/DRIVERIDHERE/statistics

@tonycarnevale
Copy link

tonycarnevale commented Feb 9, 2023

Is there a way to use the NCAA Men's Basketball feed to get all March Madness games and scores? http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard

@daverz06 @ryanbuckner this might be late but a way to do this would be adding groups=

for example https://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard?groups=7
or http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard?dates=20230123&groups=0

for some reason the college basketball api only has limited data by default. My answer now is turning into a question. Does anyone know how to do a range of groups for ncaab?

@ischmidt20
Copy link

ischmidt20 commented Feb 9, 2023

for some reason the college basketball api only has limited data by default

@tonycarnevale You need to add the limit argument to ensure all games for a day are returned. I usually set limit to 363 as there will never be more than 363 D1 games in a day

Set groups equal to 50 to get all NCAA D1 games (regular season and conference tournaments). The postseason tournaments have different identifiers which unfortunately I can't recall at the moment.

@athleticmistud
Copy link

What week number are we on in post season?...the best is yet to come...

Short answer, 22.

Here's my function for post season to build my live tracker

function getPostWeekName(weeknum) {
  var weekName;
  if (weeknum == 19){
      weekName = "WildCard";
    } else if (weeknum == 20){
      weekName = "Divisional";
    } else if (weeknum == 21){
      weekName = "Conference";
    } else if (weeknum == 22){
      weekName = "Pro Bowl";
    } else if (weeknum == 23){
      weekName = "SuperBowl";
  }
  return weekName;
}

Thank you! So how real time is it? is there much delay ?
so if I use your function and wanted it for regular season do I just do the same function but starting with 1?)

@ryanbuckner
Copy link

Thank you! So how real time is it? is there much delay ? so if I use your function and wanted it for regular season do I just do the same function but starting with 1?)

You can call this to see the regular season week 1 - if you click the link below you'll see the events JSON payload for all the games in week 1. The data is real time and sometimes faster than my YouTube TV feed. But I would caution that there is a limit on how many times per day you can call it. That goes for all these APIs.

I usually call it every 60 minutes when there is no game, to get schedule updates and odds / lines changes. When games are on I switch to every 5 minutes. This way I avoid the limits, which I think is 2500 calls per day.

https://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?seasontype=2&week=1

@ITIRadio
Copy link

ITIRadio commented Feb 12, 2023

does anyone know of the link for the live scores for the now depreciated https://feeds.nfl.com/feeds-rs/scores.json is there an alternative for the live scores?

Regular Season:
https://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?seasontype=2&week= + weeknumber

Post Season
https://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?seasontype=3&week= + weeknumber

I use the following syntax for a date range, although it seems to work better if the second date is one day after the required date for a weekend's set of games (usually like a Thursday to Tuesday):

http://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?dates=YYYYMMDD-YYYYMMDD , where the first date in chronological order is first, and then the second date.

@ITIRadio
Copy link

for some reason the college basketball api only has limited data by default

@tonycarnevale You need to add the limit argument to ensure all games for a day are returned. I usually set limit to 363 as there will never be more than 363 D1 games in a day

Set groups equal to 50 to get all NCAA D1 games (regular season and conference tournaments). The postseason tournaments have different identifiers which unfortunately I can't recall at the moment.

I'm not sure about tournaments yet, but groups = 50 is all Division I, on given dates, so this should work throughout the remainder of the season & post-season:

http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard?groups=50&limit=200&dates=YYYYMMDD-YYYYMMDD

with the dates in the desired range (though the second date, the latter, sometimes needs to be one day after the desired date). This syntax has worked all season so far, for every game involving a Division I team.

@ryanbuckner
Copy link

I use the following syntax for a date range, although it seems to work better if the second date is one day after the required date for a weekend's set of games (usually like a Thursday to Tuesday):

http://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?dates=YYYYMMDD-YYYYMMDD , where the first date in chronological order is first, and then the second date.

Where most sports are played on a daily basis, the NFL is played by week. I wasn't able to get the above syntax to work with the nfl feed. I also tried to plug in a year, and I still get back data from this season.

@RONJ0N
Copy link

RONJ0N commented Feb 14, 2023

is using this api illegal in any way? or is it just free range anybody can use it?

@opendoug
Copy link

opendoug commented Feb 14, 2023

For anyone needing JSON of NFL games, this URL seems to work:

http://site.api.espn.com/apis/site/v2/sports/football/nfl/summary?event= + {game ID}

@athleticmistud
Copy link

athleticmistud commented Feb 14, 2023 via email

@ryanbuckner
Copy link

for some reason the college basketball api only has limited data by default

@tonycarnevale You need to add the limit argument to ensure all games for a day are returned. I usually set limit to 363 as there will never be more than 363 D1 games in a day

I was able to get data for 63 games today with the following based on a few tips above

https://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard?groups=50&limit=500

@ryanbuckner
Copy link

I'm attempting to create a google sheet that can be used to update NCAA Mens Basketball scores in "real time" (upon refresh) using the APIs here and some tips in the comments. The goal is to have something that can be used for real time March Madness tracking.

I'm sharing it here for anyone interested in checking out my progress so far, and to give me ideas on improvement. Also happy to grant access to anyone that wants to edit.

Here's the sheet :
https://docs.google.com/spreadsheets/d/1WMczLzQzibHglB_kksK4b5JksXDDitUAyw5Y1HXMjog/edit?usp=sharing

@todarko
Copy link

todarko commented Feb 28, 2023

Found a way not shown above that will pull back a single teams full schedule of games:

http://site.api.espn.com/apis/site/v2/sports/basketball/nba/teams/:teamid/schedule

@daverz06
Copy link

daverz06 commented Mar 4, 2023

I'm attempting to create a google sheet that can be used to update NCAA Mens Basketball scores in "real time" (upon refresh) using the APIs here and some tips in the comments. The goal is to have something that can be used for real time March Madness tracking.

I'm sharing it here for anyone interested in checking out my progress so far, and to give me ideas on improvement. Also happy to grant access to anyone that wants to edit.

Here's the sheet : https://docs.google.com/spreadsheets/d/1WMczLzQzibHglB_kksK4b5JksXDDitUAyw5Y1HXMjog/edit?usp=sharing

You sir are a godsend. Love your work. It has helped me greatly with my NFL and now soon to be March Madness pickems. QUESTION... what would the script code look like to "freeze" the odds at say 8 am? Really appreciate your help!

@mark-perry-tfs
Copy link

mark-perry-tfs commented Mar 7, 2023

How do you see player stats from games? When I do a summary API call statistics is blank? NFL is fine.. Its the XFL API that is blank

@jeremyshultz
Copy link

I'm attempting to create a google sheet that can be used to update NCAA Mens Basketball scores in "real time" (upon refresh) using the APIs here and some tips in the comments. The goal is to have something that can be used for real time March Madness tracking.

I'm sharing it here for anyone interested in checking out my progress so far, and to give me ideas on improvement. Also happy to grant access to anyone that wants to edit.

Here's the sheet : https://docs.google.com/spreadsheets/d/1WMczLzQzibHglB_kksK4b5JksXDDitUAyw5Y1HXMjog/edit?usp=sharing

VERY nicely done! Is there any possible way that you’d be able to add URLs to the team logos in the live score tab? Like an Away Logo URL and Home Logo URL?

@bobgodwin
Copy link

I don't really do basketball, but this might be a starting point for somebody that does:
Day:
http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard?dates=20230316
Round:
http://site.api.espn.com/apis/site/v2/sports/basketball/mens-college-basketball/scoreboard?dates=20230316-20230318&limit=32
For some reason, the second date has to be one day later.
But I have no idea what determines which side of the brackets the teams go or how seeding works.

@chisox721
Copy link

Shot in the dark here, does anyone know if you can retrieve NCAAB rosters for previous years? I'm working on a large project and the only attribute I haven't been able to get for inactive players is weight. Worst case scenario I'll have to write another parser for the sports reference site but that leads to another set of issues w/ associating ID's which I'd love to avoid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment