Get block timestamp
The hash and unix timestamp of a block, identified by its number on a given chain.
Enterprise API access
For enterprise access, use https://private.api.morpho.org as the base URL and send your API key in the x-api-key header. Request an API key.
Path Parameters
block-selector*string
Selector formatted as <chain_id>:<block_number>. Example: 1:19700000.
Format
<chain_id>:<block_number>Response Body
application/json
const baseUrl = process.env.CORE_REST_BASE_URL ?? "https://api.morpho.org";const apiKey = process.env.MORPHO_API_KEY ?? "<MORPHO_API_KEY>";const blockSelector = "<chain_id>:<block_number>";const url = new URL(`${baseUrl}/v0/blocks/${blockSelector}/timestamp`);const response = await fetch(url, { headers: { accept: "application/json", "x-api-key": apiKey, },});if (!response.ok) throw new Error(await response.text());const body = await response.json();{
"data": {
"chain_id": 1,
"block_number": "string",
"block_hash": "string",
"timestamp": 1
}
}