Similar to this question How to get all the historical data from chainlink price feeds? I would like to retrieve the historical data of a particular price feed to be used off-chain for a large number of consecutive updates. However, according to the docs it seems like the round IDs are no longer incremental (i.e. you can't just call getRoundData(latest_round-_step) for steps in a certain range).

Is the solution to simply do a linear search backwards and try all entries smaller than the latest roundID, or is there a recursive way to achieve this right now (is the previous round ID saved somewhere)?

3 Answers 3


Is the solution to simply do a linear search backwards and try all entries smaller than the latest roundID

Basically, the answer to this is yes.

A better way would be to use the Graph to index the data feeds and then pull from the graph.

  • alright thanks, do you happen to have any resources at hand which I can read up on?
    – faihu
    Commented Aug 6, 2021 at 14:27

The roundId is calculated from the phase and aggregatorRoundId:

function addPhase(uint16 _phase, uint64 _originalId) internal pure returns (uint80)
    return uint80(uint256(_phase) << PHASE_OFFSET | _originalId);

Since we know how the roundId is generated we can move through only the valid ones, no searching required.

I made a library for getting the next() and prev() roundId from a given roundId. You can check it out here https://github.com/JonahGroendal/chainlink-round-id-calc/blob/master/contracts/ChainlinkRoundIdCalc.sol


Update September 2022

You can now easily view historical price data by using checkthechain.

Below is a minimal working example using the Python package:

from ctc.protocols import chainlink_utils

feed = '0x31e0a88fecb6ec0a411dbe0e9e76391498296ee9'

data = await chainlink_utils.async_get_feed_data(feed)

Alternatively, you can also use their API.

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.