getBlockTime
https://api.triport.ioReturns the estimated production time of a Solana block as a Unix timestamp.
getBlockTime returns the estimated production time of the block at a
given slot, expressed as a Unix timestamp (whole seconds since the epoch). The
estimate is derived from validator vote timestamps, so it is an approximation
rather than an exact clock reading.
Use it when you have a slot (for example from getSlot or from
a transaction's slot field) and need a wall-clock time to display or to
correlate on-chain activity with off-chain events.
Gotchas
- The result is
nullwhen the block time is not available — most commonly for slots older than the network's retained history, or for a slot that was skipped / not yet rooted.- Timestamps are estimates and can differ by a few seconds from any other time source. Do not use them for ordering within a single block.
Parameters
Positional params array — a single required element:
slotintegerrequiredResponse
When no estimate is available, result is null:
{
"jsonrpc": "2.0",
"id": 1,
"result": null
}resultinteger | nullnull if not available for the requested slot.Errors
| Code | Meaning | When it happens |
|---|---|---|
-32003 | Rate limit exceeded | More than your tier's RPS for sol_read_rpc (free 20 / basic 60 / pro 200 / business 600); a burst up to 2× is allowed before throttling. |
-32601 | Method not recognised | The method name was misspelled or is not in the Solana catalog. |
-32602 | Invalid params | slot missing or not an integer. |
A slot that simply has no recorded time is not an error — it returns
result: null. See the shared errors reference for the full
error envelope and the error.data fields.
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getBlockTime",
params: [348392041],
}),
});
const { result } = await res.json();
// result is a Unix timestamp in seconds, or null
const when = result === null ? null : new Date(result * 1000);
console.log(when);TypeScript SDK (@triport/sdk)
import { TriportClient } from "@triport/sdk";
const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY! });
const blockTime: number | null = await client.solana.getBlockTime(348392041);
if (blockTime !== null) {
console.log(new Date(blockTime * 1000).toISOString());
}Python (triport-sdk)
import os
from datetime import datetime, timezone
from triport import TriportClient
client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])
block_time = client.solana.get_block_time(348392041)
if block_time is not None:
print(datetime.fromtimestamp(block_time, tz=timezone.utc).isoformat())Notes
- Nullable result: always handle the
nullcase before doing date math — older or skipped slots have no estimate. - Estimate accuracy: the timestamp comes from validator vote times and is approximate; treat it as "around when this block was produced," not an exact timestamp.
- Related methods:
getSlotfor the current slot,getBlocksto enumerate confirmed slots in a range. - Staging: the same request works against
https://staging.api.triport.iofor testing.