Skip to main content
In this guide, you’ll learn how to retrieve claim events for a Solana token using the Bags TypeScript SDK. The endpoint supports two query modes: offset-based pagination for traditional page-by-page retrieval, and time-based filtering for fetching events within a specific time range.

Prerequisites

Before starting, make sure you have:

Endpoint Used Under the Hood

This guide uses:

Query Modes Overview

1. Offset Mode (Pagination)

Use offset mode to paginate through claim events. This is the default mode and is backward compatible with previous API versions.

Script: Paginated Claim Events

Save this as get-claim-events-paginated.ts:
get-claim-events-paginated.ts

Run the Script

2. Time Mode (Time-Based Filtering)

Use time mode to retrieve all claim events within a specific time range. This is useful for analytics, generating reports, or syncing historical data.

Script: Time-Based Claim Events

Save this as get-claim-events-by-time.ts:
get-claim-events-by-time.ts

Run the Script

Example Output

Offset Mode Output

Time Mode Output

SDK Function Reference

The sdk.state.getTokenClaimEvents() function accepts a token mint and an options object:

Return Type

Each event in the returned array has the following structure:

Use Cases

Offset Mode

  • Paginated UIs: Display claim events in a table with β€œLoad More” or page navigation
  • Real-time Feeds: Show the latest claims as they happen
  • Infinite Scroll: Load more events as the user scrolls

Time Mode

  • Weekly/Monthly Reports: Generate reports for specific time periods
  • Analytics Dashboards: Show claim activity over custom date ranges
  • Auditing: Review all claims that occurred during a specific period
  • Data Sync: Sync historical claim data to your database

Alternative: Using the Bags CLI

This section requires the Bags CLI. See Install and Set Up the Bags CLI to get started.
Query claim events and stats directly from the terminal: Offset-based pagination:
Time-based filtering:
Aggregated claim stats:
Use --json to pipe the output into other tools for analysis:

Error Handling

Common errors to handle:
When using time mode, the from timestamp must be less than or equal to to. The API validates this constraint and returns an error if violated.