Multiple price for single day for token price chart

I visited the moralis youtube video for token price chart(

but as i can see their is sinlge price for each day which make my chart quite straight
but i want my chart to look like this for example(
for that obviously i need multiple price for all the token for a day
so how to get the multiple prices for a token for a day for the list of 1000 token to create a price token chart

Please let me know about that specific API or the way to achieve this
Thank you

You can use a syntax similar to the one presented here to get the price for a particular time: Toke price with chain as bsc

1 Like

ok but if i want a price of a token at 1 am than 2 am than 3 am so total 24 price for 1 day and i need of last 7 days, so do we need to send time alongwith date in the getDateToBlock api

yes, you have to generate somehow that 1 hour time interval, and then to use something like this in order to get the blocks from that exact hour (this example has 3 different hours)

(await Moralis.Web3API.native.getDateToBlock({chain: “bsc”, date:“2021-10-27T01:00:00+00:00”})).block
(await Moralis.Web3API.native.getDateToBlock({chain: “bsc”, date:“2021-10-27T02:00:00+00:00”})).block
(await Moralis.Web3API.native.getDateToBlock({chain: “bsc”, date:“2021-10-27T03:00:00+00:00”})).block
1 Like

thank you so much , i am trying it right now
i really appreciate your support Man

i have to get the price for each hour of a day untill 7 day for each token
so its like 24x7=168 times api call to get the block and again 168 time api call to get the token price, this is just for 1 token for 7 days so imagine i have 3000 token
so do we have something in moralis like just pass the date range and the contract address and get the historical price

The part with passing the date you can do it only once and use the resulted block number with all the tokens. Then you could do 3k requests for every hour for all the tokens and save the result in the database, and all you will have to do next hour will be only 3k requests.

1 Like