League Stats v2.0

Summary
League Stats
Resource
League StatsProvides the statistics for a fantasy league by timeframe, period, player status, team id, team totals, and stats type.
Change Log
January 15, 2013
HTTP Methods
GETRetrieve stats for a league for a specified timeframe, period, team id, team totals, pro or fantasy, actual stats or projections.
Exceptions
Following list of exceptions will be returned
Example
Retrieve League Stats
XML field definitions
/league_statsA container element for the league stats.
/league_stats/playersA container element for the list of players whose stats are returned.
/league_stats/players/playerA containter element for the player.
/league_stats/players/player/@idID of a player.
/league_stats/players/player/statDefinition: /league_stats/players/player/stat/@abbr

Resource

League Stats

Description

Provides the statistics for a fantasy league by timeframe, period, player status, team id, team totals, and stats type.

Change Log

January 15, 2013

  • Rename playerid param to player_id and make it comma-delimited list for multiple values
  • Make position param a comma-delimited list for multiple values
  • Add exceptions

HTTP Methods

GET

Retrieve stats for a league for a specified timeframe, period, team id, team totals, pro or fantasy, actual stats or projections.

URL

http://api.cbssports.com/fantasy/league/stats?version=2.0

Parameters

response_format(optional) Specifies the format in which the requested resource should be returned.  Valid values are XML and JSON.  The default is XML.
limit(optional) Specifies the number of players to be returned.  By default, the API returns all players.
offset(optional, defaults to 0) Specifies the offset for the first player to be returned.
player_id(optional, multiple allowed and can be passed as a comma-delimited list, can not be used with player_status, position, team_id, team_type, pro_or_fantasy params) Limit the result set to players with ids specified in this param
player_status(optional, defaults to free_agents) Limit the result set by player_status (‘free_agents’ or ‘all’)
position(optional, defaults to all batters, multiple allowed and can be passed as a comma-delimited list) Limits the result set to a particular position, which is specified by a position code.  For a list of position codes, request the Positions resource.
timeframe(optional, defaults to current year) Year for which stats are being requested (any year in YYYY format from 1997 to current year).  Only supported period for past years is ytd
period(optional, defaults to ytd) Period for which stats are being requested.

Period can be one of the following values.

  • ytd (Year-to-Date)
  • y (Yesterday) - only valid when timeframe is current year
  • tp (This Period) - only valid when timeframe is current year
  • 7d (Last 7 Days not including the current day) - only valid when timeframe is current year
  • 14d (Last 14 Days not including the current day) - only valid when timeframe is current year
  • 21d (Last 21 Days not including the current day) - only valid when timeframe is current year
  • 28d (Last 28 Days not including the current day) - only valid when timeframe is current year
  • 3yr (Last 3 Years Average) - only valid when timeframe is current year
  • any period number for current year - only valid when timeframe is current year and stats_type=stats
  • any week of the season in ‘weekX’ format where X is the week number for football projections (stats_type=projections)
  • any date in YYYYMMDD format - only valid when timeframe is current year
stats_type(optional, defaults to ‘stats’) Determines if the resource will include actual stats, projections or Football Red Zone Stats.  Possible values are (stats, projections or redzone).
  • Projections are only available for current year.
  • redzone can only be used for football leagues.  Red Zone stats are stats that are accumulated by a player or a team inside the opponent’s 20-yard line on the football field.  Red Zone Stats can be requested for period ‘ytd’ and individual weeks ( 1 ...  17 ) for the current year and period ‘ytd’ for previous years.
source(optional, defaults to ‘cbs’ for stats_type=projections) The source for which projections are being requested.

Possible values for source for Baseball are as follows.

  • cbs - CBSSports.com Player Projections

Possible values for source for Football are as follows.

  • dave_richard - CBSSports.com Sr.  Fantasy Writer Dave Richard’s Player Projections
  • jamey_eisenberg - CBSSports.com Sr.  Fantasy Writer Jamey Eisenberg’s Player Projections
  • nathan_zegura - CBSSports.com Sr.  Fantasy Writer Nathan Zegura’s Player Projections
  • cbs - CBSSports.com Player Projections based on the average of above sources.
team_id(required if requesting stats for a particular team or team totals) ID of the fantasy team whose stats are being requested (use all to get team totals).  To get a list of fantasy team codes, request the <Teams> resource.
team_type(optional, defaults to ‘roster’) Determine whether to get a team’s roster or their scout team (‘roster’, ‘active’, ‘reserve’ or ‘scout_team’).  Can only be used with team_id.
pro_or_fantasy(optional, defaults to ‘fantasy’) Determines whether to count the stats for players only when they were active on the fantasy team’s roster or even when they were on the bench (‘fantasy’ or ‘pro’).  Can only be used with team_idfantasy is only supported for current year and periods ytd, y, period_number, or Xd (Last X Days), team_type active, and for stats_type stats.

Exceptions

Following list of exceptions will be returned

  • type: invalid_player_id, msg: Invalid player_id <player id>

Example

Retrieve League Stats

Sample URL

All Free Agent Stats for 2012

http://api.cbssports.com/fantasy/league/stats?version=2.0&player_status=free_agents&timeframe=2012&period=ytd&stats_type=stats

All Free Agent First Basemen Stats for 2011

http://api.cbssports.com/fantasy/league/stats?version=2.0&player_status=free_agents&position=1B&timeframe=2011&period=ytd&stats_type=stats

All Player Stats for 2011

http://api.cbssports.com/fantasy/league/stats?version=2.0&player_status=all&timeframe=2011&period=ytd&stats_type=stats

All Shortstops Stats for 2011

http://api.cbssports.com/fantasy/league/stats?version=2.0&player_status=all&position=SS&timeframe=2011&period=ytd&stats_type=stats

2012 Projections for All Players on Fantasy Team ID 1

http://api.cbssports.com/fantasy/league/stats?version=2.0&team_id=1&timeframe=2012&period=ytd&stats_type=projections

Year-to-date Fantasy Team Totals for 2012

http://api.cbssports.com/fantasy/league/stats?version=2.0&team_id=all&timeframe=2012&period=ytd&pro_or_fantasy=fantasy&stats_type=stats

2012 Projections for players with ids 187741 and 235253

http://api.cbssports.com/fantasy/league/stats?version=2.0&playerid=223571&playerid=293103&stats_type=projections&timeframe=2012&period=season

XML Response

Notes

  • Not all players are shown in the sample below.
  • <players> will be replaced by <teams> if requeting team totals (team_id=all)
  • <player> will be replaced by <team> if requesting team totals (team_id=all)
<?xml version="1.0"?>
<result uriAlias="/league/stats" uri="/league/stats" statusCode="200" statusMessage="OK">
  <body>
    <league_stats>
      <players><player id="293103">
<stat abbr="1B">66</stat>
<stat abbr="2B">28</stat>
<stat abbr="3B">1</stat>
<stat abbr="4x4">20</stat>
<stat abbr="4x4AL">17</stat>
<stat abbr="4x4NL">0</stat>
<stat abbr="5x5">20</stat>
<stat abbr="5x5AL">17</stat>
<stat abbr="5x5NL">0</stat>
<stat abbr="AB">460</stat>
<stat abbr="BA">0.267</stat>
<stat abbr="BB">62</stat>
<stat abbr="CS">2</stat>
<stat abbr="FPTS"></stat>
<stat abbr="G">135</stat>
<stat abbr="H">123</stat>
<stat abbr="H2H">380</stat>
<stat abbr="HR">28</stat>
<stat abbr="KO">124</stat>
<stat abbr="OBP">0.354</stat>
<stat abbr="OPS">0.869</stat>
<stat abbr="Pos">1B</stat>
<stat abbr="R">64</stat>
<stat abbr="RBI">73</stat>
<stat abbr="RV4">10.4231642512583</stat>
<stat abbr="RV5">10.4231642512583</stat>
<stat abbr="SB">4</stat>
<stat abbr="SLG">0.515</stat>
<stat abbr="TB">237</stat>
<stat abbr="TM">TEX</stat>
</player>
<player id="223571">
<stat abbr="1B">111</stat>
<stat abbr="2B">34</stat>
<stat abbr="4x4">38</stat>
<stat abbr="4x4AL">30</stat>
<stat abbr="4x4NL">0</stat>
<stat abbr="5x5">38</stat>
<stat abbr="5x5AL">30</stat>
<stat abbr="5x5NL">0</stat>
<stat abbr="AB">590</stat>
<stat abbr="BA">0.317</stat>
<stat abbr="BB">89</stat>
<stat abbr="CS">4</stat>
<stat abbr="FPTS"></stat>
<stat abbr="G">158</stat>
<stat abbr="H">187</stat>
<stat abbr="H2H">657.1</stat>
<stat abbr="HR">42</stat>
<stat abbr="KO">71</stat>
<stat abbr="OBP">0.406</stat>
<stat abbr="OPS">0.994</stat>
<stat abbr="Pos">1B</stat>
<stat abbr="R">113</stat>
<stat abbr="RBI">118</stat>
<stat abbr="RV4">20.106181498407</stat>
<stat abbr="RV5">20.106181498407</stat>
<stat abbr="SB">15</stat>
<stat abbr="SLG">0.588</stat>
<stat abbr="TB">347</stat>
<stat abbr="TM">LAA</stat>
</player>
</players>
    </league_stats>
  </body>
</result>

JSON Response

Notes

  • Not all players are shown in the sample below.
  • <players> will be replaced by <teams> if requeting team totals (team_id=all)
  • <player> will be replaced by <team> if requesting team totals (team_id=all)
{
   "body" : {
      "league_stats" : {
         "players" : [
            {
               "5x5" : "20",
               "BB" : 62,
               "RV4" : "10.4231642512583",
               "RBI" : 73,
               "TB" : "237",
               "id" : "293103",
               "4x4" : "20",
               "5x5NL" : 0,
               "OBP" : "0.354",
               "HR" : 28,
               "H" : 123,
               "4x4NL" : 0,
               "G" : "135",
               "AB" : "460",
               "OPS" : "0.869",
               "4x4AL" : "17",
               "5x5AL" : "17",
               "RV5" : "10.4231642512583",
               "SLG" : "0.515",
               "1B" : 66,
               "KO" : 124,
               "FPTS" : null,
               "2B" : 28,
               "Pos" : "1B",
               "CS" : 2,
               "TM" : "TEX",
               "H2H" : "380",
               "BA" : "0.267",
               "R" : 64,
               "SB" : 4,
               "3B" : 1
            },
            {
               "4x4AL" : "30",
               "OPS" : "0.994",
               "5x5" : "38",
               "BB" : 89,
               "RV4" : "20.106181498407",
               "5x5AL" : "30",
               "RBI" : 118,
               "TB" : "347",
               "id" : "223571",
               "RV5" : "20.106181498407",
               "SLG" : "0.588",
               "4x4" : "38",
               "5x5NL" : 0,
               "OBP" : "0.406",
               "1B" : 111,
               "KO" : 71,
               "FPTS" : null,
               "Pos" : "1B",
               "2B" : 34,
               "HR" : 42,
               "H" : "187",
               "CS" : 4,
               "H2H" : "657.1",
               "TM" : "LAA",
               "BA" : "0.317",
               "4x4NL" : 0,
               "R" : 113,
               "G" : "158",
               "SB" : 15,
               "AB" : "590"
            }
         ]
      }
   },
   "uriAlias" : "/league/stats",
   "statusMessage" : "OK",
   "uri" : "/league/stats",
   "statusCode" : 200
}

Sample URL

All Free Agent Stats for 2012

http://api.cbssports.com/fantasy/league/stats?version=2.0&player_status=free_agents&timeframe=2012&period=ytd&stats_type=stats

All Free Agent Quarterback Stats for 2011

http://api.cbssports.com/fantasy/league/stats?version=2.0&player_status=free_agents&position=QB&timeframe=2011&period=ytd&stats_type=stats

All Player Stats for 2011

http://api.cbssports.com/fantasy/league/stats?version=2.0&player_status=all&timeframe=2011&period=ytd&stats_type=stats

All Wide Receivers Stats for 2011

http://api.cbssports.com/fantasy/league/stats?version=2.0&player_status=all&position=WR&timeframe=2011&period=ytd&stats_type=stats

2012 Projections for All Players on Fantasy Team ID 1

http://api.cbssports.com/fantasy/league/stats?version=2.0&team_id=1&timeframe=2012&period=ytd&stats_type=projections

Year-to-date Fantasy Team Totals for 2012

http://api.cbssports.com/fantasy/league/stats?version=2.0&team_id=all&timeframe=2012&period=ytd&pro_or_fantasy=fantasy&stats_type=stats

2012 Projections for players with ids 223571 and 293103

http://api.cbssports.com/fantasy/league/stats?version=2.0&playerid=187741&playerid=235253&stats_type=projections&timeframe=2012&period=season

XML Response

Notes

  • Not all players are shown in the sample below.
  • <players> will be replaced by <teams> if requeting team totals (team_id=all)
  • <player> will be replaced by <team> if requesting team totals (team_id=all)
<?xml version="1.0"?>
<result uriAlias="/league/stats" uri="/league/stats" statusCode="200" statusMessage="OK">
  <body>
    <league_stats>
      <players><player id="187741">
<stat abbr="CmpPct">0.7</stat>
<stat abbr="FL">1.0</stat>
<stat abbr="FPTS">420.2</stat>
<stat abbr="G">16.0</stat>
<stat abbr="GS">16.0</stat>
<stat abbr="PaAtt">538.5</stat>
<stat abbr="PaCmp">364.5</stat>
<stat abbr="PaInt">8.5</stat>
<stat abbr="PaTD">38.0</stat>
<stat abbr="PaYd">4949.5</stat>
<stat abbr="Pos">QB</stat>
<stat abbr="ReAvg">0</stat>
<stat abbr="RuAtt">28.0</stat>
<stat abbr="RuAvg">1.9</stat>
<stat abbr="RuTD">1.5</stat>
<stat abbr="RuYd">52.5</stat>
<stat abbr="TM">NE</stat>
<stat abbr="YAtt">9.2</stat>
<stat abbr="name">Tom Brady</stat>
</player>
<player id="235253">
<stat abbr="CmpPct">0.6</stat>
<stat abbr="FL">5.0</stat>
<stat abbr="FPTS">348.2</stat>
<stat abbr="G">14.5</stat>
<stat abbr="GS">14.5</stat>
<stat abbr="PaAtt">423.5</stat>
<stat abbr="PaCmp">247.5</stat>
<stat abbr="PaInt">12.5</stat>
<stat abbr="PaTD">27.5</stat>
<stat abbr="PaYd">3572.0</stat>
<stat abbr="Pos">QB</stat>
<stat abbr="ReAvg">0</stat>
<stat abbr="RuAtt">66.0</stat>
<stat abbr="RuAvg">6.8</stat>
<stat abbr="RuTD">5.5</stat>
<stat abbr="RuYd">450.5</stat>
<stat abbr="TM">PHI</stat>
<stat abbr="YAtt">8.4</stat>
<stat abbr="name">Michael Vick</stat>
</player>
</players>
    </league_stats>
  </body>
</result>

JSON Response

Notes

  • Not all players are shown in the sample below.
  • <players> will be replaced by <teams> if requeting team totals (team_id=all)
  • <player> will be replaced by <team> if requesting team totals (team_id=all)
{
   "body" : {
      "league_stats" : {
         "players" : [
            {
               "RuAtt" : "28.0",
               "RuYd" : "52.5",
               "FL" : "1.0",
               "ReAvg" : 0,
               "id" : "187741",
               "RuTD" : "1.5",
               "PaInt" : "8.5",
               "CmpPct" : "0.7",
               "RuAvg" : "1.9",
               "name" : "Tom Brady",
               "FPTS" : 420.2,
               "YAtt" : "9.2",
               "PaCmp" : "364.5",
               "GS" : "16.0",
               "Pos" : "QB",
               "PaAtt" : "538.5",
               "TM" : "NE",
               "PaYd" : "4949.5",
               "PaTD" : "38.0",
               "G" : "16.0"
            },
            {
               "RuAtt" : "66.0",
               "RuYd" : "450.5",
               "FL" : "5.0",
               "ReAvg" : 0,
               "id" : "235253",
               "RuTD" : "5.5",
               "PaInt" : "12.5",
               "CmpPct" : "0.6",
               "RuAvg" : "6.8",
               "name" : "Michael Vick",
               "FPTS" : 348.2,
               "YAtt" : "8.4",
               "PaCmp" : "247.5",
               "GS" : "14.5",
               "Pos" : "QB",
               "PaAtt" : "423.5",
               "TM" : "PHI",
               "PaYd" : "3572.0",
               "PaTD" : "27.5",
               "G" : "14.5"
            }
         ]
      }
   },
   "uriAlias" : "/league/stats",
   "statusMessage" : "OK",
   "uri" : "/league/stats",
   "statusCode" : 200
}

XML field definitions

/league_stats

A container element for the league stats.

/league_stats/players

A container element for the list of players whose stats are returned.

/league_stats/players/player

A containter element for the player.

/league_stats/players/player/@id

ID of a player.

/league_stats/players/player/stat

Definition: /league_stats/players/player/stat/@abbr