Skip to content

cinderblockgames/nano-public-api

Repository files navigation

Nano Public API

This API sits in front of your Nano node RPC endpoint to provide access to only the public readonly calls available. The API excludes all deprecated calls, control calls, calls that write to the network, and calls that provide information about the node itself.[1]

The calls available against the v25.1 node are listed below:

The API provides a Swagger interface for ad-hoc requests, but it also provides a proxy method that can be used as a replacement for a node in normal interfacing. Basically, instead of providing http://node.example.com:7076 as your RPC endpoint, you would provide https://api.node.example.com/node/proxy and still have access to the methods listed above.

NOTE: Not all API instances will provide access to all of the calls listed above; use /api/supported_calls or /api/excluded_calls to verify which calls are supported by the instance you are using.[1]

Docker-Compose Example

version: '3.8'

services:

  node:
    image: 'nanocurrency/nano:V#[.#]'
    networks:
      - nano
    ... clipped for brevity ...
    
  monitor:
    image: 'nanotools/nanonodemonitor:v#'
    networks:
      - traefik
      - nano
    ... clipped for brevity ...
    
  api:
    image: 'cinderblockgames/nano-public-api:V#[.#]_#.#.#'
    environment:
      # optional; port on which to listen; default value provided
      - 'ASPNETCORE_URLS=http://+:2022'
      # optional; url of node rpc; default value provided
      - 'NODE=http://node:7076'
      # optional; opens CORS; default value provided
      - 'DISABLE_CORS=true'
      # optional; specifies which calls to remove from support; default value provided
      - 'EXCLUDED_CALLS=delegators;delegators_count;representatives'
      # optional; specifices a maximum value for count; -1 for no limit; default value provided
      - 'MAX_COUNT=500'
      # optional; specifies whether to allow process calls through /node/proxy
      - 'SUPPORT_PROCESS=false'
    networks:
      - traefik
      - nano
    deploy:
      mode: replicated
      replicas: 2
      labels:
        - 'traefik.enable=true'
        - 'traefik.docker.network=traefik'
        - 'traefik.http.routers.nano-api.rule=Host(`api.nano.kga.earth`)'
        - 'traefik.http.routers.nano-api.entrypoints=web-secure'
        - 'traefik.http.routers.nano-api.tls'
        - 'traefik.http.services.nano-api.loadbalancer.server.port=2022'

networks:
  traefik:
    external: true
  nano:
    external: true

Footnotes

[1] The API does allow you to specify that you want to support the process call via the SUPPORT_PROCESS environment variable. You can check for process support by calling /api/api_info and looking for supports_process.
[2] accounts_pending is also supported, but it maps to accounts_receivable.
[3] pending and pending_exists are also supported to provide support for Nano.Net, but they map to receivable and receivable_exists.