umami-api-js 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- A package to interact with [the API of self-hosted instances of Umami v3.0.1](https://umami.is/docs/api). It is a lightweight alternative to [@umami/api-client](https://github.com/umami-software/api-client), forked from [osu-api-v2-js](https://github.com/TTTaevas/osu-api-v2-js).
1
+ A package to interact with [the API of self-hosted instances of Umami](https://umami.is/docs/api). It is a lightweight alternative to [@umami/api-client](https://github.com/umami-software/api-client), forked from [osu-api-v2-js](https://github.com/TTTaevas/osu-api-v2-js).
2
2
 
3
- If you are reading this from the [package's documentation](https://umami-api-js.taevas.xyz/), please be aware that the documentation is for **umami-api-js@0.1.3**, so make sure your package is up to date! Report any bug on [Codeberg](https://codeberg.org/Taevas/umami-api-js/issues).
3
+ If you are reading this from the [package's documentation](https://umami-api-js.taevas.xyz/), please be aware that the documentation is for **umami-api-js@0.2.0**, so make sure your package is up to date! Report any bug on [Codeberg](https://codeberg.org/Taevas/umami-api-js/issues).
4
4
 
5
- Please note that this package is expected to work with self-hosted instances of **Umami v3.0.1**, and is *not* expected to work with [Umami Cloud](https://umami.is/docs/cloud), the instance of Umami hosted by its creators.
5
+ Please note that this package is expected to work with self-hosted instances of **Umami v3.0.3**, and is *not* expected to work with [Umami Cloud](https://umami.is/docs/cloud), the instance of Umami hosted by its creators.
package/dist/index.d.ts CHANGED
@@ -11,26 +11,9 @@ import { Users } from "./namespaces/Users.js";
11
11
  import { Websites } from "./namespaces/Websites.js";
12
12
  import { WebsiteStats } from "./namespaces/WebsiteStats.js";
13
13
  export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Teams, Users };
14
- export interface GenericObject {
15
- id: string;
16
- createdAt: Date;
17
- updatedAt: Date | null;
18
- deletedAt: Date | null;
19
- }
20
14
  export interface DeletionResult {
21
15
  ok: boolean;
22
16
  }
23
- export interface Report extends Omit<GenericObject, "deletedAt"> {
24
- userId: Users.User["id"];
25
- websiteId: Websites.Website["id"];
26
- type: string;
27
- name: string;
28
- description: string;
29
- parameters: {
30
- type: string;
31
- value: string;
32
- };
33
- }
34
17
  export interface NameValue {
35
18
  name: string;
36
19
  value: number;
package/dist/index.js CHANGED
@@ -140,6 +140,7 @@ export class API {
140
140
  this.log(true, "Unable to obtain a token! Here's what was received from the API:", json);
141
141
  reject(new APIError(error_message, this.server, "post", ["auth", "login"], body, response.status));
142
142
  }
143
+ // Note: `json` currently only has `token` & `user`
143
144
  this.token = json.token;
144
145
  this.user = json.user;
145
146
  const expiration_date = new Date();
@@ -1,21 +1,10 @@
1
- import { API, GenericObject, GenericRequestParameters, Teams, Users, Websites } from "../index.js";
1
+ import { API, GenericRequestParameters, Teams, Users, Websites } from "../index.js";
2
2
  /** Operations around admin management: https://umami.is/docs/api/admin */
3
3
  export declare namespace Admin {
4
4
  /** Returns all users: https://umami.is/docs/api/admin#get-apiadminusers */
5
- function getUsers(this: API, parameters?: GenericRequestParameters): Promise<(GenericObject & {
6
- username: string;
7
- role: Users.Role;
8
- logoUrl: string | null;
9
- displayName: string | null;
10
- _count: {
11
- websites: number;
12
- };
13
- })[]>;
5
+ function getUsers(this: API, parameters?: GenericRequestParameters): Promise<Users.DetailedUser[]>;
14
6
  /** Returns all websites: https://umami.is/docs/api/admin#get-apiadminwebsites */
15
- function getWebsites(this: API, parameters?: GenericRequestParameters): Promise<(Websites.WebsiteWithUser & {
16
- /** @remarks TODO Documentation says it can be null but doesn't actually say what else it can be, ***presumed* to be string**, check */
17
- team: string | null;
18
- })[]>;
7
+ function getWebsites(this: API, parameters?: GenericRequestParameters): Promise<Websites.WebsiteWithUserTeam[]>;
19
8
  /** Returns all teams: https://umami.is/docs/api/admin#get-apiadminteams */
20
9
  function getTeams(this: API, parameters?: GenericRequestParameters): Promise<Teams.TeamWithMembersCount[]>;
21
10
  }
@@ -20,12 +20,11 @@ export declare namespace Events {
20
20
  pageTitle: string | null;
21
21
  eventType: number;
22
22
  eventName: string;
23
- hasData?: number;
23
+ hasData?: boolean;
24
24
  }
25
25
  /** Gets website event details within a given time range: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevents */
26
26
  function get_WEBSITEID_Events(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & GenericRequestParameters): Promise<Event[]>;
27
- /** Gets event-data for a individual event: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-dataeventid */
28
- function get_WEBSITEID_Eventdata_EVENTID(this: API, websiteId: Websites.Website["id"], eventId: Event["id"]): Promise<{
27
+ interface Data {
29
28
  websiteId: Websites.Website["id"];
30
29
  sessionId?: Sessions.Session["id"];
31
30
  eventId: Event["id"];
@@ -37,44 +36,51 @@ export declare namespace Events {
37
36
  dateValue: Date | null;
38
37
  dataType: number;
39
38
  createdAt: Date;
40
- }[]>;
39
+ }
40
+ /** Gets event-data for a individual event: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-dataeventid */
41
+ function get_WEBSITEID_Eventdata_EVENTID(this: API, websiteId: Websites.Website["id"], eventId: Event["id"]): Promise<Data[]>;
42
+ interface DataMultiple {
43
+ eventName: Event["eventName"];
44
+ propertyName: string;
45
+ dataType: number;
46
+ total: number;
47
+ }
41
48
  /** Gets event data names, properties, and counts: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-dataevents (TODO Server returns a 500) */
42
49
  function get_WEBSITEID_EventdataEvents(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & {
43
50
  /** Event name filter */
44
51
  event?: Event["eventName"];
45
- }): Promise<{
46
- eventName: Event["eventName"];
52
+ }): Promise<DataMultiple[]>;
53
+ interface DataFields {
47
54
  propertyName: string;
48
55
  dataType: number;
56
+ value: string;
49
57
  total: number;
50
- }[]>;
58
+ }
51
59
  /** Gets event data property and value counts within a given time range: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-datafields */
52
- function get_WEBSITEID_EventdataFields(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<{
60
+ function get_WEBSITEID_EventdataFields(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<DataFields[]>;
61
+ interface DataProperties {
62
+ eventName: Event["eventName"] | null;
53
63
  propertyName: string;
54
- dataType: number;
55
- value: string;
56
64
  total: number;
57
- }[]>;
65
+ }
58
66
  /** Gets event name and property counts for a website: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-dataproperties */
59
- function get_WEBSITEID_EventdataProperties(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<{
60
- eventName: Event["eventName"] | null;
61
- propertyName: string;
67
+ function get_WEBSITEID_EventdataProperties(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<DataProperties[]>;
68
+ interface DataValues {
69
+ value: string;
62
70
  total: number;
63
- }[]>;
71
+ }
64
72
  /** Gets event data counts for a given event and property: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-datavalues */
65
73
  function get_WEBSITEID_EventdataValues(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & {
66
74
  /** Event name filter */
67
75
  event: Event["eventName"];
68
76
  /** Property name */
69
77
  propertyName: string;
70
- }): Promise<{
71
- value: string;
72
- total: number;
73
- }[]>;
74
- /** Gets aggregated website events, properties, and records within a given time range: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-datastats */
75
- function get_WEBSITEID_EventdataStats(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<{
78
+ }): Promise<DataValues[]>;
79
+ interface DataStats {
76
80
  events: number;
77
81
  properties: number;
78
82
  records: number;
79
- }>;
83
+ }
84
+ /** Gets aggregated website events, properties, and records within a given time range: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-datastats */
85
+ function get_WEBSITEID_EventdataStats(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<DataStats>;
80
86
  }
@@ -1,18 +1,22 @@
1
- import { API, DeletionResult, GenericObject, GenericRequestParameters, Users } from "../index.js";
1
+ import { API, DeletionResult, GenericRequestParameters, Users } from "../index.js";
2
2
  /** Operations around Links management: https://umami.is/docs/api/links */
3
3
  export declare namespace Links {
4
- interface Link extends GenericObject {
4
+ interface Link {
5
+ id: string;
5
6
  name: string;
6
7
  url: string;
7
8
  slug: string;
8
9
  userId: Users.User["id"];
9
- teamid: string | null;
10
+ teamId: string | null;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ deletedAt: Date | null;
10
14
  }
11
- /** Returns all user links: https://umami.is/docs/api/links#get-apilinks (TODO UNTESTED) */
15
+ /** Returns all user links: https://umami.is/docs/api/links#get-apilinks */
12
16
  function get(this: API, parameters?: GenericRequestParameters): Promise<Link[]>;
13
- /** Gets a link by ID: https://umami.is/docs/api/links#get-apilinkslinkid (TODO UNTESTED) */
17
+ /** Gets a link by ID: https://umami.is/docs/api/links#get-apilinkslinkid */
14
18
  function get_LINKID(this: API, linkId: Link["id"]): Promise<Link>;
15
- /** Updates a link: https://umami.is/docs/api/links#post-apilinkslinkid (TODO UNTESTED) */
19
+ /** Updates a link: https://umami.is/docs/api/links#post-apilinkslinkid */
16
20
  function post_LINKID(this: API, linkId: Link["id"], parameters: {
17
21
  /** The link's name */
18
22
  name?: Link["name"];
@@ -21,6 +25,6 @@ export declare namespace Links {
21
25
  /** The link's URL slug, **with a minimum of 8 characters** */
22
26
  slug?: Link["slug"];
23
27
  }): Promise<Link>;
24
- /** Deletes a link: https://umami.is/docs/api/links#delete-apilinkslinkid (TODO UNTESTED) */
28
+ /** Deletes a link: https://umami.is/docs/api/links#delete-apilinkslinkid */
25
29
  function delete_LINKID(this: API, linkId: Link["id"]): Promise<DeletionResult>;
26
30
  }
@@ -1,23 +1,23 @@
1
1
  /** Operations around Links management: https://umami.is/docs/api/links */
2
2
  export var Links;
3
3
  (function (Links) {
4
- /** Returns all user links: https://umami.is/docs/api/links#get-apilinks (TODO UNTESTED) */
4
+ /** Returns all user links: https://umami.is/docs/api/links#get-apilinks */
5
5
  async function get(parameters) {
6
6
  const response = await this.request("get", ["links"], parameters);
7
7
  return response.data;
8
8
  }
9
9
  Links.get = get;
10
- /** Gets a link by ID: https://umami.is/docs/api/links#get-apilinkslinkid (TODO UNTESTED) */
10
+ /** Gets a link by ID: https://umami.is/docs/api/links#get-apilinkslinkid */
11
11
  async function get_LINKID(linkId) {
12
12
  return await this.request("get", ["links", linkId]);
13
13
  }
14
14
  Links.get_LINKID = get_LINKID;
15
- /** Updates a link: https://umami.is/docs/api/links#post-apilinkslinkid (TODO UNTESTED) */
15
+ /** Updates a link: https://umami.is/docs/api/links#post-apilinkslinkid */
16
16
  async function post_LINKID(linkId, parameters) {
17
17
  return await this.request("post", ["links", linkId], parameters);
18
18
  }
19
19
  Links.post_LINKID = post_LINKID;
20
- /** Deletes a link: https://umami.is/docs/api/links#delete-apilinkslinkid (TODO UNTESTED) */
20
+ /** Deletes a link: https://umami.is/docs/api/links#delete-apilinkslinkid */
21
21
  async function delete_LINKID(linkId) {
22
22
  return await this.request("delete", ["links", linkId]);
23
23
  }
@@ -1,13 +1,14 @@
1
1
  import { API, Teams, Users, Websites } from "../index.js";
2
2
  /** All information about your session: https://umami.is/docs/api/me */
3
3
  export declare namespace Me {
4
- /** Get information based on your auth token: https://umami.is/docs/api/me#get-apime */
5
- function get(this: API): Promise<{
4
+ interface TokenInformation {
6
5
  token: string;
7
- authKey: string;
8
6
  shareToken: string | null;
7
+ authKey?: string;
9
8
  user: Users.User;
10
- }>;
9
+ }
10
+ /** Get information based on your auth token: https://umami.is/docs/api/me#get-apime */
11
+ function get(this: API): Promise<TokenInformation>;
11
12
  /** Get all your teams: https://umami.is/docs/api/me#get-apimeteams */
12
13
  function getTeams(this: API): Promise<Teams.TeamWithMembersCount[]>;
13
14
  /** Get all your websites: https://umami.is/docs/api/me#get-apimeteams */
@@ -1,23 +1,27 @@
1
- import { API, DeletionResult, GenericObject, GenericRequestParameters, Users } from "../index.js";
1
+ import { API, DeletionResult, GenericRequestParameters, Users } from "../index.js";
2
2
  /** Operations around Pixels management: https://umami.is/docs/api/pixels */
3
3
  export declare namespace Pixels {
4
- interface Pixel extends GenericObject {
4
+ interface Pixel {
5
+ id: string;
5
6
  name: string;
6
7
  slug: string;
7
8
  userId: Users.User["id"];
8
- teamid: string | null;
9
+ teamId: string | null;
10
+ createdAt: Date;
11
+ updatedAt: Date;
12
+ deletedAt: Date | null;
9
13
  }
10
- /** Returns all user pixels: https://umami.is/docs/api/pixels#get-apipixels (TODO UNTESTED) */
14
+ /** Returns all user pixels: https://umami.is/docs/api/pixels#get-apipixels */
11
15
  function get(this: API, parameters?: GenericRequestParameters): Promise<Pixel[]>;
12
- /** Gets a pixel by ID: https://umami.is/docs/api/pixels#get-apipixelspixelid (TODO UNTESTED) */
16
+ /** Gets a pixel by ID: https://umami.is/docs/api/pixels#get-apipixelspixelid */
13
17
  function get_PIXELID(this: API, pixelId: Pixel["id"]): Promise<Pixel>;
14
- /** Updates a pixel: https://umami.is/docs/api/pixels#post-apipixelspixelid (TODO UNTESTED) */
18
+ /** Updates a pixel: https://umami.is/docs/api/pixels#post-apipixelspixelid */
15
19
  function post_PIXELID(this: API, pixelId: Pixel["id"], parameters: {
16
20
  /** The pixel's name */
17
21
  name?: Pixel["name"];
18
22
  /** The pixel's URL slug, **with a minimum of 8 characters** */
19
23
  slug?: Pixel["slug"];
20
24
  }): Promise<Pixel>;
21
- /** Deletes a pixel: https://umami.is/docs/api/pixels#delete-apipixelspixelid (TODO UNTESTED) */
25
+ /** Deletes a pixel: https://umami.is/docs/api/pixels#delete-apipixelspixelid */
22
26
  function delete_PIXELID(this: API, pixelId: Pixel["id"]): Promise<DeletionResult>;
23
27
  }
@@ -1,23 +1,23 @@
1
1
  /** Operations around Pixels management: https://umami.is/docs/api/pixels */
2
2
  export var Pixels;
3
3
  (function (Pixels) {
4
- /** Returns all user pixels: https://umami.is/docs/api/pixels#get-apipixels (TODO UNTESTED) */
4
+ /** Returns all user pixels: https://umami.is/docs/api/pixels#get-apipixels */
5
5
  async function get(parameters) {
6
6
  const response = await this.request("get", ["pixels"], parameters);
7
7
  return response.data;
8
8
  }
9
9
  Pixels.get = get;
10
- /** Gets a pixel by ID: https://umami.is/docs/api/pixels#get-apipixelspixelid (TODO UNTESTED) */
10
+ /** Gets a pixel by ID: https://umami.is/docs/api/pixels#get-apipixelspixelid */
11
11
  async function get_PIXELID(pixelId) {
12
12
  return await this.request("get", ["pixels", pixelId]);
13
13
  }
14
14
  Pixels.get_PIXELID = get_PIXELID;
15
- /** Updates a pixel: https://umami.is/docs/api/pixels#post-apipixelspixelid (TODO UNTESTED) */
15
+ /** Updates a pixel: https://umami.is/docs/api/pixels#post-apipixelspixelid */
16
16
  async function post_PIXELID(pixelId, parameters) {
17
17
  return await this.request("post", ["pixels", pixelId], parameters);
18
18
  }
19
19
  Pixels.post_PIXELID = post_PIXELID;
20
- /** Deletes a pixel: https://umami.is/docs/api/pixels#delete-apipixelspixelid (TODO UNTESTED) */
20
+ /** Deletes a pixel: https://umami.is/docs/api/pixels#delete-apipixelspixelid */
21
21
  async function delete_PIXELID(pixelId) {
22
22
  return await this.request("delete", ["pixels", pixelId]);
23
23
  }
@@ -1,8 +1,7 @@
1
1
  import { API, Sessions, Websites } from "../index.js";
2
2
  /** Realtime data for your website: https://umami.is/docs/api/realtime */
3
3
  export declare namespace Realtime {
4
- /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid (TODO UNTESTED) */
5
- function get_WEBSITEID(this: API, websiteId: Websites.Website["id"]): Promise<{
4
+ interface Stats {
6
5
  countries: {
7
6
  [k: string]: number;
8
7
  };
@@ -17,12 +16,12 @@ export declare namespace Realtime {
17
16
  sessionId: Sessions.Session["id"];
18
17
  eventName: string;
19
18
  createdAt: Date;
20
- browser: string;
21
- os: string;
19
+ browser: string | null;
20
+ os: string | null;
22
21
  device: string;
23
22
  country: string;
24
23
  urlPath: string;
25
- referrerDomain: string;
24
+ referrerDomain: string | null;
26
25
  }[];
27
26
  series: {
28
27
  views: {
@@ -41,5 +40,7 @@ export declare namespace Realtime {
41
40
  countries: number;
42
41
  };
43
42
  timestamp: number;
44
- }>;
43
+ }
44
+ /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid */
45
+ function get_WEBSITEID(this: API, websiteId: Websites.Website["id"]): Promise<Stats>;
45
46
  }
@@ -1,9 +1,9 @@
1
1
  /** Realtime data for your website: https://umami.is/docs/api/realtime */
2
2
  export var Realtime;
3
3
  (function (Realtime) {
4
- /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid (TODO UNTESTED) */
4
+ /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid */
5
5
  async function get_WEBSITEID(websiteId) {
6
- return await this.request("post", ["realtime", websiteId]);
6
+ return await this.request("get", ["realtime", websiteId]);
7
7
  }
8
8
  Realtime.get_WEBSITEID = get_WEBSITEID;
9
9
  })(Realtime || (Realtime = {}));
@@ -1,6 +1,20 @@
1
- import { API, DeletionResult, Filters, GenericRequestParameters, NameValue, Report, Timestamps, Websites, XTY } from "../index.js";
1
+ import { API, DeletionResult, Filters, GenericRequestParameters, NameValue, Timestamps, Users, Websites, XTY } from "../index.js";
2
2
  /** Using reports throught the api: https://umami.is/docs/api/reports */
3
3
  export declare namespace Reports {
4
+ interface Report {
5
+ id: string;
6
+ userId: Users.User["id"];
7
+ websiteId: Websites.Website["id"];
8
+ type: ReportType;
9
+ name: string;
10
+ description: string;
11
+ parameters: {
12
+ type: string;
13
+ value: string;
14
+ };
15
+ createdAt: Date;
16
+ updatedAt: Date;
17
+ }
4
18
  type ReportType = {
5
19
  type: "attribution" | "breakdown" | "funnel" | "goal" | "journey" | "retention" | "revenue" | "utm";
6
20
  };
@@ -13,25 +27,25 @@ export declare namespace Reports {
13
27
  /** Creates a report: https://umami.is/docs/api/reports#post-apireports (TODO UNTESTED) */
14
28
  function post(this: API, websiteId: Websites.Website["id"], parameters: ReportType & {
15
29
  /** Name of report */
16
- name: string;
30
+ name: Report["name"];
17
31
  /** Description of report */
18
- description?: string;
32
+ description?: Report["description"];
19
33
  /** Parameters for report */
20
34
  parameters?: any;
21
35
  }): Promise<Report>;
22
36
  /** Gets a report by ID: https://umami.is/docs/api/reports#get-apireportsreportid (TODO UNTESTED) */
23
- function get_REPORTID(this: API, reportId: string): Promise<Report>;
37
+ function get_REPORTID(this: API, reportId: Report["id"]): Promise<Report>;
24
38
  /** Updates a report: https://umami.is/docs/api/reports#post-apireportsreportid (TODO UNTESTED) */
25
- function post_REPORTID(this: API, reportId: string, websiteId: Websites.Website["id"], parameters: ReportType & {
39
+ function post_REPORTID(this: API, reportId: Report["id"], websiteId: Websites.Website["id"], parameters: ReportType & {
26
40
  /** Name of report */
27
- name: string;
41
+ name: Report["name"];
28
42
  /** Description of report */
29
- description?: string;
43
+ description?: Report["description"];
30
44
  /** Parameters for report */
31
45
  parameters?: any;
32
46
  }): Promise<Report>;
33
47
  /** Deletes a report: https://umami.is/docs/api/reports#delete-apireportsreportid (TODO UNTESTED) */
34
- function delete_REPORTID(this: API, reportId: string): Promise<DeletionResult>;
48
+ function delete_REPORTID(this: API, reportId: Report["id"]): Promise<DeletionResult>;
35
49
  /** See how users engage with your marketing and what drives conversions: https://umami.is/docs/api/reports#post-apireportsattribution (TODO UNTESTED) */
36
50
  function postAttribution(this: API, websiteId: Websites.Website["id"], parameters: ReportType & Filters & Timestamps & {
37
51
  /** Attribution model */
@@ -17,19 +17,13 @@ export declare namespace Sessions {
17
17
  visits: number;
18
18
  views: number;
19
19
  }
20
- interface SessionWithHostnameCreatedat extends Session {
20
+ interface SessionWithHostnameCreatedate extends Session {
21
21
  hostname: string;
22
22
  createdAt: Date;
23
23
  }
24
- interface SessionWithDistinctidEventsTotaltime extends Session {
25
- distinctId: string | null;
26
- events: number;
27
- totaltime: number;
28
- }
29
24
  /** Gets website session details within a given time range: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessions */
30
- function get_WEBSITEID_Sessions(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & GenericRequestParameters): Promise<SessionWithHostnameCreatedat[]>;
31
- /** Gets summarized website session statistics: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsstats */
32
- function get_WEBSITEID_SessionsStats(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<{
25
+ function get_WEBSITEID_Sessions(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & GenericRequestParameters): Promise<SessionWithHostnameCreatedate[]>;
26
+ interface Stats {
33
27
  /** Pages hits */
34
28
  pageviews: {
35
29
  value: number;
@@ -50,29 +44,29 @@ export declare namespace Sessions {
50
44
  events: {
51
45
  value: number;
52
46
  };
53
- /**
54
- * Number of visitors who only visit a single page
55
- * @remarks While featured in the documentation, it doesn't seem to exist
56
- */
47
+ /** Number of visitors who only visit a single page */
57
48
  bounces?: {
58
49
  value: number;
59
50
  };
60
- /**
61
- * Time spent on the website
62
- * @remarks While featured in the documentation, it doesn't seem to exist
63
- */
51
+ /** Time spent on the website */
64
52
  totaltime?: {
65
53
  value: number;
66
54
  };
67
- }>;
55
+ }
56
+ /** Gets summarized website session statistics: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsstats */
57
+ function get_WEBSITEID_SessionsStats(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<Stats>;
68
58
  /** Get collected count of sessions by hour of weekday: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsweekly */
69
59
  function get_WEBSITEID_SessionsWeekly(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & {
70
60
  timezone: string;
71
61
  }): Promise<number[][]>;
62
+ interface SessionWithDistinctidEventsTotaltime extends Session {
63
+ distinctId: string | null;
64
+ events: number;
65
+ totaltime: number;
66
+ }
72
67
  /** Gets session details for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionid */
73
68
  function get_WEBSITEID_Sessions_SESSIONID(this: API, websiteId: Websites.Website["id"], sessionId: Session["id"]): Promise<SessionWithDistinctidEventsTotaltime>;
74
- /** Gets session activity for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidactivity */
75
- function get_WEBSITEID_Sessions_SESSIONID_Activity(this: API, websiteId: Websites.Website["id"], sessionId: Session["id"], parameters: Timestamps): Promise<{
69
+ interface Activity {
76
70
  createdAt: Date;
77
71
  urlPath: string;
78
72
  urlQuery: string;
@@ -82,9 +76,10 @@ export declare namespace Sessions {
82
76
  eventName: Events.Event["eventName"] | null;
83
77
  visitId: string;
84
78
  hasData: boolean;
85
- }[]>;
86
- /** Gets session properties for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO Server returns empty array) */
87
- function get_WEBSITEID_Sessions_SESSIONID_Properties(this: API, websiteId: Websites.Website["id"], sessionId: Session["id"]): Promise<{
79
+ }
80
+ /** Gets session activity for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidactivity */
81
+ function get_WEBSITEID_Sessions_SESSIONID_Activity(this: API, websiteId: Websites.Website["id"], sessionId: Session["id"], parameters: Timestamps): Promise<Activity[]>;
82
+ interface Properties {
88
83
  websiteId: Websites.Website["id"];
89
84
  sessionId: Session["id"];
90
85
  dataKey: string;
@@ -93,17 +88,21 @@ export declare namespace Sessions {
93
88
  numberValue: number | null;
94
89
  dateValue: Date | null;
95
90
  createdAt: Date;
96
- }[]>;
97
- /** Gets session data counts by property name: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-dataproperties (TODO Server returns empty array) */
98
- function get_WEBSITEID_SessiondataProperties(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<{
91
+ }
92
+ /** Gets session properties for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO Server returns empty array) */
93
+ function get_WEBSITEID_Sessions_SESSIONID_Properties(this: API, websiteId: Websites.Website["id"], sessionId: Session["id"]): Promise<Properties[]>;
94
+ interface DataProperties {
99
95
  propertyName: string;
100
96
  total: number;
101
- }[]>;
97
+ }
98
+ /** Gets session data counts by property name: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-dataproperties (TODO Server returns empty array) */
99
+ function get_WEBSITEID_SessiondataProperties(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<DataProperties[]>;
100
+ interface DataValues {
101
+ value: string;
102
+ total: number;
103
+ }
102
104
  /** Gets session data counts for a given property: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datavalues (TODO Server returns empty array) */
103
105
  function get_WEBSITEID_SessiondataValues(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & {
104
106
  propertyName: string;
105
- }): Promise<{
106
- value: string;
107
- total: number;
108
- }[]>;
107
+ }): Promise<DataValues[]>;
109
108
  }
@@ -22,9 +22,12 @@ export declare namespace Teams {
22
22
  user: Users.MinimalUser;
23
23
  }
24
24
  interface TeamWithMembers extends Team {
25
+ members: TeamMember[];
26
+ }
27
+ interface TeamWithMembersWithUser extends Team {
25
28
  members: TeamMemberWithUser[];
26
29
  }
27
- interface TeamWithMembersCount extends TeamWithMembers {
30
+ interface TeamWithMembersCount extends TeamWithMembersWithUser {
28
31
  _count: {
29
32
  websites: number;
30
33
  members: number;
@@ -14,9 +14,18 @@ export declare namespace Users {
14
14
  }
15
15
  interface MinimalUserWithRoleCreatedAt extends MinimalUserWithRole, MinimalUserWithCreatedAt {
16
16
  }
17
- interface User extends MinimalUserWithCreatedAt {
17
+ interface User extends MinimalUserWithRoleCreatedAt {
18
18
  isAdmin: boolean;
19
19
  }
20
+ interface DetailedUser extends MinimalUserWithRole, MinimalUserWithCreatedAt {
21
+ logoUrl: string | null;
22
+ displayName: string | null;
23
+ updatedAt: Date;
24
+ deletedAt: Date | null;
25
+ _count: {
26
+ websites: number;
27
+ };
28
+ }
20
29
  /** Creates a user: https://umami.is/docs/api/users#post-apiusers */
21
30
  function post(this: API, parameters: {
22
31
  /** The user's username */
@@ -30,11 +30,11 @@ export declare namespace WebsiteStats {
30
30
  totaltime: number;
31
31
  }
32
32
  type MetricsTypes = "path" | "entry" | "exit" | "title" | "query" | "referrer" | "channel" | "domain" | "country" | "region" | "city" | "browser" | "os" | "device" | "language" | "screen" | "event" | "hostname" | "tag";
33
- /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive (TODO UNTESTED) */
33
+ /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive */
34
34
  function get_WEBSITEID_Active(this: API, websiteId: Websites.Website["id"]): Promise<{
35
35
  visitors: number;
36
36
  }>;
37
- /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries (TODO UNTESTED) */
37
+ /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries */
38
38
  function get_WEBSITEID_EventsSeries(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Units & Filters & {
39
39
  /** Timezone (ex. America/Los_Angeles) */
40
40
  timezone: string;
@@ -1,12 +1,12 @@
1
1
  /** Operations around Website statistics: https://umami.is/docs/api/website-stats */
2
2
  export var WebsiteStats;
3
3
  (function (WebsiteStats) {
4
- /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive (TODO UNTESTED) */
4
+ /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive */
5
5
  async function get_WEBSITEID_Active(websiteId) {
6
6
  return await this.request("get", ["websites", websiteId, "active"]);
7
7
  }
8
8
  WebsiteStats.get_WEBSITEID_Active = get_WEBSITEID_Active;
9
- /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries (TODO UNTESTED) */
9
+ /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries */
10
10
  async function get_WEBSITEID_EventsSeries(websiteId, parameters) {
11
11
  return await this.request("get", ["websites", websiteId, "events", "series"], parameters);
12
12
  }
@@ -19,7 +19,12 @@ export declare namespace Websites {
19
19
  createUser: Users.MinimalUser;
20
20
  }
21
21
  interface WebsiteWithUser extends Website {
22
- user: Users.MinimalUser;
22
+ /** @remarks Might be undefined if owned by a team? */
23
+ user?: Users.MinimalUser;
24
+ }
25
+ interface WebsiteWithUserTeam extends Website {
26
+ user: Users.MinimalUser | null;
27
+ team: Teams.TeamWithMembers | null;
23
28
  }
24
29
  /** Returns all user websites: https://umami.is/docs/api/websites#get-apiwebsites */
25
30
  function get(this: API, parameters?: GenericRequestParameters & {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "umami-api-js",
3
- "version": "0.1.3",
4
- "description": "Package to easily access the umami api!",
3
+ "version": "0.2.0",
4
+ "description": "Package to easily access the Umami api!",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -23,6 +23,7 @@
23
23
  "keywords": [
24
24
  "umami",
25
25
  "api",
26
+ "analytics",
26
27
  "wrapper",
27
28
  "api-wrapper"
28
29
  ],
@@ -30,9 +31,11 @@
30
31
  "devDependencies": {
31
32
  "@types/chai": "^5.2.3",
32
33
  "@types/node": "^24.9.2",
33
- "chai": "^6.2.0",
34
+ "ajv": "^8.17.1",
35
+ "chai": "^6.2.2",
34
36
  "dotenv": "^17.2.3",
35
- "typedoc": "^0.28.14",
37
+ "ts-json-schema-generator": "^2.4.0",
38
+ "typedoc": "^0.28.16",
36
39
  "typescript": "^5.9.3"
37
40
  }
38
41
  }