Skip to content

boly38/umami-api-client

Repository files navigation

umami-api-client

NPM

Umami ReST API.

  • compatible with JavaScript.

Please note that a more efficient and typescript compatible API now exists: cf. https://github.com/jakobbouchard/umami-api-client

UmamiClient

Features

using apiKey:

  • login
  • getSites
  • getStats, getPageViews, getEvents, getMetrics

accepted periods are : 1h, 1d, 7d, 30d, 31d.

Quick start

First setup your environment

cp ./env/initenv.template.sh ./env/initenv.dontpush.sh
# update ./env/initenv.dontpush.sh
. ./env/initenv.dontpush.sh

install umami-api-client

npm install umami-api-client

then let's go, here is a sample.js:

import UmamiClient from 'umami-api-client';
async function doIt() {
  try {
    var client = new UmamiClient();
    var authData = await client.login(); 
    // default is // client.login(process.env.UMAMI_USER, process.env.UMAMI_PASSWORD)
    var sitesData = await client.getSites(authData);
    console.log(sitesData);
  } catch(error) {
    console.error(error);
  }
}
doIt();

You could play mocha tests to get more examples (cf. next section).

You could avoid using environment variable by using constructor options:

var client = new UmamiClient({server:'umami.exemple.com'});

Advanced usage

UmamiClient options

This section describes UmamiClient available options.

Note about options precedence:

  • first take option value from constructor if any,
  • or else try to retrieve related environment variable,
  • or else apply default value.

Options:

  • server : Umami endpoint - (or env.UMAMI_SERVER).

How to contribute

You're not a dev ? just submit an issue (bug, improvements, questions). Or else:

git clone https://github.com/boly38/umami-api-client.git
cd umami-api-client
npm install
# play test without umami endpoint
npm run test
# play test with umami endpoint
. ./env/initenv.dontpush.sh
npm run test
  • you could also fork, feature branch, then submit a pull request.

Services or activated bots

badge name description
CI/CD Github actions Continuous tests + coverage using c8.
scheduled npm audit Github actions Continuous vulnerability audit.
Houndci JavaScript automated review (configured by .hound.yml)
Automated Release Notes by gren gren Release notes automation
Github pages host some metrics for the main branch of this project: code coverage