Skip to content

How to discover the end points

Monitoring API Calls

The first thing we want to do to figure out the ESPN Fantasy API is to see how it is loading the web page. Many single page web applications such as Angular and React load the content to the DOM by means of javascript and api calls. If this is the case, then the data would likely be fetched in a nicely formated JSON object. Follow these steps:

ESPN Fantasy Screen Shot

  • Open Developer tools using Ctr + Shift + I
  • Navigate to the Network tab
  • Reload an ESPN page that shows informatino of interest i.e. Standings
  • Monitor the requests looking for interesting end points
    • Particularly your league ID as this indicates the request is retrieving information specific to your league
  • Note the request URL
    • We will import this into Postman shortly
  • Note the Cookie header in the Request Headers
    • This contains two authentication tokens: espnAuth and espn_s2
  • Another Header of interest is x-fantasy-filter which you'll see if you scroll to the bottom
    • This shows us some detail as to how ESPN filters information for the request

Replicating calls in Postman

Lets now copy the request URL into postman and add our Cookie authentication header. Look at this beautiful json response! Postman requests

Postman requests

Now that you know how to find how the browser requested the data the ultimately was displayed into the DOM, click on other parts of the web application such as your League Settings, a match box score, or a player, and you may notice different values being set for the view parameter, such as mRoster, mBoxScore etc.

Tip

When we isolate each view we will see what league data each view contributes

Comments