# API Pagination

A user can customize their data pagination by setting the number of items per page, specifying the sorting field and direction, and providing the `lastItemPrimary` when navigating to subsequent pages. In cases where two or more items have the same value for the sorting field, the `lastItemSecondary` can be used to help differentiate items.

| Parameter          | Description                                                                                                                                                                                                                                                                                                                                                         | Required                                          | Note                                                                                                                                                                                                                                                                           |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| limit              | Max number of items to be returned in a given page                                                                                                                                                                                                                                                                                                                  | No (default value= 10)                            | Minimum limit value is 10 and max limit value is 100                                                                                                                                                                                                                           |
| sortingField       | The field by which the list of items is sorted before it's paginated or divided into smaller, manageable sections for display.                                                                                                                                                                                                                                      | Yes (in some cases there will be a default value) | In some cases this field won't be present. In that case we are sorting by a set field, this set filed will be in API description so user knows what value to use for `lastItemPrimary`.                                                                                        |
| sortingDirection   | <p>Defines the order in which the items in a paginated list are arranged. Can take two values <code>asc</code> and <code>desc</code>.</p><ul><li><code>asc</code>(ascending): In this sorting direction, items are arranged in ascending order.</li><li><code>desc</code> (descending): In this sorting direction, items are arranged in descending order</li></ul> | Yes                                               |                                                                                                                                                                                                                                                                                |
| lastItemPrimary    | Refers to the value of the sorting field of the last item in the page of results. This value is used to determine which items are displayed on the current page and which items appear on the subsequent page when navigating through paginated data.                                                                                                               | Yes (not required to get 1st page)                |                                                                                                                                                                                                                                                                                |
| lastItemSecondary  | In cases where two or more items have the same value for the sorting field, the `lastItemSecondary` comes into play. It's an additional attribute or field that can be used to differentiate these items. I VORJ we used the objects `_id` value as this ensures uniqueness                                                                                         | No                                                |                                                                                                                                                                                                                                                                                |
| sortingMarketplace | This field is used in some of the marketplace endpoints and is used to determine which marketplace to sort by.                                                                                                                                                                                                                                                      | No (default value = all)                          | This field is used in marketplace endpoints as there is embedded information in the items returned. When using the `sortingField` parameter in these marketplace endpoints, you would specify the `sortingMarketplace` to narrow down the sorting to a particular marketplace. |


---

# 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.vorj.app/guides/api-pagination.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.
