Indexer
Purpose
Typical applications built on the Aptos blockchain, on any blockchain for that matter, require the raw blockchain data to be shaped and stored in an application-specific manner. This is essential to supporting low-latency and rich experiences when consuming blockchain data in end-user apps from millions of users. The Aptos Node API provides a lower level, stable and generic API and is not designed to support data shaping and therefore cannot support rich end-user experiences directly.
The Aptos Indexer is the answer to this need, allowing the data shaping critical to real-time app use. See this high-level diagram for how Aptos indexing works:
Quick Start
Refer to this role-oriented guide to help you quickly find the relevant docs:
- Core Infra Provider: You want to run your own Transaction Stream Service in addition to the rest of the stack.
- See docs for Self-Hosted Transaction Stream Service.
- API Operator: You want to run the Indexer API on top of a hosted Transaction Stream Service.
- See docs for Self-Hosted Indexer API.
- Custom Processor Builder: You want to build a custom processor on top of a hosted Transaction Stream Service.
- See docs for Custom Processors.
- Indexer API Consumer: You want to use a hosted Indexer API.
- See docs for the Labs-Hosted Indexer API.
- See the Indexer Example Queries.
Architecture Overview
At a high level, indexing on the Aptos blockchain works like this:
- Users of a dapp, for example, on an NFT marketplace, interact with the Aptos blockchain via a rich UI presented by the dapp. Behind the scenes, these interactions generate, via smart contracts, the transaction and event data. This raw data is stored in the distributed ledger database, for example, on an Aptos fullnode.
- This raw ledger data is read and indexed using an application-specific data model, in this case an NFT marketplace-specific data model (“Business logic” in the above diagram). This NFT marketplace-specific index is then stored in a separate database (“Indexed database” in the above diagram) and exposed via an API.
- The dapp sends NFT-specific GraphQL queries to this indexed database and receives rich data back, which is then served to the users.
Step 2 is facilitated by the Aptos Indexer. The diagram above is a simplified view of how the system works at a high level. In reality, the system is composed of many components. If you are interested in these details, see the Detailed Overview below.
Indexer API
Aptos supports the following ways to access indexed data.
- Labs hosted Indexer API: This API is rate-limited and is intended only for lightweight applications such as wallets. This option is not recommended for high-bandwidth applications.
- Self-hosted Indexer API: Run your own deployment of the Labs hosted indexer stack.
- Custom processor: Write and deploy a custom processor to index and expose data in a way specific to your needs.
Transaction Stream Service
The Indexer API and Custom Processors depend on the Transaction Stream Service. In short, this service provides a GRPC stream of transactions that processors consume. Learn more about this service here. Aptos Labs offers a hosted instance of this service, but you may also run your own.
Detailed Overview
This diagram explains how the Aptos Indexer tech stack works in greater detail.
Legacy Indexer
Find information about the legacy indexer here.