ArweaveTeam / arweave

The Arweave server and App Developer Toolkit.
https://www.arweave.org
GNU General Public License v2.0
899 stars 192 forks source link

How to get Data Stored of Arweave #520

Closed stayForward09 closed 5 months ago

stayForward09 commented 5 months ago

Hi, How are you? I'm Davee from ev3.xyz team, and we are going to add key metric- Data Stored of Arweave to our site https://depin.ninja/, especialyy, Data stored of Arweave like as https://viewblock.io/arweave/stat/cumulativeWeaveSize, So I tried to access api.viewblock.io/graphql, but I can't find where I should get API_KEY and query docs. Would you please help me to get relevant api and api documentation? Thanks.

samcamwilliams commented 5 months ago

Hey Davee!

No need for an API key, unless you want to get the data at extremely high frequency. Assuming a normal access pattern, you could just grab this from the headers of the current block from any Arweave gateway/node. Arweave.net is a big open one that is reliable (live for >5 years). g8way.io is also becoming popular but you can check out the full list on Viewblock for more options!

The route you need is GET /block/current, which will return a JSON encoding of the block. The field you want from the block is weave_size. Only thing to watch out for is that the JSON block encoding is relatively large (~300 KB or so).

Example with cURL:

sam@* ~ % curl https://arweave.net/block/current | jq .weave_size
"164241648689398"

Result is encoded as a BigNum string in preparation for it to increase 🫡.

Happy integrating! Sam

stayForward09 commented 5 months ago

Thanks for your kind help @samcamwilliams I can get correct data from https://arweave.net/block/current, but the response is a bit large as you said. But I can't run this command; sam@* ~ % curl https://arweave.net/block/current | jq .weave_size Would you help me once more? Thanks.

vird commented 5 months ago

I guess without prefix curl https://arweave.net/block/current | jq .weave_size

stayForward09 commented 5 months ago

Great! Thanks @vird @samcamwilliams

stayForward09 commented 5 months ago

Hi @everyone @team First of all, thanks for your previous kind help, and may I have one more question? At this time, we'd like to add onchain revenue of Arweave to our site https://depin.ninja, and found the perfect reference is on https://viewblock.io/arweave/stat/txFees?time=month. Would you please help me to find relevant api to get this historical data? Thanks.