apirestespn

ESPN API - How can I retrieve college basketball conferences using the Teams API?


The support forums on ESPN.com recommend using Stack Overflow with the ESPN tag. That's why I'm here.

I'm trying to obtain a list of all NCAA college basketball teams using ESPN's Teams API. I started with this GET request:

http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams?apikey=MY_API_KEY

That gave me a list of teams, but many of them are missing. For example, there is no Nebraska. So then I thought that maybe I need to get a list of teams by conference. So I read this in the documentation:

GROUPS: Allows for filtering by "group" or division, e.g. AL East, NFC South, etc. For group IDs and their corresponding values, make a request to http://developer.espn.com/v1/{resource}/leagues. Not applicable to golf and tennis.

So then I try to make a request to `http://developer.espn.com/v1/sports/basketball/mens-college-basketball/leagues?apikey=MY_API_KEY' and it says the page does not exist.

Is this a bug or user error?


Solution

  • First, I think you forgot sports in the resource. Try this:

    http://api.espn.com/v1/sports/basketball/mens-college-basketball?apikey=MY_API_KEY&leagues

    That will return a mapping of integers to conferences it seems according to the documentation.

    That fetched me:

    {"name" :"Atlantic Coast Conference","abbreviation" :"acc","groupId" :2,"shortName" :"ACC"}
    

    ...and much more.

    Then once you have that, let's say 2 = ACC. You should be able to do this:

    http://api.espn.com/v1/sports/basketball/mens-college-basketball?groups=2&apikey=MY_API_KEY'

    to get everything on ACC mens' basketball teams.

    Bear in mind the API is in beta though.