Last updated

Time Span Filtering

Time Span filtering allows you to fetch game logs and averages filtered by time. To view an example project that uses this endpoint, check out our example client.

Overview

There are three time span filters you can use: last_n, seasons, and all. Each game logs and averages query must have one time span filter. Only one time span filter can be used at a time. Time span filters can be used with game filters.

Last N Filter

The last_n time span filter returns the n game logs that the given player has played in. The returned game logs can span multiple seasons.

Using the last_n filter

Here is an exmaple of getting Patrick Mahomes last 5 game logs.

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": "last_n",
              "value": 5
          }
      }
  ]
}'

Any number can be used in the filter. Should the filter number exceed the maximum number of matching games, the maximum number of games will be returned.

Seasons Filter

The seasons filter returns all games from the seasons provided in the seasons array. One or multiple seasons can be provided.

Using the seasons filter

Here is an example of getting Patrick Mahomes games from current season (2024).

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]
          }
      }
  ]
}'

Here is an example of getting Patrick Mahomes games from the 2021, 2022, and 2023 seasons.

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": [2021, 2022, 2023]
          }
      }
  ]
}'

All Filter

This filter returns all available games.

Using the all filter

Here is an example of all available Patrick Mahomes game logs.

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": "all",
              "value": null
          }
      }
  ]
}'