Tell me more ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I am about to start a Yahoo Fantasy baseball keeper league in a few days, and I came across Yahoo APIs. I currently have been working with ASP.NET (C#), and I would like to make a companion site for our fantasy league.

Does anyone understand this enough to explain it to a beginner to API's/web services/etc? http://developer.yahoo.com/fantasysports/guide/index.html

Basically I understand that I would be querying yahoo for information and it will be returned in either XML or JSON. For one, I cannot seem to find my league_key (only league ID), so I cannot test this on my own hockey league right now. Could anyone give some guidance to this? I get OAuth errors when I try to load a link, which I have no idea what they mean.

I know I can handle parsing the XML in .NET and putting the information on a site. I am just unsure of how to retrieve it correctly.

Here are some more examples:

share|improve this question

closed as off topic by Sathya Jan 25 at 5:07

Questions on Web Applications Stack Exchange are expected to relate to web applications within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

up vote 0 down vote accepted

I'm also new to the Fantasy Sports API so this won't necessarily be a complete answer.

You need to be logged in to your actual Yahoo! account (or Authenticated through an OpenID) to see a link to your league page. Your League ID can also be retrieved when you first created the League, or from the !Fantasy Sports site after logging in (for example, my league ID is "97279"): http://baseball.fantasysports.yahoo.com/b1/register/tos?done=createjoin

If you forgot to get it, you can grab the end of the URL when viewing it: http://baseball.fantasysports.yahoo.com/b1/97279

Next you need to plug that information into an authenticated/authorized request. Authentication is done by providing your Yahoo! login or OpenID which has access to your league (i.e. probably only your's for now), while Authorization whether is done via OAuth to specify which aspects of your league can be acessed by who and where that access can happen (i.e. your ASP.net C# app will probably need to use an OAuth library).

In this case though, you're probably already authenticated to your Yahoo! account so the easiest place to work with the data is the console which I see you've already been playing with some public examples for. Then you can start to do more interesting things like drill down to Games/Teams/Players/Stats/odds... although from what I understand, the API is most useful when the league in question has games running, so most requests to your league would be black unless you go back to the previous year's data. The only table I could find for previous years is here: http://developer.yahoo.com/fantasysports/guide/game-resource.html#game-resource-desc

A request for Baseball stats for an actual MLB player from one of the example leagues from 2010 then, would look as follows: http://developer.yahoo.com/yql/console/?q=select%20*%20from%20fantasysports.players.stats%20where%20league_key%3D'238.l.627060'%20and%20player_key%3D'238.p.8193'

To see the structure of this URL call, look down below for "The REST Query": https://query.yahooapis.com/v1/yql?q=select%20*%20from%20fantasysports.players.stats%20where%20league_key%3D'238.l.627060'%20and%20player_key%3D'238.p.8193'&diagnostics=true

But note to call this from a remote server outside of Yahoo's own fantasy pages or console, you will need to authenticate using OAuth as mentioned above.

That's about all I can add for now, sorry if you know most of this already, but once I've had a chance to develop out a league and test I'll try to add more. I'm sure others who have ran leagues in previous years have had better success too...

share|improve this answer
I know this is an extremely late response, but thank you! I havent begun messing with this stuff, but it does help quite a bit. Any other information that you have learned would also be beneficial, but only if you have the time to share it. Thanks! – pjb5064 Apr 5 '11 at 13:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.