0

Get app metrics

by
Published Oct 17, 2025

Returns a list of usage metrics for a specific app for a given time range, grouped by requested time period. This endpoint requires an app management API token. It can be generated in the Your Apps section of Developer Hub. Required scope boards:read Rate limiting Level 1

Script miro Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Miro = {
3
  token: string;
4
};
5
/**
6
 * Get app metrics
7
 * Returns a list of usage metrics for a specific app for a given time range, grouped by requested time period.
8

9
This endpoint requires an app management API token. It can be generated in the Your Apps section of Developer Hub.
10
Required scope boards:read
11
Rate limiting Level 1
12

13
 */
14
export async function main(
15
  auth: Miro,
16
  app_id: string,
17
  startDate: string | undefined,
18
  endDate: string | undefined,
19
  period: "DAY" | "WEEK" | "MONTH" | undefined,
20
) {
21
  const url = new URL(
22
    `https://api.miro.com//v2-experimental/apps/${app_id}/metrics`,
23
  );
24
  for (const [k, v] of [
25
    ["startDate", startDate],
26
    ["endDate", endDate],
27
    ["period", period],
28
  ]) {
29
    if (v !== undefined && v !== "" && k !== undefined) {
30
      url.searchParams.append(k, v);
31
    }
32
  }
33
  const response = await fetch(url, {
34
    method: "GET",
35
    headers: {
36
      Authorization: "Bearer " + auth.token,
37
    },
38
    body: undefined,
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.json();
45
}
46