Limiting

Group limiting

The API provides a generic system to limit the returned items per group.

To limit the number of items that belong to a certain group, simply add the group_limit=[group]:[limit] query parameter to the url of the endpoint.

Simple group limit example

In this example we get at most 5 popular events per sport:

$ curl --request GET \\
  --url 'https://api.vaix.ai/api/sports/events/popular?group_limit=sport:5'

Not all endpoints support group limit. If group limiting is available for an endpoint, then the supported grouping fields are indicated in the documentation of that endpoint.

Prioritized limiting

The API provides a generic system to apply prioritization limits to the returned items.

This is similar to group limiting, with the difference that it applies the limit on specific values of the result set, while the limits can vary per value. Also, the limited items are ensured to be present in the result set.

To limit the number of items that belong to a certain group, simply add the prioritized_limit=[field]:[value]=[limit] query parameter to the url of the endpoint.

Prioritized limit example on event status

In this example, we get the 5 most popular events, ensuring that up to 3 are live and up to 2 are prematch:

$ curl --request GET \\
  --url 'https://api.vaix.ai/api/sports/events/popular?count=5&prioritized_limit=status:live=3,not_started=2'

Prioritized limit example on event's sport values

In this example, we get the 10 most popular events, ensuring that up to 3 are football events and up to 2 are basketball events:

 $ curl --request GET \\
  --url 'https://api.vaix.ai/api/sports/events/popular?count=10&prioritized_limit=sport:football=3,basketball=2'

Notice that since we request the 10 most popular events, the total number of events returned will be 10, with the number of football and basketball events being at most 3 and 2 respectively.

Order of the final results

Notice that in both cases the initial order of the events will be preserved.

The parameters are applying the needed limits without changing the relative order between the items of the resulted set.

Was this helpful?