The Cosmos-SDK based blockchains automatically create API's to consume. In this article I will walk you through pulling data from Cosmos Hub blockchain.
First we need a server to query. I have used cosmos.network quite a bit, but you can find others here: https://chain-registry.netlify.app/
Let's say you were doing this inside of your app. The first thing you need to do is query for the latest block.
It returns JSON. The part we care about is:
We have the block height, so let's get the actual block. I prefer the RPC endpoint when it provides the right into. The REST and RCP endpoints provide different info. RPC works great in this instance:
Actually, we don't even need the block, but this is a life skill you will need, so I am leave'n it!
Next we get all the transactions that are in the block.
Explore JSON and you can see each transaction hash.
You will loop through each transaction in the list and download each separately. Well, that's the way I do it, so let me know if there's a better way. The non RPC API provides the most information:
In case you want to use RPC, here it is for reference:
With this power along you can slay the crypto world with your creative reach. The API is very useful, but when you need to go deeper and build your own blockchain specific app, the only option for cool kids is Cosmos SDK.