umami-api-js 0.1.3 → 0.1.4

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.1.4**, 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,16 +1,8 @@
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
7
  function getWebsites(this: API, parameters?: GenericRequestParameters): Promise<(Websites.WebsiteWithUser & {
16
8
  /** @remarks TODO Documentation says it can be null but doesn't actually say what else it can be, ***presumed* to be string**, check */
@@ -1,12 +1,16 @@
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
15
  /** Returns all user links: https://umami.is/docs/api/links#get-apilinks (TODO UNTESTED) */
12
16
  function get(this: API, parameters?: GenericRequestParameters): Promise<Link[]>;
@@ -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<{
6
- token: string;
4
+ interface TokenInformation {
5
+ token: API["token"];
7
6
  authKey: string;
8
7
  shareToken: string | null;
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,11 +1,15 @@
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
14
  /** Returns all user pixels: https://umami.is/docs/api/pixels#get-apipixels (TODO UNTESTED) */
11
15
  function get(this: API, parameters?: GenericRequestParameters): Promise<Pixel[]>;
@@ -1,7 +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) */
4
+ /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid */
5
5
  function get_WEBSITEID(this: API, websiteId: Websites.Website["id"]): Promise<{
6
6
  countries: {
7
7
  [k: string]: number;
@@ -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,6 +17,15 @@ export declare namespace Users {
17
17
  interface User extends MinimalUserWithCreatedAt {
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,14 +1,16 @@
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
- return await this.request("get", ["websites", websiteId, "events", "series"], parameters);
11
+ const response = await this.request("get", ["websites", websiteId, "events", "series"], parameters);
12
+ response.t = new Date(response.t);
13
+ return response;
12
14
  }
13
15
  WebsiteStats.get_WEBSITEID_EventsSeries = get_WEBSITEID_EventsSeries;
14
16
  /** Gets metrics for a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidmetrics (TODO UNTESTED) */
@@ -23,7 +25,10 @@ export var WebsiteStats;
23
25
  WebsiteStats.get_WEBSITEID_MetricsExpanded = get_WEBSITEID_MetricsExpanded;
24
26
  /** Gets pageviews within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidpageviews (TODO UNTESTED) */
25
27
  async function get_WEBSITEID_Pageviews(websiteId, parameters) {
26
- return await this.request("get", ["websites", websiteId, "pageviews"], parameters);
28
+ const response = await this.request("get", ["websites", websiteId, "pageviews"], parameters);
29
+ response.pageviews = response.pageviews.map((v) => { v.x = new Date(v.x); return v; });
30
+ response.sessions = response.sessions.map((s) => { s.x = new Date(s.x); return s; });
31
+ return response;
27
32
  }
28
33
  WebsiteStats.get_WEBSITEID_Pageviews = get_WEBSITEID_Pageviews;
29
34
  /** Gets summarized website statistics: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidstats (TODO UNTESTED) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umami-api-js",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Package to easily access the umami api!",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,9 +30,9 @@
30
30
  "devDependencies": {
31
31
  "@types/chai": "^5.2.3",
32
32
  "@types/node": "^24.9.2",
33
- "chai": "^6.2.0",
33
+ "chai": "^6.2.2",
34
34
  "dotenv": "^17.2.3",
35
- "typedoc": "^0.28.14",
35
+ "typedoc": "^0.28.16",
36
36
  "typescript": "^5.9.3"
37
37
  }
38
38
  }