Skip to main content

List Queries

A list query targets a single type of object - keys, accounts, flavors, transactions, actions, or tokens - and returns a paginated set of results.

You can add a filter to narrow the results.

Examples

The following examples each retrieve the first two pages of results, with 10 results per page. For details on iterating through all results, see iterating results.

Accounts

List accounts with checking as the value for type in the tags.

Account.Page page1 = new Account.ListBuilder()
.setFilter("tags.type=$1")
.addFilterParameter("checking")
.setPageSize(10)
.getPage(ledger);
for (Account account : page1.items) {
...
}

String cursor = page1.cursor;

Account.Page page2 = new Account.ListBuilder()
.getPage(ledger, cursor);
for (Account account : page2.items) {
...
}

Transactions

List transactions for Alice's account.

Transaction.Page page1 = new Transaction.ListBuilder()
.setFilter("actions(sourceAccountId=$1 OR destinationAccountId=$1)")
.addFilterParameter("alice")
.setPageSize(10)
.getPage(ledger);
for (Transaction tx : page1.items) {
...
}

String cursor = page1.cursor;

Transaction.Page page2 = new Transaction.ListBuilder()
.getPage(ledger, cursor);
for (Transaction tx : page2.items) {
...
}

Actions

List actions that issued USD to Alice's account.

Action.Page page1 = new Action.ListBuilder()
.setFilter("destinationAccountId=$1 AND flavorId=$2 AND type=$3")
.addFilterParameter("alice")
.addFilterParameter("usd")
.addFilterParameter("issue")
.setPageSize(10)
.getPage(ledger);
for (Action action : page1.items) {
...
}

String cursor = page1.cursor;

Action.Page page2 = new Action.ListBuilder()
.getPage(ledger, cursor);
for (Action action : page2.items) {
...
}

Tokens

List tokens with date as the value for due in the tags.

Note: This endpoint does not return individual token objects, but rather token group objects, which each represent an amount of identical tokens.

TokenGroup.Page page1 = new Token.ListBuilder()
.setFilter("tags.due=$1")
.addFilterParameter("date")
.setPageSize(10)
.getPage(ledger);
for (TokenGroup tokenGroup : page1.items) {
...
}

String cursor = page1.cursor;

TokenGroup.Page page2 = new Token.ListBuilder()
.getPage(ledger, cursor);
for (TokenGroup tokenGroup : page2.items) {
...
}