Indexer Architecture
The Aptos Indexer stores data from on-chain (via the Transaction Stream Service). It indexes basic data about transactions, fungible assets, tokens, collections, accounts, ANS (Aptos Name Service) names, and more. Apps can query that data via the Indexer API.
Aptos Labs hosts a free version of the Indexer API to help the community get access to data such as:
- Historical data - Ex. What transactions have impacted this account?
- Aggregate data - Ex. How many delegators are in this staking pool?
- Specific info best searched via query - Ex. What NFTs does an account own?
High Level Breakdown
Here is how the Indexer creates that API at a high-level:
The Indexer uses the Transaction Stream Service and Custom Processors to update a database with rich tables. Then it exposes an API for Aptos apps to access the consolidated data.
For situations where you need to go beyond the Aptos hosted Indexer API data, you will want to create a custom processor.
Writing a custom processor can help you:
- Get access to different types of data.
- Store additional information beyond what the Aptos Labs hosted Indexer API is saving.
- Change how transactions are processed.
If you would like to operate your own Indexer API as a service, see how to host your own Indexer.
Detailed Overview
You can use the below diagram for a much more in-depth diagram explaining how the Indexer code actually works behind the scenes.