Skip to content

Self-Hosted Indexer API

This guide will walk you through setting up a self-hosted Indexer API.

  • A running PostgreSQL instance is required, with a valid user and database. In this example we call the user postgres and the database indexer.
  • If you wish to use Docker, you must have Docker installed. Installation Guide.

To run the service we need to define a config file. We will start with this template:

health_check_port: 8084
server_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.

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

This is the connection string to your PostgreSQL database. It should be in the format postgresql://<username>:<password>@<host>:<port>/<database>.

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.

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.

Clone the repo:

Terminal window
# SSH
git clone git@github.com:aptos-labs/aptos-indexer-processors-v2.git
# HTTPS
git clone https://github.com/aptos-labs/aptos-indexer-processors-v2.git

Navigate to the directory for the service:

Terminal window
cd aptos-indexer-processors
cd rust/processor

Run the service:

Terminal window
cargo run --release -- -c config.yaml

To run the service with Docker, use the following command:

Terminal window
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.