Filtering syntax
Filtering is done either:- by using a query parameter named
queryand containing a JSON object describing the filter criteria. - by sending the filter criteria as a JSON object in the body of the request.
order:XXXX:pending
In order to get all accounts, with unique value XXXX of order segment, we use this regex-like syntax order::pending.
An address is divided into segments delimited by semi-colons
:. If a segment is empty in the filter, it is interpreted as a wildcard match. Moreover, if the filter ends with a semi-colon, it is interpreted as an open-ended wildcard.foo with the value bar.
Combining filters
The root of the filter object has always a single key. This key is the operation to apply to the filter. In order to combine filters, you can use the$and and $or operations.
Here is an example:
$and operation. The result will only include resources that match both filters.
Filtering operations reference
Operations
The following operations are supported:$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: Inverse the result of the expression. It takes an expression as parameter and returns the opposite decision. To invert the result of a$matchoperation, you can use the$notoperation like this:
Filterable fields
Depending on the resource you are querying, you can filter on different fields. Here are the exhaustive list of fields you can filter on:Accounts
address: The address of the account.metadata[XXX]: The metadata fieldXXXof the account. You can use the$existsoperator to test the existence of a metadata field, or the$matchoperator to filter on the value of a metadata field.metadata: The account metadata. You can use the$existsoperator to test whether the account has metadata or not.balance[ASSET]: The balance of the account for the assetASSET. You can use the$lt,$lte,$gt,$gte, or$matchoperators to filter on the balance.
Transactions
reference: The reference of the transaction.timestamp: The timestamp of the transaction. Note that it is the time at which the transaction has occurred, not the time at which it has been recorded in the ledger. See the reference documentation about bi-temporality for more information.reverted: Whether the transaction has been reverted or not. You can use the$matchwith the valuetrueorfalseto filter on this field.account: Either thesourceor thedestinationof the transaction. You can use the$matchoperator to filter on this field.source: The source account address of the transaction.destination: The destination account address of the transaction.metadata[XXX]: The metadata fieldXXXof the transaction. You can use the$existsoperator to test the existence of a metadata field, or the$matchoperator to filter on the value of a metadata field.metadata: The transaction metadata. You can use the$existsoperator to test whether the transaction has metadata or not.
Volumes
account: The account address of the volume. You can use the$matchoperator to filter on this field.first_usage: The timestamp of when the account was first used. You can use the$lt,$lte,$gt,$gte, or$matchoperators to filter on this field.metadata[XXX]: The metadata fieldXXXof the volume. You can use the$existsoperator to test the existence of a metadata field, or the$matchoperator to filter on the value of a metadata field.metadata: The volume metadata. You can use the$existsoperator to test whether the volume has metadata or not.balance[ASSET]: The balance of the volume for the assetASSET. You can use the$lt,$lte,$gt,$gte, or$matchoperators to filter on the balance.