getBlockTime
Returns the estimated production time of a block as a Unix timestamp (seconds since the Unix epoch). Block times are estimated from validator vote timestamps and may not be available for very old blocks. This method is essential for displaying human-readable timestamps in block explorers, correlating on-chain events with wall-clock time, and building time-series analytics.
Parameters
| # | Type | Required | Description |
|---|---|---|---|
| 1 | u64 | Yes | Slot number of the block to query |
Response
Returns a single value:
| Field | Type | Description |
|---|---|---|
result | `i64 | null` |
Code Examples
cURL
curl http://88.216.36.108:7999 -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockTime",
"params": [
166974442
]
}'TypeScript
const response = await fetch("http://88.216.36.108:7999", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getBlockTime",
params: [
166974442
]
}),
});
const { result } = await response.json();
console.log("Block time:", new Date(result * 1000).toISOString());Python
import requests
response = requests.post("http://88.216.36.108:7999", json={
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockTime",
"params": [
166974442
]
})
result = response.json()["result"]
from datetime import datetime; print(f"Time: {datetime.fromtimestamp(result)}")Rust
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client.post("http://88.216.36.108:7999")
.json(&json!({
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockTime",
"params": [
166974442_u64
]
}))
.send().await?
.text().await?;
println!("{}", res);
Ok(())
}Example Response
{
"jsonrpc": "2.0",
"result": 1681391935,
"id": 1
}