# Keys API launch guide Simple Lido keys and validators HTTP API. Source code is available via [link](https://github.com/lidofinance/lido-keys-api). API documentation and more information about how `Keys api` work is available via [link](https://hackmd.io/fv8btyNTTOGLZI6LqYyYIg). ## Requirements 1. 2 core CPU 2. 5 GB RAM - Keys-API-DB — 500MB - Keys-API — 4GB 3. EL Full node 4. CL node for applications like Ejector that use [validators API](https://hackmd.io/fv8btyNTTOGLZI6LqYyYIg?view#validators). KAPI currently doesn't work with Nimbus client. If you use Teku client, please use archive mode. ## Environment variables ```dockerfile # Application port PORT=3000 # The number of seconds that each request will last in storage GLOBAL_THROTTLE_TTL=5 # The maximum number of requests within the TTL limit GLOBAL_THROTTLE_LIMIT=100 # Cache expiration time in seconds GLOBAL_CACHE_TTL=1 # Log level: debug, info, notice, warning or error LOG_LEVEL=debug # Log format: simple or json LOG_FORMAT=json # EL Node provider # You could provide few providers for fallback PROVIDERS_URLS=http://your_el_node1,http://your_el_node2 # chain id CHAIN_ID=1 # DB config DB_NAME=db DB_PORT=5432 DB_HOST=keys_api_db DB_USER=postgres DB_PASSWORD=postgres # It is possible to enable/disable collecting of validators # value below is default VALIDATOR_REGISTRY_ENABLE=true # CL api urls # if VALIDATOR_REGISTRY_ENABLE=false , there are no need to provide CL_API_URLS CL_API_URLS=http://your_cl_node1,http://your_cl_node2 # FallbackProviderModule request policy parameters # values below are default PROVIDER_JSON_RPC_MAX_BATCH_SIZE=100 PROVIDER_CONCURRENT_REQUESTS=5 PROVIDER_BATCH_AGGREGATION_WAIT_MS=10 ``` ## How to run For running `Keys Api` please use our public stable image available via [link](https://hub.docker.com/r/lidofinance/lido-keys-api/tags). Below you can find docker-compose example for running service with database. Please always use the SHA256 hash of the Docker image for the latest release, which can be found here: https://docs.lido.fi/guides/tooling#keys-api. <details> <summary>docker-compose.yml</summary> ```yaml= version: '3.7' services: keys_api_db: image: postgres:14-alpine restart: unless-stopped environment: - POSTGRES_DB=${DB_NAME} - POSTGRES_USER=${DB_USER} - POSTGRES_PASSWORD=${DB_PASSWORD} ports: - ${DB_PORT}:5432 volumes: - ./.volumes/pgdata-${CHAIN_ID}/:/var/lib/postgresql/data keys_api: image: lidofinance/lido-keys-api@<latest-hash> restart: always environment: - NODE_ENV=production - PORT=${PORT} - LOG_LEVEL=${LOG_LEVEL} - LOG_FORMAT=${LOG_FORMAT} - PROVIDERS_URLS=${PROVIDERS_URLS} - CHAIN_ID=${CHAIN_ID} - DB_NAME=${DB_NAME} - DB_PORT=${DB_PORT} - DB_HOST=${DB_HOST} - DB_USER=${DB_USER} - DB_PASSWORD=${DB_PASSWORD} - CL_API_URLS=${CL_API_URLS} - VALIDATOR_REGISTRY_ENABLE=${VALIDATOR_REGISTRY_ENABLE} ports: - '${PORT}:${PORT}' depends_on: - keys_api_db ``` </details> To run docker-compose: `docker-compose up` Now you could access API on `http://localhost:${PORT}/api`. ## Monitoring Prometheus metrics will be available by enpoint `http://localhost:${PORT}/metrics`. You could find in [repository](https://github.com/lidofinance/lido-keys-api) configs and dashboards for running prometheus and grafana locally. for grafana configs check [link](https://github.com/lidofinance/lido-keys-api/tree/main/grafana). For prometheus [link](https://github.com/lidofinance/lido-keys-api/tree/main/prometheus). Below example of `docker-compose` from repository <details> <summary>docker-compose.yml</summary> ```yaml= version: '3.7' services: keys_api_prometheus: image: prom/prometheus:v2.17.2 container_name: keys_api_prometheus ports: - 9090:9090 volumes: - ./prometheus/:/etc/prometheus/ command: - '--config.file=/etc/prometheus/prometheus.yml' keys_api_grafana: image: grafana/grafana-oss:9.1.5 container_name: keys_api_grafana restart: unless-stopped ports: - 8000:3000 volumes: - ./grafana/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml depends_on: - keys_api_prometheus ``` <details>