Learn about why we built a custom solution to replace the History API from
nodeos. Our powerful search query language with our deep indexing of the data, provides the best way to retrieve *just* the data you want from the blockchain. Coupled with GraphQL Subscription and chain-wide cursors, and you can easily provide your UI with historical data AND listen for incoming matches.
Find stuff. In the blockchain space there’s a lot of things going on. A lot of transactions flowing, a lot of mutations to the database and we want to find stuff.
How do you find stuff? There’s many ways to do that and historically you had a native API that was provided by `nodeos` that was called “The History API.” That History API provided you – it’s deprecated today – but there’s replacements for that, it provided you with a list of your historical transactions. It gave you all the transactions that you signed, and also all the transactions where some smart contract notified your account. Now you might have noticed that there’s a lot of spam caused by that, because any contract can notify you without your consent, right? So it makes the History API quite full of spam, and difficult to navigate sometimes.
There’s a lot of things you don’t really need. So when you’re building a UI, and you want to have a list of your latest DEX transactions, or your latest something, the only thing you could query with the History API was your transactions and then you need to download them all with the whole payload and then sift through them on the client which is heavy. And you might be scrolling through 100s or 1000s of spammy transactions which you are not interested in.
So we that early at dfuse and we decided to do something about it. And we thought the best way to query the history of the blockchain is with a search engine. So we built dfuse Search.
So how does the dfuse Search work? The dfuse Search is actually indexing all of the blockchain history. All of the data, all the blocks, all the time and in real time. And we’ve created a special dedicated database for blockchains that indexes right now EOS, and that goes inside your actions. So for example you have a transfer, you have `from` `to` `quantity` and a `memo`. Well we’re indexing approximately 30 properties inside those transactions.
So if you want to see what transfers were made from me to you on that token, you can actually craft a small query and then we’ll search the whole blockchain just for that. It’s a lot easier than sifting through pages and pages and selecting that on your client.
And what we have also with the GraphQL subscription features we’re pulling out today, is that you’re able to use that search syntax to stream incoming blocks. So it’s soft of filtered in real time and it will notify if things just arrived that match that query. But also, that’s a new feature the GraphQL interface, we’re going to be able to navigate forks for you.
So remember the microforks thing? We’re going to link it below. If there’s a microfork, you want to be alerted that this transaction that matched does not match anymore. It has been reverted.
So we’re going to send you in the GraphQL payload, and make sure that you select that `undo`. It’s going to be `true`. You’re going to want to remove it from your database. You’re going to want to take it out from the UI. And that will mean it is not there anymore. Most probably it has been re-injected in the blockchain by the next producer. So you’ll get it back in a few milliseconds when there is a chain reorganization like that. So basically with that stream there, it’s bulletproof.
You’ll know the truth of blockchain and you’ll be able to offer that security and guarantee to your users. Now we’ve worked really hard to be able to satisfy the most basic and the most used use case, like feeding UIs with historical data while listening to the future. And with the GraphQL interface and the new cursor that we built, you’re able to do just that.
You can query with that language, be very specific as to what you want to get. Get paginated historical things. Or even streaming so that you can stream the whole blockchain in one swift, if you want, through the GraphQL subscription. And use the cursor, that we now send at each response, and use the cursor to do a forward search that then goes and navigates into the future.
So you can search backwards and forwards with the same cursor, and always be aware of what the reality is, historical or real time, of the blockchain. So to do that, we needed to build something that didn’t exist, we’re really proud of that, and if you want to try it out the best way to do it is the GraphQL interface that we’re going to link down in the docs. And I hope you’re going to have a lot of fun querying the blockchain.