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
Features
using apiKey:
- login
- getSites
- getStats, getPageViews, getEvents, getMetrics
accepted periods are : 1h
, 1d
, 7d
, 30d
, 31d
.
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'});
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
).
You're not a dev ? just submit an issue (bug, improvements, questions). Or else:
- Clone
- Install deps
- setup your test environment (cf. initenv.dontpush.sh)
- Then mocha tests
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.
badge | name | description |
---|---|---|
Github actions | Continuous tests + coverage using c8. | |
Github actions | Continuous vulnerability audit. | |
Houndci | JavaScript automated review (configured by .hound.yml ) |
|
gren | Release notes automation | |
Github pages host some metrics for the main branch of this project: code coverage |