List Accounts
Query multiple accounts with filtering, sorting, and pagination.
Query Structureβ
query GetAccounts(
$where: accounts_bool_exp
$order_by: [accounts_order_by!]
$limit: Int
$offset: Int
) {
accounts(
where: $where
order_by: $order_by
limit: $limit
offset: $offset
) {
id
label
image
type
created_at
}
accounts_aggregate(where: $where) {
aggregate {
count
}
}
}
Variablesβ
{
"where": {
"type": { "_eq": "AtomWallet" }
},
"order_by": [{ "created_at": "desc" }],
"limit": 20,
"offset": 0
}
Response Fieldsβ
| Field | Type | Description |
|---|---|---|
id | String | Account address |
label | String | Human-readable name |
image | String | Profile image URL |
type | String | Account type |
created_at | DateTime | First interaction timestamp |
Interactive Exampleβ
Query
query GetRecentAccounts($limit: Int!) {
accounts(
order_by: { created_at: desc }
limit: $limit
) {
id
label
image
type
created_at
}
}Variables
Click "Run Query" to execute the GraphQL query and see results
Use Casesβ
Search Accountsβ
Search accounts by label:
async function searchAccounts(searchTerm: string, limit: number = 20) {
const query = `
query SearchAccounts($search: String!, $limit: Int!) {
accounts(
where: { label: { _ilike: $search } }
order_by: { label: asc }
limit: $limit
) {
id
label
image
type
}
}
`
const data = await client.request(query, {
search: `%${searchTerm}%`,
limit
})
return data.accounts
}
Paginated Account Listβ
async function getAccountsPaginated(page: number, pageSize: number = 20) {
const query = `
query GetAccountsPaginated($limit: Int!, $offset: Int!) {
accounts(
order_by: { created_at: desc }
limit: $limit
offset: $offset
) {
id
label
image
type
created_at
}
accounts_aggregate {
aggregate {
count
}
}
}
`
const data = await client.request(query, {
limit: pageSize,
offset: (page - 1) * pageSize
})
return {
accounts: data.accounts,
total: data.accounts_aggregate.aggregate.count,
page,
pageSize,
totalPages: Math.ceil(data.accounts_aggregate.aggregate.count / pageSize)
}
}
Filtering Optionsβ
By Typeβ
# Only AtomWallet accounts
accounts(where: { type: { _eq: "AtomWallet" } })
# Exclude protocol vaults
accounts(where: { type: { _neq: "ProtocolVault" } })
By Labelβ
# Case-insensitive search
accounts(where: { label: { _ilike: "%vitalik%" } })
# Exact match
accounts(where: { label: { _eq: "vitalik.eth" } })
By Dateβ
# Accounts created after date
accounts(where: {
created_at: { _gte: "2024-01-01T00:00:00Z" }
})
Best Practicesβ
- Use pagination - Always limit results for large datasets
- Include aggregate - Get total count for pagination UI
- Use indexes - Filter by indexed fields (type, created_at)
- Case-insensitive search - Use
_ilikefor label searches
Relatedβ
- Single Account - Query individual accounts
- Following - Social relationships
- Aggregations - Aggregate patterns