getFirstAvailableBlock
Returns the slot of the lowest confirmed block that has not been purged from the ledger
Common use cases
| Data Pipeline Initialization | Determine the earliest available slot when bootstrapping an indexer, analytics system, or data pipeline to avoid requesting blocks that have been pruned from the ledger. |
| Block Range Validation | Validate that a target slot or block range falls within the available ledger history before attempting to fetch block data, preventing unnecessary RPC calls. |
| Ledger Retention Monitoring | Monitor cluster retention policies by tracking the first available block over time to understand data availability windows and plan archival strategies. |
Parameters
No parameters required.
Request
- cURL
- JavaScript
- Python
curl https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getFirstAvailableBlock"
}'
// Using fetch
const response = await fetch('https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "getFirstAvailableBlock"
})
});
const data = await response.json();
console.log(data);
import requests
import json
url = 'https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
data = {
"jsonrpc": "2.0",
"id": 1,
"method": "getFirstAvailableBlock"
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Replace mainnet with devnet in the URL to query devnet instead.
Response
{
"jsonrpc": "2.0",
"result": 250000,
"id": 1
}
Response Fields
Return value: u64
Slot
FAQ and Troubleshooting
What's the difference between getFirstAvailableBlock and minimumLedgerSlot?
Both methods return the oldest slot available on the node, but they query different storage layers. getFirstAvailableBlock queries the long-term storage (BigTable) for the first confirmed block that hasn't been purged, while minimumLedgerSlot queries the validator's local ledger. For RPC nodes with deep historical storage, getFirstAvailableBlock typically returns a much older slot.
Can getFirstAvailableBlock return null?
No. The method returns a u64 slot number. If no blocks are available in storage (which would only occur in catastrophic scenarios), the RPC call would fail rather than return null. In practice, all production RPC nodes have at least some block history available.
Related Methods
minimumLedgerSlot
Returns the oldest slot in the validator's local ledger, complementary to getFirstAvailableBlock which queries long-term storage
getSlot
Returns the most recent slot processed by the node, forming the upper bound of the available block range
getBlock
Fetches detailed block data for a specific slot; use getFirstAvailableBlock to determine valid slot range before calling getBlock