1

Using ESPN's developer API's, you can query for news on a specific athlete using the 'athleteId'. See the Methods section of their docs:

http://developer.espn.com/docs/headlines#parameters

If you look up a player profile you can find the athlete id in the url of the page, but my question is how can we find this id using solely the APIs? With just the athlete's name?

TrevorBliss
  • 371
  • 3
  • 13
  • If it's not in documentation, then I guess you can't. That's kind of the point of API documentations, to tell you what you can you and what you cannot. – bobek Mar 15 '14 at 02:07

3 Answers3

1

If you go to a team's roster page, use inspect element, or whatever equivalent for the browser you use, and look at the table element of all the players on the team. Within the 'td' tags, you'll find a player ID. You could scrape the screen, store all of the player ids locally, and then use them as parameters in your api calls. This is merely a suggestion, but it should work, if the id that is used on the page is the same as the id needed to get that player's information in api.

fafafooey
  • 181
  • 1
  • 2
  • 13
1

As stated, it's all available in the api:

import requests
import pandas as pd

url = 'https://sports.core.api.espn.com/v3/sports/football/nfl/athletes?limit=18000'
jsonData = requests.get(url).json()

players = pd.DataFrame(jsonData['items']).dropna(subset='firstName')
players = players[['id', 'fullName']].dropna()

Output:

print(players)
            id          fullName
6        14856     Isaako Aaitui
7      3058033        Manny Abad
8        16836  Jared Abbrederis
9      2576467    Mehdi Abdesmad
10       14466  Isa Abdul-Quddus
       ...               ...
16920    16424     Mike Zupancic
16921    15462   Markus Zusevics
16922    11317     Jeremy Zuttah
16923  4294520   Brandon Zylstra
16924  4608362     Shane Zylstra

[16919 rows x 2 columns]
chitown88
  • 27,527
  • 4
  • 30
  • 59
0

All NFL player ID can be found on this page

https://sports.core.api.espn.com/v3/sports/football/nfl/athletes?limit=18000

This will return all NFL players ID , name and DOB

function GetESPNIds() {
    var url = 'https://sports.core.api.espn.com/v3/sports/football/nfl/athletes?limit=20000';
    $.ajax({
        type: "GET",
            url: url,
            success: function (data) {
            for (var i=0;i<data.items.length;i++) {
                if(data.items[i].hasOwnProperty("lastName") && data.items[i].hasOwnProperty("firstName") && data.items[i].hasOwnProperty("dateOfBirth")) {
                    console.log("Name: "+data.items[i].lastName+","+data.items[i].firstName +" ID: " +data.items[i].id +" DOB: " +data.items[i].dateOfBirth);
                }
            }
            }
    });
}

GetESPNIds();
MShack
  • 642
  • 1
  • 14
  • 33