# 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). ## Hardware requirements Require 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). If you use Teku client, please use archive mode. ## Environment variables ```.env # Application port PORT=3000 # Log format: simple or json LOG_FORMAT=json # EL Node provider # You could provide few providers for fallback EL_PROVIDERS_URLS=http://your_el_node1,http://your_el_node2 # chain id CHAIN_ID=1 # DB config DB_NAME=keys_api_db DB_PORT=5432 DB_HOST=localhost 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=https://your_cl_node/<token> ``` ## 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. <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} volumes: - ./.volumes/pgdata-${CHAIN_ID}/:/var/lib/postgresql/data keys_api: image: lidofinance/lido-keys-api@sha256:d05885c2ef715fd45cc677f7a3ef7042ba7c7ac70a49f6dae5e22cc2bfdbacf2 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=5432 - DB_HOST=db - 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>