Player Stats
Anytime's player stats API allows you to fetch historical player stats. Our simple split and filtering API allows you to simply fetch the game logs and averages for different time spans and filters. To view an example project that uses this endpoint, check out our example client.
Overview
Anytime's Suppor Stats APIs allow you to quickly fetch split and filtered player averages and game logs.
Step 1: Lookup Player
In order to fetch a player's stats, you first need to find their id
. You can lookup a player's information, and their id using their name. Optionally, you can proveide a team_id
to improve accuracy and performance.
Player Lookup Without Team Id
Use the following curl
command to lookup an NBA player by name:
curl -X GET https://api.anytimelabs.io/v1beta/leagues/nfl/players/lookup?name=Patrick Mahomes
name
: Player name.
Response Example
{ "first_name": "Patrick", "full_name": "Patrick Mahomes", "id": "pl_026eb061f6cb9e1182c3172ab0cd97c6", "jersey_number": 15, "last_name": "Mahomes", "position": { "category": "skill", "name": "QB" }, "team": { "abbr": "KC", "city": "Kansas City", "full_name": "Kansas City Chiefs", "id": "tm_7524b771b2c4937b80349862d96e7468", "league_id": "nfl", "mascot": "Chiefs" } }
This response includes relevant player information. We will use the returned player id
to fetch their supporting stats.
Player Lookup With Team Id
Although uncommon, name collisions do happen. Specifying a team_id
will improve accuracy and performance. Use the following curl
command to lookup an NBA player by name
and team_id
:
curl -X GET https://api.anytimelabs.io/v1beta/leagues/nfl/players/lookup?name=Patrick Mahomes&team_id=tm_7524b771b2c4937b80349862d96e7468
name
: Player name.team_id
: Team Id.
Response Example
{ "first_name": "Patrick", "full_name": "Patrick Mahomes", "id": "pl_026eb061f6cb9e1182c3172ab0cd97c6", "jersey_number": 15, "last_name": "Mahomes", "position": { "category": "skill", "name": "QB" }, "team": { "abbr": "KC", "city": "Kansas City", "full_name": "Kansas City Chiefs", "id": "tm_7524b771b2c4937b80349862d96e7468", "league_id": "nfl", "mascot": "Chiefs" } }
This response includes relevant player information. We will use the returned player id
to fetch their supporting stats.
Step 2: Fetch Player Averages
Using the player_id
you can fetch player averages, filtering for various game type filters like h2h
or is_home
, and time span filters like last_n
and seasons
. You can read more about time span filters here, and game filters here.
Fetch player averages in away games this season
This example shows how to get Patrick Mahomes's averages for away games this season.
curl -X POST https://api.anytimelabs.io/v1beta/leagues/nfl/players/pl_026eb061f6cb9e1182c3172ab0cd97c6/averages \ -H "Content-Type: application/json" \ -d '{ "conditions": [ { "time_span": { "key": "seasons", "value": [2024] }, "game_filters": [{ "key": "is_home", "value": false }] } ] }'
Response Example
{ "condition_averages": [ { "averages": { "pass_att": 33.25, "pass_cmp": 22.0, "pass_int": 1.25, "pass_lng_td": 19.0, "pass_lng_yds": 33.0, "pass_sacks": 1.5, "pass_td": 1.25, "pass_yds": 219.5, "rec_lng_td": 0.0, "rec_lng_yds": 0.0, "rec_rec": 0.0, "rec_td": 0.0, "rec_tgt": 0.0, "rec_yds": 0.0, "rush_att": 5.5, "rush_lng_td": 0.25, "rush_lng_yds": 18.75, "rush_rec_yds": 21.25, "rush_td": 0.25, "rush_yds": 21.25, "td_scored": 0.25 }, "condition": { "game_filters": [ { "key": "is_home", "value": false } ], "time_span": { "key": "seasons", "value": [ 2024 ] } }, "condition_index": 0 } ], "player": { "first_name": "Patrick", "full_name": "Patrick Mahomes", "id": "pl_026eb061f6cb9e1182c3172ab0cd97c6", "jersey_number": 15, "last_name": "Mahomes", "position": { "category": "skill", "name": "QB" }, "team": { "abbr": "KC", "city": "Kansas City", "full_name": "Kansas City Chiefs", "id": "tm_7524b771b2c4937b80349862d96e7468", "league_id": "nfl", "mascot": "Chiefs" } } }
Step 3: Fetch Player Game Logs
Using the player_id
you can fetch player game logs, filtering for various game type filters like h2h
or is_home
, and time span filters like last_n
and seasons
.
Fetch player game logs in away games this season
Use the following curl
command to return to a specific anchor:
curl -X POST https://api.anytimelabs.io/v1beta/leagues/nfl/players/pl_026eb061f6cb9e1182c3172ab0cd97c6/game-logs \ -H "Content-Type: application/json" \ -d '{ "conditions": [ { "time_span": { "key": "seasons", "value": [2024] }, "game_filters": [{ "key": "is_home", "value": false }] } ] }'
anchor_id
: The ID of the anchor you wish to return to.
Response Example
{ "condition_game_logs": [ { "averages": { "pass_att": 33.25, "pass_cmp": 22.0, "pass_int": 1.25, "pass_lng_td": 19.0, "pass_lng_yds": 33.0, "pass_sacks": 1.5, "pass_td": 1.25, "pass_yds": 219.5, "rec_lng_td": 0.0, "rec_lng_yds": 0.0, "rec_rec": 0.0, "rec_td": 0.0, "rec_tgt": 0.0, "rec_yds": 0.0, "rush_att": 5.5, "rush_lng_td": 0.25, "rush_lng_yds": 18.75, "rush_rec_yds": 21.25, "rush_td": 0.25, "rush_yds": 21.25, "td_scored": 0.25 }, "condition": { "game_filters": [ { "key": "is_home", "value": false } ], "time_span": { "key": "seasons", "value": [ 2024 ] } }, "condition_index": 0, "game_logs": [ { "game": { "away_team": { "abbr": "KC", "city": "Kansas City", "full_name": "Kansas City Chiefs", "id": "tm_7524b771b2c4937b80349862d96e7468", "league_id": "nfl", "mascot": "Chiefs" }, "game_time": "2024-09-23T00:20:00Z", "home_team": { "abbr": "ATL", "city": "Atlanta", "full_name": "Atlanta Falcons", "id": "tm_f50e76586643922496bb74d8d6921f83", "league_id": "nfl", "mascot": "Falcons" }, "id": "gm_8e736fb8e9e29311bbe314cc42d625d5", "league_id": "nfl" }, "stats": { "pass_att": 39, "pass_cmp": 26, "pass_int": 1, "pass_lng_td": 13, "pass_lng_yds": 27, "pass_sacks": 0, "pass_td": 2, "pass_yds": 217, "rec_lng_td": 0, "rec_lng_yds": 0, "rec_rec": 0, "rec_td": 0, "rec_tgt": 0, "rec_yds": 0, "rush_att": 6, "rush_lng_td": 0, "rush_lng_yds": 15, "rush_rec_yds": 17, "rush_td": 0, "rush_yds": 17, "td_scored": 0 } }, { "game": { "away_team": { "abbr": "KC", "city": "Kansas City", "full_name": "Kansas City Chiefs", "id": "tm_7524b771b2c4937b80349862d96e7468", "league_id": "nfl", "mascot": "Chiefs" }, "game_time": "2024-09-29T20:25:00Z", "home_team": { "abbr": "LAC", "city": "Los Angeles", "full_name": "Los Angeles Chargers", "id": "tm_0cc9aa07fe359940b50e2d584ce53f1f", "league_id": "nfl", "mascot": "Chargers" }, "id": "gm_a98cfea8d524989286daa503053c36fa", "league_id": "nfl" }, "stats": { "pass_att": 29, "pass_cmp": 19, "pass_int": 1, "pass_lng_td": 54, "pass_lng_yds": 54, "pass_sacks": 3, "pass_td": 1, "pass_yds": 245, "rec_lng_td": 0, "rec_lng_yds": 0, "rec_rec": 0, "rec_td": 0, "rec_tgt": 0, "rec_yds": 0, "rush_att": 5, "rush_lng_td": 0, "rush_lng_yds": 13, "rush_rec_yds": 12, "rush_td": 0, "rush_yds": 12, "td_scored": 0 } }, { "game": { "away_team": { "abbr": "KC", "city": "Kansas City", "full_name": "Kansas City Chiefs", "id": "tm_7524b771b2c4937b80349862d96e7468", "league_id": "nfl", "mascot": "Chiefs" }, "game_time": "2024-10-20T20:25:00Z", "home_team": { "abbr": "SF", "city": "San Francisco", "full_name": "San Francisco 49ers", "id": "tm_e343414c2aa993d794bdcbc90de2fb03", "league_id": "nfl", "mascot": "49ers" }, "id": "gm_c337c62f577f9cfdb88b46ce5c8d9457", "league_id": "nfl" }, "stats": { "pass_att": 27, "pass_cmp": 16, "pass_int": 2, "pass_lng_td": 0, "pass_lng_yds": 26, "pass_sacks": 2, "pass_td": 0, "pass_yds": 154, "rec_lng_td": 0, "rec_lng_yds": 0, "rec_rec": 0, "rec_td": 0, "rec_tgt": 0, "rec_yds": 0, "rush_att": 5, "rush_lng_td": 1, "rush_lng_yds": 33, "rush_rec_yds": 39, "rush_td": 1, "rush_yds": 39, "td_scored": 1 } }, { "game": { "away_team": { "abbr": "KC", "city": "Kansas City", "full_name": "Kansas City Chiefs", "id": "tm_7524b771b2c4937b80349862d96e7468", "league_id": "nfl", "mascot": "Chiefs" }, "game_time": "2024-10-27T20:25:00Z", "home_team": { "abbr": "LV", "city": "Las Vegas", "full_name": "Las Vegas Raiders", "id": "tm_6eeba998faa39796a48f4060679c63dc", "league_id": "nfl", "mascot": "Raiders" }, "id": "gm_3d706c80eb5998f880c6f2ee0ea2d883", "league_id": "nfl" }, "stats": { "pass_att": 38, "pass_cmp": 27, "pass_int": 1, "pass_lng_td": 9, "pass_lng_yds": 25, "pass_sacks": 1, "pass_td": 2, "pass_yds": 262, "rec_lng_td": 0, "rec_lng_yds": 0, "rec_rec": 0, "rec_td": 0, "rec_tgt": 0, "rec_yds": 0, "rush_att": 6, "rush_lng_td": 0, "rush_lng_yds": 14, "rush_rec_yds": 17, "rush_td": 0, "rush_yds": 17, "td_scored": 0 } } ] } ], "player": { "first_name": "Patrick", "full_name": "Patrick Mahomes", "id": "pl_026eb061f6cb9e1182c3172ab0cd97c6", "jersey_number": 15, "last_name": "Mahomes", "position": { "category": "skill", "name": "QB" }, "team": { "abbr": "KC", "city": "Kansas City", "full_name": "Kansas City Chiefs", "id": "tm_7524b771b2c4937b80349862d96e7468", "league_id": "nfl", "mascot": "Chiefs" } } }