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 resultsprojection: 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=nameThis would return:
- Page 2 of results
- 10 results per page
- Only active creditors
- Sorted by name in ascending order
