Skip to main content
GET
/
{chain_id}
/
api
/
legacy
/
block
/
get-block-number-by-time
Get block number by time stamp
curl --request GET \
  --url https://api.blockscout.com/{chain_id}/api/legacy/block/get-block-number-by-time \
  --header 'Authorization: Bearer <token>'
{
  "message": "<string>",
  "result": {
    "blockNumber": "<string>"
  }
}

Authorizations

Authorization
string
header
required

API key passed as a Bearer token in the Authorization header.

Path Parameters

chain_id
string
required

The ID of the blockchain

Query Parameters

timestamp
string

Unix timestamp in seconds.

Pattern: ^-?([1-9][0-9]*|0)$
closest
enum<string>

Whether to return the block before or after the timestamp.

Available options:
before,
after

Response

200 - application/json

Block number

message
string
required

Human-readable status string — OK on success, a descriptive error message otherwise.

result
GetBlockNumberByTimeResult · object
required

Block number closest to the requested timestamp; null if the lookup fails.

status
enum<string>
required

1 = OK, 0 = error, 2 = pending.

Available options:
0,
1,
2