Pagination & Filtering
All list endpoints in the AnySpend Platform API return paginated responses. This page covers how to navigate large result sets, filter data, and sort results.List response format
Every list endpoint returns a consistent envelope:| Field | Type | Description |
|---|---|---|
object | string | Always "list" for list responses. |
data | array | The array of resource objects for the current page. Each item includes its own object type field. |
has_more | boolean | true if there are more results beyond this page. Use this to determine whether to fetch the next page. |
total_count | number | The total number of matching resources across all pages. |
url | string | The API endpoint path for this list. |
Pagination parameters
Usepage and limit query parameters to navigate through results.
| Parameter | Type | Default | Max | Description |
|---|---|---|---|---|
page | integer | 1 | — | The page number to retrieve (1-indexed). |
limit | integer | 20 | 100 | The number of results per page. |
Basic pagination example
Navigating pages
Use thehas_more field to determine when to stop paginating:
Filtering
Most list endpoints support query parameters for filtering results. The available filters depend on the resource type.Payment Links
| Parameter | Type | Description |
|---|---|---|
search | string | Search by name or short code (partial match). |
active | "true" or "false" | Filter by active/inactive status. |
Checkout Sessions
| Parameter | Type | Description |
|---|---|---|
status | "active", "completed", "expired" | Filter sessions by status. |
Transactions
| Parameter | Type | Description |
|---|---|---|
status | string | Filter by transaction status. |
chain_id | number | Filter by blockchain network. |
Sorting
List endpoints that support sorting acceptsort and order parameters.
| Parameter | Type | Default | Description |
|---|---|---|---|
sort | string | created_at | The field to sort by. Allowed values vary by resource. |
order | "asc" or "desc" | desc | Sort direction. |
Payment Links sort fields
| Field | Description |
|---|---|
created_at | When the payment link was created (default). |
updated_at | When the payment link was last modified. |
name | Alphabetical by name. |
current_uses | Number of completed checkouts. |
Auto-pagination example
For convenience, you can build an async iterator that handles pagination automatically:Counting results
Usetotal_count from any page to get the total number of matching resources without fetching all pages:
limit=1 minimizes the response payload when you only need the count.
Best practices
Use limit=100 for bulk operations
Use limit=100 for bulk operations
When you need to fetch all records (e.g., for data export or sync), use the maximum
limit=100 to minimize the number of API calls and stay within rate limits.Use has_more instead of total_count for pagination loops
Use has_more instead of total_count for pagination loops
has_more is the authoritative signal for whether to fetch the next page. Avoid computing page counts from total_count as the total can change between requests.Cache total_count for UI pagination controls
Cache total_count for UI pagination controls
When building pagination UI (e.g., “Page 3 of 8”), fetch
total_count once and cache it for the session. Re-fetch only when the user refreshes or applies new filters.Combine filters with pagination
Combine filters with pagination
Apply filters before paginating to reduce the result set. This is more efficient than fetching all records and filtering client-side:
Respect rate limits during bulk fetches
Respect rate limits during bulk fetches
If you are paginating through a large dataset, be mindful of the 120 requests/min rate limit. For very large datasets, add a short delay between page requests:
HypeDuel