TriportRPC

getBlockHeight

POSThttps://api.triport.io/v1/sol

Returns the current block height of the node — the number of confirmed blocks beneath the latest confirmed block.

Solanasol_read_rpcfree+ · 20 / 60 / 200 / 600 rps (free / basic / pro / business)

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.

configobjectoptional
Configuration object (see fields below). Omit it entirely for defaults.
config.commitmentstringoptional
Commitment level for the query: processed, confirmed, or finalized. Defaults to finalized.
config.minContextSlotinteger (u64)optional
The minimum slot at which the request may be evaluated.

Response

Response fields

FieldTypeDescription
jsonrpcstringAlways "2.0".
idstring | integerEchoes the id from the request, for correlating responses.
resultinteger (u64)Current block height — the count of confirmed blocks.

Errors

Errors arrive in the standard JSON-RPC error object (code, message, data).

CodeTriport codeWhen it happens
-32602invalid_paramsThe config object contains an unknown field or a malformed value (e.g. an invalid commitment enum value).
-32002tier_insufficientThe API key's tier is below the minimum for this method (not expected here — getBlockHeight is free+).
-32003rate_limitedYou 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); // 285432109

TypeScript 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); // 285432109

Python (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)  # 285432109

Notes

  • commitment defaults to finalized when 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.
  • id may be any client-chosen string or integer; it is echoed back so you can correlate responses.
  • This is a sol_read_rpc method 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.