How to build your query filter ?
Last updated: February 21, 2025
In order to help you filter data out from our various endpoints, a filter can be added as a parameter to the request. Key of this parameter is query.
Another option is to add it into resquet's body. The value is a JSON object, taking the following operators:
$and/$or: Takes expression arrays as parameters.$match: Equality operator. Takes an object containing a single key/value pair as parameter.$lt: Lower. Same format as $match.$lte: Lower or equal. Same format as $match.$gt: Greater. Same format as $match.$gte: Greater than or equal to. Same format as $match.$exists: test the existence of a metadata$not
Here is an example:
With parameter:
?query={"$match": { "account": "order::pending" }}In the body:
{
"$match": { "source": "order::pending" }
}In this example, we are filtering on a ledger account. The naming convention set on this account is the following: order:XXXX:pending
In order to get all accounts, with unique value XXXX of order segment, we use this regex-like syntax order::pending equivalent to .*
or for a metadata
{ "$match": { "metadata[foo]": "bar"} }Except for $and and $or, all operators take a single object as parameter, containing a single key and therefore a single value.
example of $and / $or
{
"$and": [
{
"$match": { "reference": "123" }
},
{
"$match": { "metadata[foo]": "bar" }
}
]
}