0

retrieving a users league keys

This request is for a REST query to compile every league key that a user is a part of. Using "users;use_login=1/games" is close but it doesn't retrieve the league id part for the league key. In other words, the part users see in yahoo.com fantasy sports URLs.

It's been over a month since I worked on this and thought I did this before, but maybe not. Ideas? Almost done with an open application/hack :)

by
8 Replies
  • To be clear, this is for all past leagues (and not only active ones, which I see "users;use_login=1/games;game_keys=nfl/leagues" works for). I'm still researching this, so maybe I'll find the answer before anyone even reads this question ;)
    0
  • Looks like you must enter in game keys, so for every football league (plus or free) you can do:
    CODE
    http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=57,49,79,101,124,153,175,199,222,242,58,62,78,102,125,154,176,20
    0,223/leagues

    Or a shorter version, it seems passing in the name instead (e.g., 'nfl') will get the current league info. So:
    CODE
    http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=nfl/leagues

    Maybe one day I'll look for a "Find all leagues this user is in, of all types" but maybe later as it's trivial to store/know all available yahoo sports game keys.
    0
  • QUOTE (phil @ Aug 6 2010, 04:23 PM) <{POST_SNAPBACK}>
    Looks like you must enter in game keys, so for every football league (plus or free) you can do:
    CODE
    http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=57,49,79,101,124,153,175,199,222,242,58,62,78,102,125,154,176,20
    0,223/leagues

    Or a shorter version, it seems passing in the name instead (e.g., 'nfl') will get the current league info. So:
    CODE
    http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=nfl/leagues

    Maybe one day I'll look for a "Find all leagues this user is in, of all types" but maybe later as it's trivial to store/know all available yahoo sports game keys.

    Yeah, that's absolutely right given the current state of the world. In future, I'd like to put in a bit more flexibility on the games resource to request games of a certain type instead of explicitly needing to provide each game_key, and I also want to fix the problem where games that we don't support yet will cause the more generic "users;use_login=1/games/leagues" types of requests to fail.
    0
  • I think there's a bug when using multiple game codes for the users/games resource. The following fails with an HTTP 400 Bad Request

    http://fantasysports.yahooapis.com/fantasy...fl,pnfl/leagues

    While this request succeeds:

    http://fantasysports.yahooapis.com/fantasy...242,238/leagues

    The only difference is that one uses multiple game codes and the other uses multiple game IDs. If I use one game code then the request succeeds. The docs indicate I should be able to request game_keys=nfl,pnfl.

    Run the failed request in YQL

    Run the successful request in YQL
    0
  • @Ryan:
    Oops. Docs out of date. "pnfl" no longer exists, so it can't find a valid current game ID for that. Try something like "nfl,mlb" and you should have better luck.
    0
  • QUOTE (Sean Montgomery @ Aug 31 2010, 10:12 PM) <{POST_SNAPBACK}>
    @Ryan:
    Oops. Docs out of date. "pnfl" no longer exists, so it can't find a valid current game ID for that. Try something like "nfl,mlb" and you should have better luck.


    Odd, so I can select "where game_key='223'", which is a pnfl league and get back my league info from 2009. But I can't select "where game_key='pnfl'" to get it? I was hoping to select the nfl and pnfl leagues so I could see which leagues I've participated in during past years. If pnfl doesn't work then I have to use something like "game_key in (223, 200, ...)".
    0
  • QUOTE (Ryan Kennedy @ Aug 31 2010, 10:43 PM) <{POST_SNAPBACK}>
    Odd, so I can select "where game_key='223'", which is a pnfl league and get back my league info from 2009. But I can't select "where game_key='pnfl'" to get it? I was hoping to select the nfl and pnfl leagues so I could see which leagues I've participated in during past years. If pnfl doesn't work then I have to use something like "game_key in (223, 200, ...)".

    Right, because when you ask for a game_key, it's going to do an interpretive step to map any game code you provide over to the most recent active game ID associated with that game ID, and there is no such game ID for pnfl. Asking for any particular game ID specifically, though, will work fine (as long as that game ID is actually tied to a game).

    The ideal eventual way to solve this would be for us to extend out the games collection filtering options to let you ask for all games that match a certain game code, ie, you request "game_codes=pnfl,nfl" (using API, not YQL syntax) and you get back a collection of all games we've ever had that would have been categorized as pnfl or nfl. You'd probably also want to have the option to request certain seasons, ie, "game_codes=pnfl;game_seasons=2008" would get you the pnfl game from 2008. This would certainly make it easier to discover game IDs in a more hand-wavy fashion. Bug filed to look into it somewhere down the line (I've been wanting to do this for a while, just haven't had the time).
    0
  • QUOTE (Sean Montgomery @ Sep 1 2010, 01:21 PM) <{POST_SNAPBACK}>
    Right, because when you ask for a game_key, it's going to do an interpretive step to map any game code you provide over to the most recent active game ID associated with that game ID, and there is no such game ID for pnfl. Asking for any particular game ID specifically, though, will work fine (as long as that game ID is actually tied to a game).

    The ideal eventual way to solve this would be for us to extend out the games collection filtering options to let you ask for all games that match a certain game code, ie, you request "game_codes=pnfl,nfl" (using API, not YQL syntax) and you get back a collection of all games we've ever had that would have been categorized as pnfl or nfl. You'd probably also want to have the option to request certain seasons, ie, "game_codes=pnfl;game_seasons=2008" would get you the pnfl game from 2008. This would certainly make it easier to discover game IDs in a more hand-wavy fashion. Bug filed to look into it somewhere down the line (I've been wanting to do this for a while, just haven't had the time).

    +1 ... :)
    0

Recent Posts

in Fantasy Sports API