0

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?

Vidya
  • 29,932
  • 7
  • 42
  • 70
nomad
  • 1,699
  • 5
  • 21
  • 35

2 Answers2

1

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.

Vidya
  • 29,932
  • 7
  • 42
  • 70
  • Good catch. But it still gives me a 404 error. I will update the question with the new URL. – nomad Oct 29 '13 at 22:05
  • 1
    Try again. I made an edit. It looks like `leagues` needs to be a query param rather than a path param as you had it before. – Vidya Oct 29 '13 at 22:21
  • 1
    You don't need the &leagues GET parameter here. You can find a list of Helper API Calls at http://developer.espn.com/overview#helper-api-calls. These describe how to get the different groups inside a league. It does seem that the documentation needs to be edited for the /leagues endpoint you found - that endpoint was deprecated a long time ago and seems to have been missed from that page. – Roger Raymond Oct 31 '13 at 14:55
0

I could not figure out how to get a list of conferences, but I found out how to get the missing teams. When I was making the first get request, it was limiting me to 50 results by default:

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

They have a sandbox where you can play with your parameters, and I saw a limit and offset option:

http://developer.espn.com/io-docs

To get more than 50 results, you have to make multiple requests using the limit and offset parameters.

First Call: http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams/?limit=50&offset=0&_accept=text%2Fxml&apikey=MY_API_KEY

Next Call: http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams/?limit=50&offset=50&_accept=text%2Fxml&apikey=MY_API_KEY

And so on...

nomad
  • 1,699
  • 5
  • 21
  • 35