Trending Insights API
Trending insights allows you to fetch hundreds of engaging player stat trends compared to real-time handicaps. To view an example project that uses this endpoint, check out our example client.
Overview
Anytime's Trends API lets you fetch hundreds of player trends. You can filter responses by
- Fetch for trends by league, game, team or player
- Configure maximum results for a given player or stat to ensure an even distribution of trends.
The Player Trend Object
Here is an exmaple player trend object that would get returned from Anytime's Trend API.
{ "entity": { "first_name": "Roman", "full_name": "Roman Josi", "id": "pl_51693e396932cb6fafdfd2590ff408ee", "jersey_number": 59, "last_name": "Josi", "position": { "category": "skater", "name": "D" }, "team": { "abbr": "NSH", "city": "Nashville", "full_name": "Nashville Predators", "id": "tm_57b2264b6932cb6fafdfd2590ff408ee", "league_id": "nhl", "mascot": "Predators" } }, "entity_trend_condition": { "game_filters": [], "time_span": { "key": "last_n", "value": 5 } }, "entity_trend_readable_string": "Roman Josi had over 3.5 Shots on Goal in 5 of the last 5 games", "entity_trend_stats": { "average": 4.4, "hits": 5, "misses": 0, "push": 0, "total": 5 }, "entity_type": "player", "game": { "away_team": { "abbr": "NSH", "city": "Nashville", "full_name": "Nashville Predators", "id": "tm_57b2264b6932cb6fafdfd2590ff408ee", "league_id": "nhl", "mascot": "Predators" }, "game_time": "2024-11-08T00:00:00Z", "home_team": { "abbr": "FLA", "city": "Florida", "full_name": "Florida Panthers", "id": "tm_57bc23b16932cb6fafdfd2590ff408ee", "league_id": "nhl", "mascot": "Panthers" }, "id": "gm_68cc7a4d70269b56ac3541a655692e1f", "league_id": "nhl" }, "handicap": 3.5, "id": "tr_7556e1b2bb888b8bb638dce916939a73", "league_id": "nhl", "stat": { "entity_type": "player", "key": "shots", "position_categories": [ "skater" ], "title": "Shots on Goal" }, "stat_result": "over", "updated": "2024-11-07T18:46:06Z" }
entity
: The information of the entity the trend is about. For player trends, this will contain player information including name, position, current team, and more.entity_trend_condition
: This object contains the filters for the given trend. These filters follow the same schema as our time span and game filters.entity_trend_readable_string
: The plain english, readable string to represent the trend.entity_trend_stats
: This object holds the number relavant to the trend including number of hits + number of misses for the trend time span, and average for the given stat for the trend time span.handicap
: The handicap against which this trend is compared.stat
: Information about the stat behind this trend including key, title, and position category for which this stat is relevant.game
: This object hold the relevant information for the upcoming game including home team info, away team info and game time.
Fetch all trends
To fetch all available trends, with no filtering, make the following request.
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{}'
This will return all available trends from all leagues. This might return a very large object depending of the number of upcoming events, so we recommend including filters with the request.
Fetch League Trends
Fetch all trends for one or multiple leagues.
Use the following curl
command to fetch NHL player trends.
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{ "leagues": ['nhl'] }'
Fetch Trends For Specific Games
You can fetch trends for specific upcoming games by including an array of game_id strings with the request. (Since the game_id in the example is old, this will not return any results, it is just an example.)
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{ "leagues": ['nhl'], "game_ids": [ "gm_68cc7a4d70269b56ac3541a655692e1f" ] }'
You can include one or many game_id strings in the game_ids
array.
Fetch Trends For Specific Players
You can fetch trends for specific players by including an array of entity_id strings with the request. (This request will not return any results, it is just an example.)
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{ "leagues": ['nhl'], "entity_ids": [ "pl_51693e396932cb6fafdfd2590ff408ee" ] }'
You can include one or many entity_id strings in the entity_ids
array.
Fetch Trends For Specific Stats
You can fetch trends for specific stats by including an array of stat_key strings with the request.
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{ "stat_keys": [ "assists" ] }'
You can include one or many stat_key strings in the stat_keys
array.
Trend Filters
You can limit the number and distribution of returned trends in a few way. These filters can be used by themselves or in combination with other filters.
Maximum Results
You can specify a max_results
field to limit the number of results.
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{ "max_results": 100 }'
Maximum Results Per Player
You can specify the maximum trends returned for each entity. This can be helpful when fetching many trends at once, to ensure an even distribution of trends across players.
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{ "max_results_per_entity": 2 }'
Maximum Results Per Player + Stat Combo
Sometimes players have mutliple trends for the same stat. For example: Patrick Mahomes has gone over 225.5 passing yards in 4/L5 games.
and Patrick Mahomes has gone over 225.5 passing yards in 8/L10 games.
Since both trends can be returned from the same request, you can limit the number of trends for each player + stat combination.
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{ "max_results_per_entity_stat_key": 2 }'
Combining filters
You can combine any and all filters above in a single query. Here is an example:
curl -X POST https://api.anytimelabs.io/v1beta/trends \ -H "Content-Type: application/json" \ -d '{ "leagues": ["nba", "nhl"], "stat_keys": ["points"], "max_results": 50, "max_results_per_entity": 2, "max_results_per_entity_stat_key": 1 }'