I would like to query a range of blocks on the EOSIO mainnet which were created during a specific time span (for example, from unix time 1555500000 to 1555600000, which is around April 17-18, 2019). How do I find the numbers of the blocks created in that time span?

I see it's possible via getting various blocks with the REST API (/v1/chain/get_block), looking at the timestamp field of the responses, and performing a binary search for each of my two unix time borders. Is there a more straightforward way?

2 Answers 2


Looks like dfuse comes to the rescue.

The /v0/block_id/by_time endpoint can be used as follows (example from the link):

curl -H "Authorization: Bearer $TOKEN" \

Have to convert Unix time to ISO8601 extended format, but that can be automated too.


When the blockchain operates normally, you get a new block every half a second. So you can start with any block you want and calculate the diff in seconds times 2 to get the number of blocks to diff from your initial query.

Might be off by just a few since tge real world is not mathematically precise, especially when dealing with time and networks.

  • 1
    Ideally 0.002*(d.getTime()-1528545389000) should give the latest block number (considering 1528545389000 is the timestamp when Block1 was generated) But it doesn't. Probably because BPs missed a lot of blocks on the way. So you need a source which knows about when these blocks were missed. You may consider the answer from @Gassa
    – mixdev
    Sep 24, 2019 at 6:11
  • d=Date.now() BTW
    – mixdev
    Sep 24, 2019 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.