Vanilla JS SDK
import { MonitoringClient } from '@monitoring/sdk-js';
const client = new MonitoringClient({
baseUrl: 'https://api.unimoni.example.com',
fetchToken: async () => {
const r = await fetch('/api/dashboard-token').then(r => r.json());
return { token: r.token, expiresAt: new Date(r.expiresAt) };
},
});
const series = await client.range('system_cpu_usage_percent', {
last: '1h',
step: '15s',
labels: { host: 'web-01' },
});
renderChart(series);Token refresh
The SDK manages refresh itself: 1) it calls fetchToken on mount, 2) it automatically re-issues 30 seconds before expiresAt. The partner backend returns a fresh token each time.