Pagination & Sorting
Pagination
There are two optional parameters that can be used to control pagination of results: offset
and limit
. Each can be used independently, or together.
Meta Object
The meta
object is returned at the root with every paginated response payload. It contains information about the query that was performed.
{
"meta": {
"offset": 0, // default is 0
"limit": 100, // default is 100
"orderBy": [], // default is no sorting
"hasMore": Boolean // (no default)
},
results: [] // the data you requested
}
Limit
The limit
parameter is used to limit the number of results returned. For example, if you wanted to limit the results to 10, you would use limit=10
as a query string parameter in the URL. If you do not define a limit, the default is 100.
// GET https://api.getpropify.com/v1/<model_name>?limit=10
{
"meta": {
"offset": 0,
"limit": 10,
"orderBy": [],
"hasMore": true // or false
},
"results": [] // 10 results
}
Offset
The offset
parameter is used to skip results. For example, if you wanted to skip the first 10 results, you would use offset=10
as a query string parameter in the URL. If you do not define an offset, the default is 0.
The below example would skip the first 10 results, and return the next 100 results.
// GET https://api.getpropify.com/v1/<model_name>?offset=10
{
"meta": {
"offset": 10,
"limit": 100,
"orderBy": [],
"hasMore": true // or false
},
"results": [] // 100 results
}
hasMore
The hasMore
parameter is used to indicate if there are more results available. If there are more results available, the value will be true
. If there are no more results available, the value will be false
. This can be used to determine if you should make another request to get more results, or optionally increase the limit
value.
Sorting
Propify provides a sorting mechanism that can be used to sort results by one or more fields. The orderBy
parameter is used to define the sort order. The orderBy
parameter is an array of objects, where each object contains a field
and direction
property.
order-by Query String Parameter
The order-by
parameter is used to define the sort order. It is a combination of field_name
and direction
separated by a colon. For example, if you wanted to sort by the id
field in ascending order, you would use order-by=id:asc
as a query string parameter in the URL. If you wanted to sort by the id
field in descending order, you would use order-by=id:desc
as a query string parameter in the URL.
If you wanted to sort by multiple fields, you would provide a comma-separated list of fields and directions. For example, if you wanted to sort by the id
field in ascending order, and then by the name
field in descending order, you would use order-by=id:asc,name:desc
as a query string parameter in the URL.
// GET https://api.getpropify.com/v1/<model_name>?order-by=id:asc,name:desc
{
"meta": {
"offset": 0,
"limit": 100,
"orderBy": [
{
"field": "id",
"direction": "asc"
},
{
"field": "name",
"direction": "desc"
}
],
"hasMore": true // or false
},
"results": []
}