Indexing with SQD
SOON integrates with SQD to provide powerful data indexing capabilities. This guide will walk you through using SQD’s Solana API to index and query data from SOON’s networks.
Available Networks
SOON’s data is accessible through these Subsquid archives:
Understanding SQD Architecture
SQD uses a distributed worker system to efficiently serve blockchain data. Each worker handles a specific range of blocks, and queries are routed to appropriate workers through a central gateway.
Core Concepts
-
Router: The main entry point that directs queries to specific workers
-
Workers: Distributed nodes that store and serve blockchain data
-
Block Ranges: Each worker handles a specific range of blocks
-
Archive Height: The latest block available in the archive
Query Flow
1. Check Archive Height
First, verify the current height of the archive:
2. Get Worker Assignment
Request a worker URL for your desired block range:
3. Query Data
Make your data request to the assigned worker:
Example Response:
Query Options
Instruction Queries
Filter and fetch specific instruction data:
Transaction Queries
Get full transaction details:
Log Queries
Fetch program logs:
Best Practices
Handling Pagination
For large datasets, implement pagination:
Error Handling
Implement robust error handling:
Common Use Cases
Track Program Interactions
Monitor specific program activities:
Monitor Account Activity
Track account changes and interactions:
Rate Limits and Performance
-
Keep block ranges reasonable (suggested: ≤1000 blocks per query)
-
Cache worker URLs when querying consecutive blocks
-
Implement exponential backoff for retries
-
Consider using webhooks for real-time updates
TypeScript Support
SQD provides TypeScript typings for better developer experience: