Self-Hosted Indexer API
This guide will walk you through setting up a self-hosted Indexer API.
Prerequisites
Section titled “Prerequisites”- A running PostgreSQL instance is required, with a valid user and database. In this example we call the user
postgres
and the databaseindexer
. - If you wish to use Docker, you must have Docker installed. Installation Guide.
Configuration
Section titled “Configuration”To run the service we need to define a config file. We will start with this template:
health_check_port: 8084server_config: processor_config: type: default_processor postgres_connection_string: postgresql://postgres:@localhost:5432/indexer indexer_grpc_data_service_address: 127.0.0.1:50051 indexer_grpc_http2_ping_interval_in_secs: 60 indexer_grpc_http2_ping_timeout_in_secs: 10 auth_token: AUTH_TOKEN
From here you will likely want to change the values of some of these fields. Let’s go through some of them.
processor_name
Section titled “processor_name”This is the processor you want to run. You can see what processors are available here. Some examples:
coin_processor
ans_processor
token_v2_processor
postgres_connection_string
Section titled “postgres_connection_string”This is the connection string to your PostgreSQL database. It should be in the format postgresql://<username>:<password>@<host>:<port>/<database>
.
indexer_grpc_data_service_address
Section titled “indexer_grpc_data_service_address”This is the URL for the Transaction Stream Service. If you are using the Labs-Hosted instance you can find the URLs for each network at this page. Make sure to select the correct URL for the network you want to index. If you are running this service locally the value should be 127.0.0.1:50051
.
auth_token
Section titled “auth_token”This is the auth token used to connect to the Transaction Stream Service. If you are using the Labs-Hosted instance you can use the API Gateway to get an API key. Learn more at this page.
Run with source code
Section titled “Run with source code”Clone the repo:
# SSHgit clone git@github.com:aptos-labs/aptos-indexer-processors-v2.git
# HTTPSgit clone https://github.com/aptos-labs/aptos-indexer-processors-v2.git
Navigate to the directory for the service:
cd aptos-indexer-processorscd rust/processor
Run the service:
cargo run --release -- -c config.yaml
Run with Docker
Section titled “Run with Docker”To run the service with Docker, use the following command:
docker run -it --network host --mount type=bind,source=/tmp/config.yaml,target=/config.yaml aptoslabs/indexer-processor-rust -c /config.yaml
This command binds the container to the host network and mounts the config file from the host into the container. This specific invocation assumes that your config file in the host is at /tmp/config.yaml
.
See the image on DockerHub here: https://hub.docker.com/r/aptoslabs/indexer-processor-rust/tags.