Skip to content

Pagination and Queries

Most GET endpoints in the Amili API support both individual resource retrieval and paginated list retrieval:

  • Individual Resource: GET /{resource}/{id} - Returns a single resource
  • Paginated List: GET /{resource} - Returns a paginated list of resources

Pagination Response Format

When retrieving lists of resources, the API returns a paginated response with the following structure:

json
{
  "_items": [
    {
      "_id": "resource_id_1",
      "name": "Resource Name 1"
      // ... other resource fields
    },
    {
      "_id": "resource_id_2",
      "name": "Resource Name 2"
      // ... other resource fields
    }
  ],
  "_meta": {
    "total": 150,
    "max_results": 25,
    "page": 1
  }
}

Response Fields:

  • _items: Array of resource objects
  • _meta.total: Total number of resources available
  • _meta.max_results: Maximum number of results per page
  • _meta.page: Current page number

Query Parameters

GET endpoints support the following query parameters for filtering, sorting, and pagination:

Pagination Parameters

  • page: Page number (default: 1)
  • max_results: Number of results per page (default: 25, max: 100)

Filtering Parameters

  • where: JSON filter expression for filtering results
  • projection: JSON projection to specify which fields to include/exclude

Sorting Parameters

  • sort: Field name to sort by (prefix with - for descending order)

Example Query

GET /creditors?page=2&max_results=10&where={"status":"active"}&sort=name

This would return:

  • Page 2 of results
  • 10 results per page
  • Only active creditors
  • Sorted by name in ascending order