Pagination

Efficiently managing large datasets is crucial for maintaining API performance and scalability. Our APIs employ a robust pagination mechanism to deliver data in smaller, manageable portions. This improves response times and client-side processing, particularly for applications that load results incrementally.


Pagination in our APIs


Instead of returning the entire dataset in a single response, which can strain resources, clients can request specific subsets of data. This improves response times and enables smoother data handling, particularly for applications that load results incrementally.

We support two query parameters for pagination:

  • page (integer): Specifies the page number to retrieve. The default value is 1.
    • Negative values are invalid and will result in an error.
  • limit (integer): Defines the maximum number of items per page. The default value is 10.

For example, to retrieve the first page of organizations with a maximum of 10 items per page:

GET /v1/organizations?page=1&limit=10

Pagination response

The pagination response includes the following structure:

  • items: An array of entities retrieved for the current page. Each object contains detailed information about the resource requested, as shown in the example below.
  • page: The current page number, starting from 1 (default).
  • limit: The maximum number of items included in the response, as defined in the request or default configuration.

Below is an example response for a paginated request:

{
    "items": [
        {
            "id": "0193696f-8eff-7926-a77a-0b424cf7156b",
            "parentOrganizationId": null,
            "legalName": "Collins Inc",
            "doingBusinessAs": "The ledger.io",
            "legalDocument": "78425230000190",
            "address": {
                "line1": "Avenida Paulista, 1234",
                "line2": "CJ 203",
                "zipCode": "01310916",
                "city": "New Lyla",
                "state": "CH",
                "country": "FO"
            },
            "status": {
                "code": "ACTIVE",
                "description": "Ledger Test"
            },
            "createdAt": "2024-11-26T17:05:39.071587Z",
            "updatedAt": "2024-11-26T17:05:39.071587Z",
            "deletedAt": null,
            "metadata": {
                "bitcoinn": "3QH2XV7JxMRKXDqh87JG7LWuf7AeGfy",
                "boolean": true,
                "chave": "metadata_chave",
                "double": 10.5,
                "int": 1
            }
        }
    ],
    "page": 1,
    "limit": 1
}


Maximum page size


By default, API endpoints that support pagination accept a maximum of 100 items per page (limit=100). This restriction helps ensure optimal performance and avoids excessive payload sizes.

If your use case requires retrieving a larger number of items per request, you can override this limit by setting the MAX_PAGINATION_LIMIT environment variable in your deployment configuration ( .env file).

🚧

Important

Increasing the pagination limit may result in slower response times depending on the volume of data and infrastructure conditions. Be sure to test thoroughly in staging environments before applying the change in production.

To update this configuration in Kubernetes:

kubectl edit configmap midaz-transaction -n midaz

# Set the new value for MAX_PAGINATION_LIMIT

kubectl rollout restart deployments midaz-transaction -n midaz

This behavior is inherited by Midaz and all its plugin services.