Summary
The Solana explorer API is the JSON-RPC interface that powers block explorers and lets developers query transactions, accounts, and blocks. This article explains how to use it for debugging and analytics, and how to choose a reliable RPC provider for production workloads.
Quick decision guide: which Solana API should you use?
Before you write any code, decide whether you need a public RPC endpoint, a managed API service, or a dedicated node. The choice depends on your workload:
- Prototyping or light testing: a public endpoint like
https://solana.api.onfinality.io/publicis fine for occasional requests. - Production dApp or indexer: you need a reliable, scalable RPC provider with high throughput and low latency. OnFinality's managed Solana RPC offers shared and dedicated options.
- Heavy analytics or archival data: consider a dedicated node or a provider with archive data support.
For most production use cases, a managed RPC service is the right fit because it handles infrastructure, scaling, and failover. If you need full control or custom configuration, a dedicated node might be better. Review RPC pricing to compare options.
What is the Solana explorer API?
The Solana explorer API is the JSON-RPC interface that block explorers like Solana Explorer use to fetch on-chain data. It allows you to query transactions, accounts, blocks, and network status. Developers use it to build dashboards, monitor activity, and debug applications.
The API is essentially the same as the standard Solana RPC API. The term "explorer API" often refers to the read-only methods that power explorer features, such as getTransaction, getAccountInfo, and getBlock. These methods are part of the Solana JSON-RPC specification.
Key methods for exploring Solana data
Here are the most useful methods for inspecting on-chain data:
| Method | Description | Use case |
|---|---|---|
getTransaction | Fetch a transaction by signature | Verify a transaction's status and details |
getAccountInfo | Get account balance and data | Check token balances or program state |
getBlock | Retrieve a block by slot | Analyze block contents and rewards |
getSignaturesForAddress | List transaction signatures for an address | Show transaction history for an account |
getBalance | Get SOL balance of an account | Quick balance checks |
getLatestBlockhash | Get the latest blockhash | Prepare transactions |
These methods are read-only and do not require sending transactions. They are ideal for building explorers, analytics tools, and monitoring systems.
How to call the Solana explorer API
You can call the Solana JSON-RPC API using any HTTP client. Here's a curl example to get a transaction by signature:
curl https://solana.api.onfinality.io/public \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTransaction",
"params": [
"2mN7Z1mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3",
{
"encoding": "jsonParsed",
"maxSupportedTransactionVersion": 0
}
]
}'
Replace the signature with a real one from the explorer. The jsonParsed encoding gives human-readable JSON instead of raw binary.
Using the API in JavaScript
For JavaScript applications, you can use the official @solana/web3.js library. Here's an example of fetching a transaction:
import { Connection, PublicKey } from '@solana/web3.js';
const connection = new Connection('https://solana.api.onfinality.io/public');
const signature = '2mN7Z1mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3mQmZ3';
const tx = await connection.getParsedTransaction(signature, {
maxSupportedTransactionVersion: 0
});
console.log(tx);
This gives you a parsed transaction object with account keys, instructions, and balances.
Common pitfalls when using the explorer API
- Rate limits: Public endpoints often have rate limits. If you make many requests, you may get 429 errors. Use a managed provider with higher limits for production.
- Transaction version: Newer Solana transactions may use version 0. Always set
maxSupportedTransactionVersionto 0 to avoid errors. - Encoding: Use
jsonParsedfor readable data, but be aware it may be slower thanbase58for large payloads. - Slot lag: Data may not be immediately available after a transaction. Wait a few seconds before querying.
How to choose a Solana RPC provider for explorer-like workloads
If you're building an explorer or analytics tool, you need a provider that can handle high read throughput. Consider these factors:
| Factor | What to check | Why it matters |
|---|---|---|
| Throughput | Requests per second (RPS) limits | High traffic needs high RPS |
| Latency | Response time from different regions | Low latency improves user experience |
| Reliability | Uptime history and failover | Avoid downtime |
| Data retention | Archive data availability | Historical queries need archive nodes |
| WebSocket support | Real-time subscriptions | Live updates for explorers |
OnFinality offers Solana RPC endpoints with HTTP and WebSocket support. You can start with a shared endpoint and upgrade to a dedicated node as your traffic grows.
Debugging with the explorer API
When a transaction fails, the explorer API can help you diagnose the issue. Use getTransaction to inspect the error message and logs. For example, a failed transaction will have an err field in the response.
You can also use getSignaturesForAddress to see recent transactions for an account and check their statuses. This is useful for monitoring and debugging.
Key Takeaways
- The Solana explorer API is the JSON-RPC interface for reading on-chain data.
- Use methods like
getTransaction,getAccountInfo, andgetBlockto inspect data. - Public endpoints are fine for testing, but production apps need a reliable provider.
- Choose a provider based on throughput, latency, reliability, and data retention.
- OnFinality provides managed Solana RPC and dedicated nodes for scalable infrastructure.
Frequently Asked Questions
What is the difference between the Solana explorer API and the RPC API?
The explorer API is essentially the same as the RPC API. It refers to the read-only methods used by block explorers to fetch data.
Can I use the explorer API to send transactions?
No, the explorer API is read-only. To send transactions, you need to sign and submit them via the RPC API.
How do I get a Solana RPC endpoint?
You can use a public endpoint like https://solana.api.onfinality.io/public or sign up for a managed service at OnFinality.
Does OnFinality support Solana devnet?
Yes, OnFinality provides Solana devnet RPC for testing.
What is the best way to monitor Solana transactions?
Use WebSocket subscriptions to get real-time updates, or poll the RPC API with getSignaturesForAddress.