Getting started overview
To begin using Thunderbit's services for Solana development, the initial steps involve creating an account, generating API keys, and making a successful API call. This process establishes connectivity to the Solana blockchain via Thunderbit's infrastructure, enabling access to RPC endpoints, transaction history, and webhook functionalities for real-time monitoring and data retrieval. Thunderbit offers a free Developer Plan that includes 5 million requests per month, which is suitable for initial testing and development.
The following table provides a quick reference for the essential steps to get started:
| Step | What to do | Where to find it |
|---|---|---|
| 1. Account Creation | Register for a Thunderbit account. | Thunderbit homepage |
| 2. API Key Generation | Create a new project and retrieve your API key. | Thunderbit Dashboard (after login) |
| 3. First Request | Execute a sample Solana RPC call using your API key. | Thunderbit API overview or developer environment |
| 4. Explore Features | Review documentation for Solana RPC methods, transaction history, and webhooks. | Thunderbit documentation portal |
Create an account and get keys
Access to Thunderbit's Solana infrastructure requires an API key, which is generated after account creation. Follow these steps to set up your account and obtain the necessary credentials:
- Navigate to the Thunderbit website: Open your web browser and go to the Thunderbit homepage.
- Sign up: Locate the 'Sign Up' or 'Get Started' button, typically in the top right corner or prominent on the landing page. Provide the required information, such as your email address and a secure password. Confirm your account if an email verification step is required.
- Log in to your dashboard: After successful registration and verification, log in to your Thunderbit dashboard using your new credentials. This dashboard is your central hub for managing projects and API keys.
- Create a new project: Within the dashboard, you will typically find an option to 'Create New Project' or similar. Projects help organize your API keys and track usage for specific applications. Give your project a descriptive name.
- Retrieve your API key: Once a project is created, Thunderbit will automatically generate one or more API keys associated with it. These keys are unique identifiers that authenticate your requests to Thunderbit's services. Copy your API key and store it securely. It is common practice to treat API keys like sensitive credentials, similar to passwords, to prevent unauthorized access to your services and usage quotas. The Thunderbit documentation provides further guidance on managing API keys.
Each API key is tied to a specific project and dictates access levels and rate limits according to your chosen plan. For security best practices, avoid embedding API keys directly into client-side code or public repositories. Instead, use environment variables or a secure backend service to manage and inject your API keys into requests.
Your first request
After obtaining your API key, you can make your first request to a Thunderbit Solana RPC endpoint. This example demonstrates how to query the current slot number on the Solana blockchain using a getSlot RPC method. This method is a standard Solana RPC call, which returns the current slot number, a fundamental unit of time in the Solana blockchain.
The base URL for Thunderbit's Solana RPC typically follows a pattern like https://api.thunderbit.io/v1/solana/mainnet/{YOUR_API_KEY} for the mainnet, or similar for devnet/testnet environments. Replace {YOUR_API_KEY} with the key you generated in the previous step.
Example using cURL
This cURL command sends a JSON-RPC request to get the current Solana slot:
curl -X POST \
-H "Content-Type: application/json" \
-d '{ "jsonrpc": "2.0", "id": 1, "method": "getSlot" }' \
"https://api.thunderbit.io/v1/solana/mainnet/{YOUR_API_KEY}"
Replace {YOUR_API_KEY} with your actual Thunderbit API key. A successful response will return a JSON object containing the current slot number:
{
"jsonrpc": "2.0",
"result": 213456789,
"id": 1
}
Example using JavaScript (Node.js with node-fetch)
For JavaScript environments, you can use node-fetch or built-in fetch API (in browser or recent Node.js versions) to make the request:
const fetch = require('node-fetch'); // If using Node.js without native fetch
const apiKey = 'YOUR_API_KEY';
const rpcUrl = `https://api.thunderbit.io/v1/solana/mainnet/${apiKey}`;
async function getSolanaSlot() {
try {
const response = await fetch(rpcUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'getSlot'
})
});
const data = await response.json();
console.log('Current Solana Slot:', data.result);
} catch (error) {
console.error('Error fetching Solana slot:', error);
}
}
getSolanaSlot();
Ensure you replace 'YOUR_API_KEY' with your Thunderbit API key. This script will log the current Solana slot to your console.
Example using Python (with requests library)
The Python requests library simplifies HTTP requests:
import requests
import json
api_key = 'YOUR_API_KEY'
rpc_url = f"https://api.thunderbit.io/v1/solana/mainnet/{api_key}"
headers = {
'Content-Type': 'application/json'
}
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "getSlot"
}
try:
response = requests.post(rpc_url, headers=headers, data=json.dumps(payload))
response.raise_for_status() # Raise an exception for HTTP errors
data = response.json()
print("Current Solana Slot:", data.get("result"))
except requests.exceptions.RequestException as e:
print(f"Error fetching Solana slot: {e}")
Remember to substitute 'YOUR_API_KEY' with your actual key. This Python script will output the current slot number.
Common next steps
With a successful first request, you can expand your integration with Thunderbit's services:
-
Explore more RPC methods: The Thunderbit API documentation details various Solana RPC methods beyond
getSlot. These include fetching account information (getAccountInfo), transaction details (getTransaction), block data (getBlock), and more. Refer to the official Solana RPC API reference for a comprehensive list of available methods and their parameters. - Use transaction history: Thunderbit offers enhanced Solana transaction history. This API allows for querying past transactions for specific addresses, providing valuable data for wallets, explorers, and analytics tools.
- Implement webhooks: For real-time event notifications, integrate Thunderbit Webhooks. Webhooks can notify your application about new blocks, transactions, or account activity without constant polling, reducing resource consumption and latency. This is particularly useful for dApps requiring immediate updates.
-
Select appropriate network: Thunderbit supports Solana mainnet, devnet, and testnet. Ensure your API calls target the correct network environment for your development or production needs by adjusting the URL (e.g.,
mainnet,devnet,testnet). - Monitor API usage: Utilize the Thunderbit dashboard to track your API request usage and monitor your project's performance. This helps in managing costs and anticipating when to upgrade your plan if you exceed the Developer Plan's 5M requests/month.
-
Explore SDKs (if available): Although Thunderbit does not explicitly list official SDKs, the Solana ecosystem has various community-maintained libraries for different languages (e.g.,
@solana/web3.jsfor JavaScript/TypeScript,solana-pyfor Python) that can simplify interacting with RPC endpoints. These libraries often handle JSON-RPC formatting and provide convenient methods.
Troubleshooting the first call
If your initial API call to Thunderbit does not succeed, consider the following common issues and troubleshooting steps:
- Incorrect API Key: Double-check that you have copied the full and correct API key from your Thunderbit dashboard. An invalid or truncated key will result in an authentication error, typically an HTTP 401 (Unauthorized) response. Ensure there are no extra spaces or characters.
-
Incorrect Endpoint URL: Verify that the base URL for your API call matches the Thunderbit RPC endpoint exactly, including the correct network (e.g.,
mainnet,devnet,testnet) and that your API key is correctly embedded in the path, if that is the required authentication method. Consult the Thunderbit API overview for the exact endpoint structure. -
JSON-RPC Payload Errors: The JSON payload sent in your POST request must conform to the JSON-RPC 2.0 specification. Ensure the
jsonrpcfield is"2.0", theidis a number, and themethodfield contains a valid Solana RPC method name (e.g.,"getSlot"). Missing or malformed fields will lead to parse errors or invalid request responses. -
Content-Type Header: Ensure your request includes the HTTP header
Content-Type: application/json. This header informs the server that the request body is in JSON format, which is required for JSON-RPC requests. -
Network Connectivity: Confirm that your development environment has stable internet access and is not blocked by a firewall or proxy from reaching
api.thunderbit.io. Test connectivity with a simplepingortraceroutecommand if necessary. - Rate Limits Exceeded: While less likely on a first call, if you are quickly iterating or have other processes using the same API key, you might hit rate limits. Thunderbit's free Developer Plan allows 5 million requests per month. Check your dashboard for usage statistics. If you receive an HTTP 429 (Too Many Requests) error, wait a short period before retrying.
- Referencing Documentation: If an error message is returned, cross-reference it with the Thunderbit documentation or the generic Solana RPC error codes to understand its specific meaning and recommended resolution.