Skip to main content

Index

Request

HTTP MethodGET
Path/resource
BodyNo body

Field Name

The "Field Name" is a crucial component of a RESTful API's request and response structure. It serves multiple purposes, including searching, filtering, and sorting of resources. Each field name corresponds to a specific data attribute within the resource object. The convention for field naming uses dot separators to traverse nested objects within the resource hierarchy.

Example:

{
"name": "", -> field name = name
"vehicle": { -> field name = vehicle
"id": "", -> field name = vehicle.id
"license_plate": "", -> field name = vehicle.license_plate
"type": {
"name": "" -> field name = vehicle.type.name
}
}
}

In the given example, field names like "name," "vehicle," "vehicle.id," "vehicle.license_plate," and "vehicle.type.name" represent various levels of data hierarchy within the API. These field names are used to interact with and manipulate the resource data.

Operation

A searchable index has SEARCHABLE label. Use the "search" key to specify the desired search value in the query parameter.

Pagination

A paginable index has PAGINATABLE label. To paginate through a resource, include the "limit" key to specify results per page and the "page" key to indicate the desired page number in the query parameter. The response will include the pagination details (count, page, total count, and total page) & results.

Filter

A filterable index has FILTERABLE label. A resource can be filtered with multiple conditions. To apply it, use the "filters" key and the value in the format of {field name} {operator} {value}. Here are the available operators along with an example for the "filter" value:

OperatorDescriptionExample
eqEqualname eq 'John'
ltLess thanage lt 18
lteLess than equalage lte 18
gtGreater thanage gt 18
gteGreater than equalage gte 18
inInname in ('John', 'Doe') age in (1, 5, 10, 20)

Sort

A sortable index has SORTABLE label. Sort can be applied for multiple fields. To apply it, use the “sorts” key and the value in the format of {field name} {sort operator}. Sort operator can be asc or desc and case insensitive.

Success Response

The response status code will be 200.

The response body format for the normal Index is:

{
"data": [
{...resource...}
]
}

The response body format for the Index with pagination is:

{
"metadata": {
"count": 5,
"page": 1,
"total_count": 100,
"total_page": 20
},
"data": {
"paginated_result": [{...resource...}], // Array containing the paginated results
"ids": [...ids...], // Array containing all results ids
}
}