Skip to content

Web API for Mira Gateway and monitoring data

The Mira Gateway API service program will provide a web API for the data from the Mira Gateway and Mira Monitoring Receiver.

The API

The service will publish documentation, and schemas, about the API at the /v1/docs path.

Prerequisites

Mira Gateway running with the monitor db enabled.

Installation

Required files to install the system on linux is under the '/libmira/gateway' directory. Under there are arm64 (64 bit ARM), armhf (32 bit ARM) and x86_64 (Intel).

For ARM targets there are debian packages suitable for Raspberry Pi OS.

For the ARM64 target, there is also an deploy/install_mira_monitoring.sh script that can be used to install the Mira Monitoring & Web API services together with grafana and influx.

If the archive has been extracted on the target, run:

cd libmira/gateway/arm64/deploy
sudo ./install_mira_monitoring.sh

The service is also available as binaries for the three supported platforms: libmira/gateway/*/mira_gateway_api-*.

Configuration file

The configuration file is using the toml format.

Configure the following fields:

gw_monitor_db = "<path>"    # Path including name of the gateway monitor database

[influx_config]             # Configuration needed to connect to the Influx database
url = "<url>"               # URL to the database, usually "http://localhost:8086"
bucket_name = "<bucket>"    # Name of the bucket/database created in Influx
auth_token = "<token>"      # Authentication token for the Influx server

[api_config]
ip_address = "<adress>"     # IPv4 address the service will listen to. Use "0.0.0.0" for all addresses
port = <port>               # The port the service will listen to.

NOTE

Due to a bug in the Mira 2.10.0 release, all fields needs to be present and have values of the right type. A complete file can look like this:

tundev_address = "fd00::1"
gw_monitor_db = "mon.db"
mira_nbr_db = "mira_nbr.db"

[influx_config]
url = "http://localhost:8086"
bucket_name = "miramon"
auth_token = "auth-token"

[api_config]
ip_address = "0.0.0.0"
port = 3001


The same configuration file works with the Mira Monitoring Receiver service. By using the same file to both services, there is less risk of having incorrect configuration.

How to run

First start the gateway and optionally the monitoring receiver.

Then run the gateway_api executable:

./gateway_api --config-file <toml config file>

Without the monitoring receiver, or influx db, some data will not be available.

The service will now start to listen for web requests.

The argument --debug will cause extra debug messages to be logged.

Back to top