0

YQL To Select Players Sorted by a Specific Stat

Is it possible, using YQL, to select a list of players that are sorted by a given stat? Ie. Can I get a list of NHL players (and stats) sorted by the goals category?

by
4 Replies
  • So, sort of. These are fantasy services, so things will be geared more towards data in a fantasy context. So, let's assume you have a Fantasy Hockey league -- yes, you can make a request of the form:

    CODE
    select * from fantasysports.players.stats where league_key='<league key>' and sort=1


    And that'll get you the top 25 players sorted by stat category 1, which happens to be goals. Of course, you have to know that goals are stat category 1, which makes it a bit trickier -- there's a stat_categories resource beneath the game that's accessible from the APIs (not in YQL) that'll explain all the stat_categories we offer, or you could ask for your league settings from YQL.
    0
  • Excellent, thanks. I notice that this query gives back the current season stats. Is there a way to get previous season stats? Also, what's the key to kicking it into week by week stats?

    Thanks for the help.
    0
  • QUOTE (Canned @ Sep 17 2010, 01:44 PM) <{POST_SNAPBACK}>
    Excellent, thanks. I notice that this query gives back the current season stats. Is there a way to get previous season stats? Also, what's the key to kicking it into week by week stats?

    Thanks for the help.

    It's a bit convoluted and poorly documented, but as an example:

    CODE
    select * from fantasysports.players.stats where league_key='mlb.l.627060' and sort=7 and sort_type="season" and sort_season=2009 and stats_type="season" and stats_season=2009;


    Basically, you can specify the type (season, week, date) and the value (stats_season, stats_week, stats_date) and make sure to mirror that out to the sort if you want to sort against it, too. Hopefully you can figure it out after playing around a bit. :)
    0
  • QUOTE (Sean Montgomery @ Sep 22 2010, 06:28 PM) <{POST_SNAPBACK}>
    It's a bit convoluted and poorly documented, but as an example:

    CODE
    select * from fantasysports.players.stats where league_key='mlb.l.627060' and sort=7 and sort_type="season" and sort_season=2009 and stats_type="season" and stats_season=2009;


    Basically, you can specify the type (season, week, date) and the value (stats_season, stats_week, stats_date) and make sure to mirror that out to the sort if you want to sort against it, too. Hopefully you can figure it out after playing around a bit. :)Does sort='PTS' work? It doesn't seem to function for NHL, at least for me.
    0

Recent Posts

in Fantasy Sports API