Last updated

Game Filters

Game filters allow you to fetch game logs and averages filtered by game attributes. To view an example project that uses this endpoint, check out our example client.

Overview

Game filters are optional. Game filters must be accompanied by a time span filter. There are two game filters you can use: is_home and h2h. You can include mutliple game filters in a single query.

Is Home Filter

The is_home returns the player's home games for the specified time span filter.

Using the is_home filter

Here is an exmaple of getting Patrick Mahomes last 5 home 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
          },
          "game_filters": [
            {
                "key": "is_home",
                "value": true
            }
          ]
      }
  ]
}'

To fetch away games, set the value on the is_home fitler to false.

Head to Head Filter

The h2h returns each of the player's games against the specified opponent for the specified time span filter.

Using the h2h filter

Here is an example of getting Patrick Mahomes game logs when he played the Las Vegas Raiders in the 2023 and 2024 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": [2023, 2024]
          },
          "game_filters": [
            {
                "key": "h2h",
                "value": "tm_6eeba998faa39796a48f4060679c63dc"
            }
          ]
      }
  ]
}'

Combining Game Filters

Game filters can be combined in the same query.

Using Combined Game Filters

Here is an example of getting all of Patrick Mahomes game logs against the Las Vegas Raiders at home for the 2023 and 2024 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": [2023, 2024]
          },
          "game_filters": [
            {
                "key": "h2h",
                "value": "tm_6eeba998faa39796a48f4060679c63dc"
            },
            {
                "key": "is_home",
                "value": true
            }
          ]
      }
  ]
}'