getBlockHeight
https://api.triport.io/v1/solReturns the current block height of the node — the number of confirmed blocks beneath the latest confirmed block.
getBlockHeight returns the current block height as a u64 integer. The block
height is the count of confirmed blocks below the current block — it
increments by one for every block that is actually produced.
Use it when you need a monotonic, gap-free measure of chain progress. A common
use is to compare a transaction's lastValidBlockHeight against the current
height to decide whether the transaction's blockhash has expired.
Distinguish from getSlot: block height counts only the blocks that were
produced, while a slot is a fixed ~400 ms time unit that advances even when its
leader skips block production. Because skipped slots increment the slot but not
the block height, the slot value is always greater than or equal to the
block height.
All Solana JSON-RPC methods POST to the same base path /v1/sol; the method
field in the request body selects the call.
Parameters
The single positional parameter is an optional config object.
configobjectoptionalconfig.commitmentstringoptionalprocessed, confirmed, or finalized. Defaults to finalized.config.minContextSlotinteger (u64)optionalResponse
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | Always "2.0". |
id | string | integer | Echoes the id from the request, for correlating responses. |
result | integer (u64) | Current block height — the count of confirmed blocks. |
Errors
Errors arrive in the standard JSON-RPC error object (code, message,
data).
| Code | Triport code | When it happens |
|---|---|---|
-32602 | invalid_params | The config object contains an unknown field or a malformed value (e.g. an invalid commitment enum value). |
-32002 | tier_insufficient | The API key's tier is below the minimum for this method (not expected here — getBlockHeight is free+). |
-32003 | rate_limited | You exceeded your tier's sustained RPS for sol_read_rpc; honour Retry-After / data.retry_after_sec. |
See the shared errors reference for the full envelope, the
data fields, and the HTTP ↔ JSON-RPC wire-code mapping.
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/sol", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getBlockHeight",
params: [{ commitment: "finalized" }],
}),
});
const { result: blockHeight } = await res.json();
console.log(blockHeight); // 285432109TypeScript SDK (@triport/sdk)
import { TriportClient } from "@triport/sdk";
const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY });
const blockHeight = await client.sol.getBlockHeight({ commitment: "finalized" });
console.log(blockHeight); // 285432109Python (triport-sdk)
import os
from triport import TriportClient
client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])
block_height = client.sol.get_block_height(commitment="finalized")
print(block_height) # 285432109Notes
commitmentdefaults tofinalizedwhen omitted.- Block height is gap-free and monotonically increasing; slot numbers are not
(skipped slots leave gaps). Use this method, not
getSlot, when you need a count of actual blocks. idmay be any client-chosen string or integer; it is echoed back so you can correlate responses.- This is a
sol_read_rpcmethod available from the free tier; throughput scales with your plan (20 → 600 rps) with burst allowance. There is no daily quota. - Related:
getBlockTime,getBlocks,getLatestBlockhash.