Skip to content

Commit 871d5a5

Browse files
committed
add new ESPN base url
1 parent 6ba77bc commit 871d5a5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

_posts/2019-07-27-espn-fantasy-v3.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ ESPN has a weirdly undocumented API for interacting with their fantasy sports pl
1010

1111
Then ESPN changed the API earlier this year (2019) and everyone's code broke. (I wrote [three](https://stmorse.github.io/journal/espn-fantasy-python.html) [blog](https://stmorse.github.io/journal/espn-fantasy-2-python.html) [posts](https://stmorse.github.io/journal/espn-fantasy-3-python.html) on the old version and most of it's now unusable. Sad.)
1212

13+
**EDIT (September 2024): ESPN has changed the base URL (again) as of about April 2024, judging by [this issue](https://github.com/cwendt94/espn-api/issues/539) on cwendt's Python package. The base URL is now:**
14+
15+
```
16+
https://lm-api-reads.fantasy.espn.com/apis/v3/games
17+
```
18+
19+
**(end edit)**
20+
1321
But around the interwebs people are figuring out the new "version 3" API. Here's a [JS API Client](https://github.com/mkreiser/ESPN-Fantasy-Football-API) and a [Python project](https://github.com/cwendt94/ff-espn-api).
1422

1523
This post is a crash course in what I know about it, enough to hopefully get your feet wet before the 2019 fantasy season crashes in. [In a follow-up post](https://stmorse.github.io/journal/espn-fantasy-projections.html), I show how to grab historical player projections and compare to reality. [In this post](https://stmorse.github.io/journal/fantasy-bench.html) I compare actual to optimal rosters along with ESPN projections.
@@ -53,6 +61,14 @@ https://fantasy.espn.com/apis/v3/games/ffl/leagueHistory/<ID>?seasonId=<YEAR>
5361

5462
where `<YEAR>` is anything 2017 or previous (not sure how far back it goes, but I was finding what appeared to be correct info for one of my leagues' 2013 season).
5563

64+
**EDIT (September 2024) Follow-up from note above, as of about April 2024, ESPN changed the base url from this fantasy.espn.com spot to:**
65+
66+
```
67+
https://lm-api-reads.fantasy.espn.com/apis/v3/games
68+
```
69+
70+
**That is the only change I see, other than possibly some tweaks to JSON data you'll have to navigate on your own. The rest of this post's code works fine.**
71+
5672
You can put this URL in a browser and look at the resulting text (at this point it will show only some basic info about the league members), formatted in [JSON](https://www.json.org), which will look very familiar to a Python programmer since the structures are similar to Python's, more on that in a bit.
5773

5874
Anyway let's do this request via Python, for example:

_posts/2019-08-05-espn-fantasy-projections.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ We'll make use of the ESPN Fantasy API which [I cover how to use here](https://s
2929

3030
We are, in a nutshell, going to send ESPN the same GET request its website sends its own servers when we navigate to a historical league page. You can eavesdrop on how these requests are formed by using Safari's Web Developer tools or a proxy service like [Charles](https://www.charlesproxy.com) or [Fiddler](https://www.telerik.com/fiddler).
3131

32+
**EDIT (September 2024): ESPN has changed the base URL (again) as of about April 2024, judging by [this issue](https://github.com/cwendt94/espn-api/issues/539) on cwendt's Python package. The base URL is now:**
33+
34+
```
35+
https://lm-api-reads.fantasy.espn.com/apis/v3/games
36+
```
37+
38+
**(end edit)**
39+
3240
Before we write code to grab all the data we need, let's explore a little piece of it:
3341

3442
```python

0 commit comments

Comments
 (0)