# Indexer Installation

This guide will walk you through setting up a self-hosted indexer API. before indexer service setup, user should have setup Endless fullnode and already connected to Endless network.

Please refer [Sample configuration with index GRPC enabled](/endless/devbuild/nodes/run-a-public-fullnode/deploy-a-pfn/using-precompiled-binary.md#sample-configuration-with-index-grpc-enabled)

## Pre-compile binary file with configuration

To run the indexer service we need to build configuration: `config.toml`. the content below for your reference:

```toml
stream_url="http://127.0.0.1:50051"
server="127.0.0.1:3000"
db_dir="endless_indexer_data"
```

Let’s go through some of these fields.

* `stream_url` indexer service depends transaction sent by GRPC service.

  stream\_url should points to `endless-node` GRPC endpoint, please refer [Sample configuration with index GRPC enabled](/endless/devbuild/nodes/run-a-public-fullnode/deploy-a-pfn/using-precompiled-binary.md#sample-configuration-with-index-grpc-enabled)
* `server` This is the URL service of endless-indexer. By default the value is `127.0.0.1:3000`.
* `db_dir` `db_dir` points to the directory where index service store db data. By default the value is `endless_indexer_data`

### Run endless-index

Make sure the `config.toml` is located in the same directory as `endless-index`.

```shell
endless-index
```

All indexed data are saved under `endless_indexer_data`.

Prune `endless_indexer_data` and restart `endless-index` if user want to clear and rebuild the index from the scratch.

## Docker

docker run command:

```shell
docker run -e APP_STREAM_URL=http://127.0.0.1:50051 -v $PWD/data:/app -p 3000:3000 endless-indexer
```

Here is a sample `docker-compose.yaml` to orchestrate `endless-node` and `endless-indexer`:

```yaml
services:
  # Ensure that the default configuration file in `endless-node` has already been modified to enable index GRPC 
  # and point to the IP address and corresponding port of `endless-indexer`
  endless-node:
    image: endlesslab/endless-node:latest
    restart: unless-stopped

  endless-indexer:
    image: endlesslab/endless-indexer:latest
    depends_on:
      - endless-node
    environment: 
      - APP_STREAM_URL=http://127.0.0.1:50051
      - APP_SERVER=127.0.0.1:3000
      - APP_DB_DIR=/app/endless_indexer_data
    ports:
      - "3000:3000"
      - "50051:50051"
    volumes:
      - ./endless_indexer_data:/app/endless_indexer_data
    restart: unless-stopped
```

## Endless-index API Doc

After ensure `endless-index` service is started, accessing `http://localhost:3000/api/v2/spec` will display the schema that conforms to the OpenAPI specification.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.endless.link/endless/devbuild/build/endless-apis/indexer-rest-api/indexer-installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
