Ledger objects in Sequence are represented as key-value JSON objects. To retrieve data, you perform a query with optional parameters.
There are two types of queries: list queries and sum queries.
A list query returns a time-ordered set of objects beginning with the most recent. All objects support the list query.
For details and examples, see List Queries.
A sum query is an aggregate over the amount fields in a list of objects. Only actions and tokens support the sum query.
For details and examples, see Sum Queries.
The primary query parameter is a filter, which allows targeting specific fields in a set of objects.
For details and examples, see Filters.
Sum queries on actions and tokens also accept a group by query parameter that indicates how amounts should be summed.
The query will sum the amounts in the resulting set of actions or tokens where the values of the "group" field are identical. This is analogous to the "GROUP BY" clause in SQL.
Results of all queries are paginated. There are two methods for handling these:
- Retrieving a page of results at a time – useful for implementing pagination in an end-user application, such as infinite scroll.
- Iterating though individual results - useful for processing results in an application, such as generating a report (where pages are incidental).
For details and examples, see Pagination.