Prerequisites
Before starting, make sure you have:- Completed our TypeScript and Node.js Setup Guide.
- Got your API key from the Bags Developer Portal.
- The token mint address you want to analyze.
Endpoint Used Under the Hood
This guide uses:GET /fee-share/token/claim-eventsviasdk.state.getTokenClaimEvents()
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 asget-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 asget-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
Thesdk.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.
--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.Related Guides
- Get Token Lifetime Fees - Get total fees earned by a token
- Get Token Creators - Find token launch creators
- Claim Fees - Claim your earned fees
