Filter & Sort
To query a list of entities, it is possible to specify what kind of entities to return and in what order.
Query filters
The filtering conditions can be set using the parameter filter.
The filters must be given as a JSON string.
{
"int_field": {"$eq": 100},
"id": {"$in": [2, 3, 5]}
}
The JSON string needs to be URL-encoded as one-line string.
The operators include: |Operator|equivalent| |-|-| |=|=| |eq|=| |neq|<>| |gt|>| |lt|<| |gte|>=| |lte|<=| |in|IN|
- Note that the $ symbol is optional.
- $or is not supported.
Example filter fields with various operators.
curl /v2/payins?filter={"age":{"$gt":18},"name":"Adam","score":{"$lte":50}}
Sorting
Sorting can be specified on one or more fields using the sort parameter.
There are two formats for sorting fields.
JSON format
[{"asc_field":1},{"desc_field":-1}]or
{"asc_field":1,"desc_field":-1}The first variant sets the first field as primary and the second field the secondary sorting field, while the latter format is not suitable for such order.
Plain format
<asc_field>,-<desc_field>,...
Sort by currency in ascending order and then created_at by descending order.
curl /v2/payins?sort=currency,-created_at