# 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.

{% hint style="info" %}

### Simple group limit example

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

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

{% endhint %}

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.

{% hint style="info" %}

### 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`:

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

{% endhint %}

{% hint style="info" %}

### 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:

```bash
 $ 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.
{% endhint %}

{% hint style="info" %}

### 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.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sportradar.com/personalization/overview/using-the-api/limiting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
