umami-api-js
    Preparing search index...

    Class API

    An API instance is needed to make requests to the server!

    Index

    Constructors

    • If you have account credentials, you might want to use this constructor

      Parameters

      • username: string
      • password: string
      • Optionalsettings: Partial<API>

      Returns API

    • If you are already in possession of an API.token and don't necessarily wish to be able to get a new one, you might want to use this constructor

      Parameters

      • token: string
      • Optionalsettings: Partial<API>

      Returns API

    Properties

    addTeamUser: (
        this: API,
        teamId: string,
        parameters: { role: TeamRole; userId: string },
    ) => Promise<Omit<TeamMember, "user">> = Teams.addTeamUser

    Type Declaration

    createReport: (
        this: API,
        websiteId: string,
        parameters: ReportType & {
            description?: string;
            name: string;
            parameters?: any;
        },
    ) => Promise<Report> = Reports.createReport

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: ReportType & {
                description?: string;
                name: string;
                parameters?: any;
            },
        ): Promise<Report>
      • Parameters

        • this: API
        • websiteId: string
        • parameters: ReportType & { description?: string; name: string; parameters?: any }
          • Optionaldescription?: string

            Description of report

          • name: string

            Name of report

          • Optionalparameters?: any

            Parameters for report

        Returns Promise<Report>

    createTeam: (
        this: API,
        name: string,
    ) => Promise<[GenericTeam, Omit<TeamMember, "user">]> = Teams.createTeam

    Type Declaration

    createUser: (
        this: API,
        parameters: { id?: string; password: string; role: Role; username: string },
    ) => Promise<GenericUser> = Users.createUser

    Type Declaration

      • (
            this: API,
            parameters: { id?: string; password: string; role: Role; username: string },
        ): Promise<GenericUser>
      • Parameters

        • this: API
        • parameters: { id?: string; password: string; role: Role; username: string }
          • Optionalid?: string

            Force a UUID assignment to the user

          • password: string

            The user's password

          • role: Role

            The user's role

          • username: string

            The user's username

        Returns Promise<GenericUser>

    createWebsite: (
        this: API,
        parameters: {
            domain: string;
            id?: string;
            name: string;
            shareId?: string | null;
            teamId?: string;
        },
    ) => Promise<Website> = Websites.createWebsite

    Type Declaration

      • (
            this: API,
            parameters: {
                domain: string;
                id?: string;
                name: string;
                shareId?: string | null;
                teamId?: string;
            },
        ): Promise<Website>
      • Parameters

        • this: API
        • parameters: {
              domain: string;
              id?: string;
              name: string;
              shareId?: string | null;
              teamId?: string;
          }
          • domain: string

            The full domain of the tracked website

          • Optionalid?: string

            Force a UUID assignment to the website

          • name: string

            The name of the website in Umami

          • OptionalshareId?: string | null

            A unique string to enable a share url. Set null to unshare

          • OptionalteamId?: string

            The ID of the team the website will be created under

        Returns Promise<Website>

    deleteReport: (this: API, reportId: string) => Promise<{ ok: boolean }> = Reports.deleteReport

    Type Declaration

    deleteTeam: (this: API, teamId: string) => Promise<{ ok: boolean }> = Teams.deleteTeam

    Type Declaration

    deleteUser: (this: API, id: string) => Promise<{ ok: boolean }> = Users.deleteUser

    Type Declaration

    deleteWebsite: (this: API, websiteId: string) => Promise<{ ok: boolean }> = Websites.deleteWebsite

    Type Declaration

    getRealtime: (
        this: API,
        websiteId: string,
    ) => Promise<
        {
            countries: { [k: string]: number };
            events: {
                __type: string;
                browser: string;
                country: string;
                createdAt: Date;
                device: string;
                eventName: string;
                os: string;
                referrerDomain: string;
                sessionId: string;
                urlPath: string;
            }[];
            referrers: { [k: string]: number };
            series: {
                views: { x: Date; y: number }[];
                visitors: { x: Date; y: number }[];
            };
            timestamp: number;
            totals: {
                countries: number;
                events: number;
                views: number;
                visitors: number;
            };
            urls: { [k: string]: number };
        },
    > = Realtime.getRealtime

    Type Declaration

      • (
            this: API,
            websiteId: string,
        ): Promise<
            {
                countries: { [k: string]: number };
                events: {
                    __type: string;
                    browser: string;
                    country: string;
                    createdAt: Date;
                    device: string;
                    eventName: string;
                    os: string;
                    referrerDomain: string;
                    sessionId: string;
                    urlPath: string;
                }[];
                referrers: { [k: string]: number };
                series: {
                    views: { x: Date; y: number }[];
                    visitors: { x: Date; y: number }[];
                };
                timestamp: number;
                totals: {
                    countries: number;
                    events: number;
                    views: number;
                    visitors: number;
                };
                urls: { [k: string]: number };
            },
        >
      • Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime-api#get-apirealtimewebsiteid (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string

        Returns Promise<
            {
                countries: { [k: string]: number };
                events: {
                    __type: string;
                    browser: string;
                    country: string;
                    createdAt: Date;
                    device: string;
                    eventName: string;
                    os: string;
                    referrerDomain: string;
                    sessionId: string;
                    urlPath: string;
                }[];
                referrers: { [k: string]: number };
                series: {
                    views: { x: Date; y: number }[];
                    visitors: { x: Date; y: number }[];
                };
                timestamp: number;
                totals: {
                    countries: number;
                    events: number;
                    views: number;
                    visitors: number;
                };
                urls: { [k: string]: number };
            },
        >

    getReport: (this: API, reportId: string) => Promise<Report> = Reports.getReport

    Type Declaration

    getReports: (
        this: API,
        websiteId: string,
        parameters: ReportType & Omit<GenericRequestParameters, "search">,
    ) => Promise<Report[]> = Reports.getReports

    Type Declaration

    getReportsAttribution: (
        this: API,
        websiteId: string,
        parameters: ReportType & Filters & Timestamps & {
            model: "firstClick" | "lastClick";
            step: string;
            type: ("path" | "event")[];
        },
    ) => Promise<
        {
            paidAds: NameValue[];
            referrer: NameValue[];
            total: { pageviews: number; visitors: number; visits: number };
            utm_campaign: NameValue[];
            utm_content: NameValue[];
            utm_medium: NameValue[];
            utm_source: NameValue[];
            utm_term: NameValue[];
        },
    > = Reports.getReportsAttribution

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: ReportType & Filters & Timestamps & {
                model: "firstClick" | "lastClick";
                step: string;
                type: ("path" | "event")[];
            },
        ): Promise<
            {
                paidAds: NameValue[];
                referrer: NameValue[];
                total: { pageviews: number; visitors: number; visits: number };
                utm_campaign: NameValue[];
                utm_content: NameValue[];
                utm_medium: NameValue[];
                utm_source: NameValue[];
                utm_term: NameValue[];
            },
        >
      • See how users engage with your marketing and what drives conversions: https://umami.is/docs/api/reports-api#post-apireportsattribution (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: ReportType & Filters & Timestamps & {
              model: "firstClick" | "lastClick";
              step: string;
              type: ("path" | "event")[];
          }
          • model: "firstClick" | "lastClick"

            Attribution model

          • step: string

            Conversion step

          • type: ("path" | "event")[]

            Conversion type

        Returns Promise<
            {
                paidAds: NameValue[];
                referrer: NameValue[];
                total: { pageviews: number; visitors: number; visits: number };
                utm_campaign: NameValue[];
                utm_content: NameValue[];
                utm_medium: NameValue[];
                utm_source: NameValue[];
                utm_term: NameValue[];
            },
        >

    getReportsBreakdown: (
        this: API,
        websiteId: string,
        parameters: ReportType & Filters & Timestamps & {
            fields: (
                | "region"
                | "path"
                | "event"
                | "title"
                | "query"
                | "referrer"
                | "browser"
                | "os"
                | "device"
                | "country"
                | "city"
                | "hostname"
                | "tag"
            )[];
        },
    ) => Promise<
        {
            bounces: number;
            country: string;
            os: string;
            totaltime: number;
            views: number;
            visitors: number;
            visits: number;
        }[],
    > = Reports.getReportsBreakdown

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: ReportType & Filters & Timestamps & {
                fields: (
                    | "region"
                    | "path"
                    | "event"
                    | "title"
                    | "query"
                    | "referrer"
                    | "browser"
                    | "os"
                    | "device"
                    | "country"
                    | "city"
                    | "hostname"
                    | "tag"
                )[];
            },
        ): Promise<
            {
                bounces: number;
                country: string;
                os: string;
                totaltime: number;
                views: number;
                visitors: number;
                visits: number;
            }[],
        >
      • Dive deeper into your data by using segments and filters: https://umami.is/docs/api/reports-api#post-apireportsbreakdown (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: ReportType & Filters & Timestamps & {
              fields: (
                  | "region"
                  | "path"
                  | "event"
                  | "title"
                  | "query"
                  | "referrer"
                  | "browser"
                  | "os"
                  | "device"
                  | "country"
                  | "city"
                  | "hostname"
                  | "tag"
              )[];
          }

        Returns Promise<
            {
                bounces: number;
                country: string;
                os: string;
                totaltime: number;
                views: number;
                visitors: number;
                visits: number;
            }[],
        >

    getReportsFunnel: (
        this: API,
        websiteId: string,
        parameters: ReportType & Filters & Timestamps & {
            steps: { type: "path" | "event"; value: string }[];
            window: number;
        },
    ) => Promise<
        {
            dropoff: number
            | null;
            dropped: number;
            previous: number;
            remaining: number;
            type: string;
            value: string;
            visitors: number;
        }[],
    > = Reports.getReportsFunnel

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: ReportType & Filters & Timestamps & {
                steps: { type: "path" | "event"; value: string }[];
                window: number;
            },
        ): Promise<
            {
                dropoff: number
                | null;
                dropped: number;
                previous: number;
                remaining: number;
                type: string;
                value: string;
                visitors: number;
            }[],
        >
      • Understand the conversion and drop-off rate of users: https://umami.is/docs/api/reports-api#post-apireportsfunnel (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: ReportType & Filters & Timestamps & {
              steps: { type: "path" | "event"; value: string }[];
              window: number;
          }
          • steps: { type: "path" | "event"; value: string }[]

            Type of event and conversion step

          • window: number

            Window of days between funnel steps to be considered a conversion

        Returns Promise<
            {
                dropoff: number
                | null;
                dropped: number;
                previous: number;
                remaining: number;
                type: string;
                value: string;
                visitors: number;
            }[],
        >

    getReportsGoals: (
        this: API,
        websiteId: string,
        parameters: ReportType & Filters & Timestamps & {
            type: ("path" | "event")[];
            value: string;
        },
    ) => Promise<{ num: number; total: number }> = Reports.getReportsGoals

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: ReportType & Filters & Timestamps & {
                type: ("path" | "event")[];
                value: string;
            },
        ): Promise<{ num: number; total: number }>
      • Track your goals for pageviews and events: https://umami.is/docs/api/reports-api#post-apireportsgoals (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: ReportType & Filters & Timestamps & {
              type: ("path" | "event")[];
              value: string;
          }
          • type: ("path" | "event")[]

            Conversion type

          • value: string

            Conversion step value

        Returns Promise<{ num: number; total: number }>

    getReportsJourney: (
        this: API,
        websiteId: string,
        parameters: ReportType & Filters & Timestamps & {
            endStep?: string;
            startStep: string;
            steps: number;
        },
    ) => Promise<{ count: number; items: (string | null)[] }[]> = Reports.getReportsJourney

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: ReportType & Filters & Timestamps & {
                endStep?: string;
                startStep: string;
                steps: number;
            },
        ): Promise<{ count: number; items: (string | null)[] }[]>
      • Understand how users nagivate through your website: https://umami.is/docs/api/reports-api#post-apireportsjourney (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: ReportType & Filters & Timestamps & {
              endStep?: string;
              startStep: string;
              steps: number;
          }
          • OptionalendStep?: string

            Ending step URL or event name

          • startStep: string

            Starting step URL or event name

          • steps: number

            Number of steps from 3 to 7

        Returns Promise<{ count: number; items: (string | null)[] }[]>

    getReportsRetention: (
        this: API,
        websiteId: string,
        parameters: ReportType & Filters & Timestamps & { timezone: string },
    ) => Promise<
        {
            date: Date;
            day: number;
            percentage: number;
            returnVisitors: number;
            visitors: number;
        }[],
    > = Reports.getReportsRetention

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: ReportType & Filters & Timestamps & { timezone: string },
        ): Promise<
            {
                date: Date;
                day: number;
                percentage: number;
                returnVisitors: number;
                visitors: number;
            }[],
        >
      • Measure your website stickiness by tracking how often users return: https://umami.is/docs/api/reports-api#post-apireportsretention (TODO UNTESTED)

        Parameters

        Returns Promise<
            {
                date: Date;
                day: number;
                percentage: number;
                returnVisitors: number;
                visitors: number;
            }[],
        >

    getReportsRevenue: (
        this: API,
        websiteId: string,
        parameters: ReportType & Filters & Timestamps & {
            currency: string;
            timezone: string;
        },
    ) => Promise<
        {
            chart: XTY[];
            country: NameValue[];
            total: {
                average: number;
                count: number;
                sum: number;
                unique_count: number;
            };
        },
    > = Reports.getReportsRevenue

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: ReportType & Filters & Timestamps & {
                currency: string;
                timezone: string;
            },
        ): Promise<
            {
                chart: XTY[];
                country: NameValue[];
                total: {
                    average: number;
                    count: number;
                    sum: number;
                    unique_count: number;
                };
            },
        >
      • Get currency for given range. Needed for Revenue and optional in Attribution reports: https://umami.is/docs/api/reports-api#post-apireportsrevenue (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: ReportType & Filters & Timestamps & { currency: string; timezone: string }
          • currency: string

            Currency code (ISO 4217)

          • timezone: string

            Timezone (ex. America/Los_Angeles)

        Returns Promise<
            {
                chart: XTY[];
                country: NameValue[];
                total: {
                    average: number;
                    count: number;
                    sum: number;
                    unique_count: number;
                };
            },
        >

    getReportsUTM: (
        this: API,
        websiteId: string,
        parameters: ReportType & Filters & Timestamps,
    ) => Promise<
        {
            utm_campaign: UTM[];
            utm_content: UTM[];
            utm_medium: UTM[];
            utm_source: UTM[];
            utm_term: UTM[];
        },
    > = Reports.getReportsUTM

    Type Declaration

    getTeam: (
        this: API,
        teamId: string,
    ) => Promise<GenericTeam & { members: Omit<TeamMember, "user">[] }> = Teams.getTeam

    Type Declaration

    getTeams: (
        this: API,
        parameters?: Omit<GenericRequestParameters, "search">,
    ) => Promise<
        (
            GenericTeam & {
                _count: { members: number; websites: number };
                members: TeamMember[];
            }
        )[],
    > = Teams.getTeams

    Type Declaration

    getTeamsAsAdmin: (
        this: API,
        parameters?: GenericRequestParameters,
    ) => Promise<
        (
            GenericObject & {
                _count: { members: number; websites: number };
                accessCode: string;
                logoUrl: string | null;
                members: TeamMember[];
                name: string;
            }
        )[],
    > = Admin.getTeams

    Type Declaration

      • (
            this: API,
            parameters?: GenericRequestParameters,
        ): Promise<
            (
                GenericObject & {
                    _count: { members: number; websites: number };
                    accessCode: string;
                    logoUrl: string | null;
                    members: TeamMember[];
                    name: string;
                }
            )[],
        >
      • Parameters

        Returns Promise<
            (
                GenericObject & {
                    _count: { members: number; websites: number };
                    accessCode: string;
                    logoUrl: string | null;
                    members: TeamMember[];
                    name: string;
                }
            )[],
        >

        TODO Possibly doesn't work? (throws 404 on my end)

    getTeamUser: (
        this: API,
        teamId: string,
        userId: string,
    ) => Promise<Omit<TeamMember, "user">> = Teams.getTeamUser

    Type Declaration

    getTeamUsers: (
        this: API,
        teamId: string,
        parameters: GenericRequestParameters,
    ) => Promise<TeamMember[]> = Teams.getTeamUsers

    Type Declaration

    getTeamWebsites: (
        this: API,
        teamId: string,
        parameters: GenericRequestParameters,
    ) => Promise<
        (
            GenericObject & {
                createdBy: string;
                createUser: { id: string; username: string };
                domain: string;
                name: string;
                resetAt: Date | null;
                shareId: string;
                teamId: string | null;
                userId: string | null;
            }
        )[],
    > = Teams.getTeamWebsites

    Type Declaration

      • (
            this: API,
            teamId: string,
            parameters: GenericRequestParameters,
        ): Promise<
            (
                GenericObject & {
                    createdBy: string;
                    createUser: { id: string; username: string };
                    domain: string;
                    name: string;
                    resetAt: Date | null;
                    shareId: string;
                    teamId: string | null;
                    userId: string | null;
                }
            )[],
        >
      • Get all websites that belong to a team: https://umami.is/docs/api/teams-api#get-apiteamsteamidwebsites (TODO UNTESTED)

        Parameters

        Returns Promise<
            (
                GenericObject & {
                    createdBy: string;
                    createUser: { id: string; username: string };
                    domain: string;
                    name: string;
                    resetAt: Date | null;
                    shareId: string;
                    teamId: string | null;
                    userId: string | null;
                }
            )[],
        >

    getUser: (this: API, id: string) => Promise<GenericUser & { createdAt: Date }> = Users.getUser

    Type Declaration

    getUsersAsAdmin: (
        this: API,
        parameters?: GenericRequestParameters,
    ) => Promise<
        (
            GenericObject & {
                _count: { websiteUser: number };
                displayName: string | null;
                logoUrl: string | null;
                password: string;
                role: Role;
                username: string;
            }
        )[],
    > = Admin.getUsers

    Type Declaration

      • (
            this: API,
            parameters?: GenericRequestParameters,
        ): Promise<
            (
                GenericObject & {
                    _count: { websiteUser: number };
                    displayName: string | null;
                    logoUrl: string | null;
                    password: string;
                    role: Role;
                    username: string;
                }
            )[],
        >
      • Parameters

        Returns Promise<
            (
                GenericObject & {
                    _count: { websiteUser: number };
                    displayName: string | null;
                    logoUrl: string | null;
                    password: string;
                    role: Role;
                    username: string;
                }
            )[],
        >

    getUserTeams: (
        this: API,
        id: string,
        parameters?: Omit<GenericRequestParameters, "search">,
    ) => Promise<
        (
            GenericObject & {
                _count: { members: number; websites: number };
                accessCode: string;
                logoUrl: string | null;
                members: Omit<GenericObject, "deletedAt"> & {
                    role: TeamRole;
                    teamId: string;
                    user: { id: string; username: string };
                    userId: string;
                }[];
                name: string;
            }
        )[],
    > = Users.getUserTeams

    Type Declaration

      • (
            this: API,
            id: string,
            parameters?: Omit<GenericRequestParameters, "search">,
        ): Promise<
            (
                GenericObject & {
                    _count: { members: number; websites: number };
                    accessCode: string;
                    logoUrl: string | null;
                    members: Omit<GenericObject, "deletedAt"> & {
                        role: TeamRole;
                        teamId: string;
                        user: { id: string; username: string };
                        userId: string;
                    }[];
                    name: string;
                }
            )[],
        >
      • Parameters

        Returns Promise<
            (
                GenericObject & {
                    _count: { members: number; websites: number };
                    accessCode: string;
                    logoUrl: string | null;
                    members: Omit<GenericObject, "deletedAt"> & {
                        role: TeamRole;
                        teamId: string;
                        user: { id: string; username: string };
                        userId: string;
                    }[];
                    name: string;
                }
            )[],
        >

    getUserWebsites: (
        this: API,
        id: string,
        parameters: GenericRequestParameters & { includeTeams: boolean },
    ) => Promise<(Website & { user: MinimalUser })[]> = Users.getUserWebsites

    Type Declaration

    getWebsite: (this: API, websiteId: string) => Promise<Website> = Websites.getWebsite

    Type Declaration

    getWebsiteActiveVisitors: (
        this: API,
        websiteId: string,
    ) => Promise<{ visitors: number }> = WebsiteStats.getWebsiteActiveVisitors

    Type Declaration

    getWebsiteEventData: (
        this: API,
        websiteId: string,
        eventId: string,
    ) => Promise<
        {
            createdAt: Date;
            dataKey: string;
            dataType: number;
            dateValue: Date
            | null;
            eventId: string;
            eventName: string;
            numberValue: number | null;
            sessionId: string;
            stringValue: string;
            urlPath: string;
            websiteId: string;
        }[],
    > = Events.getWebsiteEventData

    Type Declaration

      • (
            this: API,
            websiteId: string,
            eventId: string,
        ): Promise<
            {
                createdAt: Date;
                dataKey: string;
                dataType: number;
                dateValue: Date
                | null;
                eventId: string;
                eventName: string;
                numberValue: number | null;
                sessionId: string;
                stringValue: string;
                urlPath: string;
                websiteId: string;
            }[],
        >
      • Gets event-data for a individual event https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevent-dataeventid (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • eventId: string

        Returns Promise<
            {
                createdAt: Date;
                dataKey: string;
                dataType: number;
                dateValue: Date
                | null;
                eventId: string;
                eventName: string;
                numberValue: number | null;
                sessionId: string;
                stringValue: string;
                urlPath: string;
                websiteId: string;
            }[],
        >

    getWebsiteEvents: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps & GenericRequestParameters,
    ) => Promise<
        {
            browser: string;
            city: string;
            country: string;
            createdAt: Date;
            device: string;
            eventName: string;
            eventType: number;
            hasData: number;
            hostname: string;
            id: string;
            os: string;
            pageTitle: string;
            referrerDomain: string;
            referrerPath: string;
            referrerQuery: string;
            sessionId: string;
            urlPath: string;
            urlQuery: string;
            websiteId: string;
        }[],
    > = Events.getWebsiteEvents

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: Filters & Timestamps & GenericRequestParameters,
        ): Promise<
            {
                browser: string;
                city: string;
                country: string;
                createdAt: Date;
                device: string;
                eventName: string;
                eventType: number;
                hasData: number;
                hostname: string;
                id: string;
                os: string;
                pageTitle: string;
                referrerDomain: string;
                referrerPath: string;
                referrerQuery: string;
                sessionId: string;
                urlPath: string;
                urlQuery: string;
                websiteId: string;
            }[],
        >
      • Gets website event details within a given time range: https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevents (TODO UNTESTED)

        Parameters

        Returns Promise<
            {
                browser: string;
                city: string;
                country: string;
                createdAt: Date;
                device: string;
                eventName: string;
                eventType: number;
                hasData: number;
                hostname: string;
                id: string;
                os: string;
                pageTitle: string;
                referrerDomain: string;
                referrerPath: string;
                referrerQuery: string;
                sessionId: string;
                urlPath: string;
                urlQuery: string;
                websiteId: string;
            }[],
        >

    getWebsiteEventsData: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps & { event?: string },
    ) => Promise<
        {
            dataType: number;
            eventName: string;
            propertyName: string;
            total: number;
        }[],
    > = Events.getWebsiteEventsData

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: Filters & Timestamps & { event?: string },
        ): Promise<
            {
                dataType: number;
                eventName: string;
                propertyName: string;
                total: number;
            }[],
        >
      • Gets event data names, properties, and counts: https://umami.is/docs/api/events-api#get-apiwebsiteswebsiteidevent-dataevents (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: Filters & Timestamps & { event?: string }
          • Optionalevent?: string

            Event name filter

        Returns Promise<
            {
                dataType: number;
                eventName: string;
                propertyName: string;
                total: number;
            }[],
        >

    getWebsiteEventsDataFields: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps,
    ) => Promise<
        { dataType: number; propertyName: string; total: number; value: string }[],
    > = Events.getWebsiteEventsDataFields

    Type Declaration

    getWebsiteEventsDataProperties: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps,
    ) => Promise<{ eventName: string; propertyName: string; total: number }[]> = Events.getWebsiteEventsDataProperties

    Type Declaration

    getWebsiteEventsDataStats: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps,
    ) => Promise<{ events: number; properties: number; records: number }[]> = Events.getWebsiteEventsDataStats

    Type Declaration

    getWebsiteEventsDataValues: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps & { event: string; propertyName: string },
    ) => Promise<{ total: number; value: string }> = Events.getWebsiteEventsDataValues

    Type Declaration

    getWebsiteEventsStats: (
        this: API,
        websiteId: string,
        parameters: Timestamps & Units & Filters & { timezone: string },
    ) => Promise<XTY[]> = WebsiteStats.getWebsiteEvents

    Type Declaration

    getWebsiteMetrics: (
        this: API,
        websiteId: string,
        parameters: Timestamps & Units & Filters & {
            limit?: number;
            offset?: number;
            timezone: string;
            type: MetricsTypes;
        },
    ) => Promise<{ x: string; y: number }[]> = WebsiteStats.getWebsiteMetrics

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: Timestamps & Units & Filters & {
                limit?: number;
                offset?: number;
                timezone: string;
                type: MetricsTypes;
            },
        ): Promise<{ x: string; y: number }[]>
      • Gets metrics for a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidmetrics (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: Timestamps & Units & Filters & {
              limit?: number;
              offset?: number;
              timezone: string;
              type: MetricsTypes;
          }
          • Optionallimit?: number

            (optional, default 500) Number of rows returned

          • Optionaloffset?: number

            (optional, default 0) Number of ows to skip

          • timezone: string

            Timezone (ex. America/Los_Angeles)

          • type: MetricsTypes

            Metrics type

        Returns Promise<{ x: string; y: number }[]>

    getWebsiteMetricsExpanded: (
        this: API,
        ...args: [
            websiteId: string,
            parameters: Timestamps & Units & Filters & {
                limit?: number;
                offset?: number;
                timezone: string;
                type: MetricsTypes;
            },
        ],
    ) => Promise<(Stats & { name: string })[]> = WebsiteStats.getWebsiteMetricsExpanded

    Type Declaration

    getWebsitePageviews: (
        this: API,
        websiteId: string,
        parameters: Timestamps & Units & Filters & {
            compare?: string;
            timezone: string;
        },
    ) => Promise<
        {
            pageviews: { x: Date; y: number }[];
            sessions: { x: Date; y: number }[];
        },
    > = WebsiteStats.getWebsitePageviews

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: Timestamps & Units & Filters & {
                compare?: string;
                timezone: string;
            },
        ): Promise<
            {
                pageviews: { x: Date; y: number }[];
                sessions: { x: Date; y: number }[];
            },
        >
      • Gets pageviews within a given time range: https://umami.is/docs/api/website-stats-api#get-apiwebsiteswebsiteidpageviews (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • parameters: Timestamps & Units & Filters & { compare?: string; timezone: string }
          • Optionalcompare?: string

            Comparison value prev | yoy

          • timezone: string

            Timezone (ex. America/Los_Angeles)

        Returns Promise<
            {
                pageviews: { x: Date; y: number }[];
                sessions: { x: Date; y: number }[];
            },
        >

    getWebsites: (
        this: API,
        parameters: GenericRequestParameters & { includeTeams: boolean },
    ) => Promise<(Website & { user: MinimalUser })[]> = Websites.getWebsites

    Type Declaration

    getWebsitesAsAdmin: (
        this: API,
        parameters?: GenericRequestParameters,
    ) => Promise<(Website & { team: string | null; user: MinimalUser })[]> = Admin.getWebsites

    Type Declaration

    getWebsiteSession: (
        this: API,
        websiteId: string,
        sessionId: string,
    ) => Promise<
        GenericSession & {
            distinctId: string;
            events: number;
            totaltime: number;
        },
    > = Sessions.getWebsiteSession

    Type Declaration

    getWebsiteSessionActivity: (
        this: API,
        websiteId: string,
        sessionId: string,
        parameters: Timestamps,
    ) => Promise<
        {
            createdAt: Date;
            eventId: string;
            eventName: string;
            eventType: number;
            hasData: number;
            referrerDomain: string;
            urlPath: string;
            urlQuery: string;
            visitId: string;
        }[],
    > = Sessions.getWebsiteSessionActivity

    Type Declaration

      • (
            this: API,
            websiteId: string,
            sessionId: string,
            parameters: Timestamps,
        ): Promise<
            {
                createdAt: Date;
                eventId: string;
                eventName: string;
                eventType: number;
                hasData: number;
                referrerDomain: string;
                urlPath: string;
                urlQuery: string;
                visitId: string;
            }[],
        >
      • Gets session activity for a individual session: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionssessionidactivity (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • sessionId: string
        • parameters: Timestamps

        Returns Promise<
            {
                createdAt: Date;
                eventId: string;
                eventName: string;
                eventType: number;
                hasData: number;
                referrerDomain: string;
                urlPath: string;
                urlQuery: string;
                visitId: string;
            }[],
        >

    getWebsiteSessionDataProperties: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps,
    ) => Promise<{ propertyName: string; total: number }[]> = Sessions.getWebsiteSessionDataProperties

    Type Declaration

    getWebsiteSessionDataValues: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps & { propertyName: string },
    ) => Promise<{ total: number; value: string }[]> = Sessions.getWebsiteSessionDataValues

    Type Declaration

    getWebsiteSessionProperties: (
        this: API,
        websiteId: string,
        sessionId: string,
    ) => Promise<
        {
            createdAt: Date;
            dataKey: string;
            dataType: number;
            dateValue: Date
            | null;
            numberValue: number | null;
            sessionid: string;
            stringValue: string;
            websiteId: string;
        }[],
    > = Sessions.getWebsiteSessionProperties

    Type Declaration

      • (
            this: API,
            websiteId: string,
            sessionId: string,
        ): Promise<
            {
                createdAt: Date;
                dataKey: string;
                dataType: number;
                dateValue: Date
                | null;
                numberValue: number | null;
                sessionid: string;
                stringValue: string;
                websiteId: string;
            }[],
        >
      • Gets session properties for a individual session: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO UNTESTED)

        Parameters

        • this: API
        • websiteId: string
        • sessionId: string

        Returns Promise<
            {
                createdAt: Date;
                dataKey: string;
                dataType: number;
                dateValue: Date
                | null;
                numberValue: number | null;
                sessionid: string;
                stringValue: string;
                websiteId: string;
            }[],
        >

    getWebsiteSessions: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps & GenericRequestParameters,
    ) => Promise<(GenericSession & { createdAt: Date; hostname: string })[]> = Sessions.getWebsiteSessions

    Type Declaration

    getWebsiteSessionsStats: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps,
    ) => Promise<
        {
            bounces: { value: number };
            pageviews: { value: number };
            totaltime: { value: number };
            visitors: { value: number };
            visits: { value: number };
        },
    > = Sessions.getWebsiteSessionsStats

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: Filters & Timestamps,
        ): Promise<
            {
                bounces: { value: number };
                pageviews: { value: number };
                totaltime: { value: number };
                visitors: { value: number };
                visits: { value: number };
            },
        >
      • Gets summarized website session statistics: https://umami.is/docs/api/sessions-api#get-apiwebsiteswebsiteidsessionsstats (TODO UNTESTED)

        Parameters

        Returns Promise<
            {
                bounces: { value: number };
                pageviews: { value: number };
                totaltime: { value: number };
                visitors: { value: number };
                visits: { value: number };
            },
        >

    getWebsiteSessionsWeekly: (
        this: API,
        websiteId: string,
        parameters: Filters & Timestamps & { timezone: string },
    ) => Promise<number[][]> = Sessions.getWebsiteSessionsWeekly

    Type Declaration

    getWebsiteStats2: (
        this: API,
        websiteId: string,
        parameters: Timestamps & Filters & Units & { timezone: string },
    ) => Promise<Stats & { comparison: Stats }> = WebsiteStats.getWebsiteStats

    Type Declaration

    Will replace API.getWebsiteStats, which you should use for a reliable experience

    joinTeam: (this: API, accessCode: string) => Promise<Omit<TeamMember, "user">> = Teams.joinTeam

    Type Declaration

    removeTeamUser: (
        this: API,
        teamId: string,
        userId: string,
    ) => Promise<{ ok: boolean }> = Teams.removeTeamUser

    Type Declaration

    resetWebsite: (this: API, websiteId: string) => Promise<{ ok: boolean }> = Websites.resetWebsite

    Type Declaration

    updateReport: (
        this: API,
        reportId: string,
        websiteId: string,
        parameters: ReportType & {
            description?: string;
            name: string;
            parameters?: any;
        },
    ) => Promise<Report> = Reports.updateReport

    Type Declaration

      • (
            this: API,
            reportId: string,
            websiteId: string,
            parameters: ReportType & {
                description?: string;
                name: string;
                parameters?: any;
            },
        ): Promise<Report>
      • Parameters

        • this: API
        • reportId: string
        • websiteId: string
        • parameters: ReportType & { description?: string; name: string; parameters?: any }
          • Optionaldescription?: string

            Description of report

          • name: string

            Name of report

          • Optionalparameters?: any

            Parameters for report

        Returns Promise<Report>

    updateTeam: (
        this: API,
        teamId: string,
        parameters: { accessCode?: string; name?: string },
    ) => Promise<GenericTeam> = Teams.updateTeam

    Type Declaration

    updateTeamUser: (
        this: API,
        teamId: string,
        userId: string,
        role: TeamRole,
    ) => Promise<Omit<TeamMember, "user">> = Teams.updateTeamUser

    Type Declaration

    updateUser: (
        this: API,
        id: string,
        parameters?: { password?: string; role?: Role; username?: string },
    ) => Promise<GenericUser & { createdAt: Date }> = Users.updateUser

    Type Declaration

      • (
            this: API,
            id: string,
            parameters?: { password?: string; role?: Role; username?: string },
        ): Promise<GenericUser & { createdAt: Date }>
      • Parameters

        • this: API
        • id: string
        • Optionalparameters: { password?: string; role?: Role; username?: string }
          • Optionalpassword?: string

            The user's password

          • Optionalrole?: Role

            The user's role

          • Optionalusername?: string

            The user's username

        Returns Promise<GenericUser & { createdAt: Date }>

    updateWebsite: (
        this: API,
        websiteId: string,
        parameters: { domain: string; name: string; shareId?: string | null },
    ) => Promise<Website> = Websites.updateWebsite

    Type Declaration

      • (
            this: API,
            websiteId: string,
            parameters: { domain: string; name: string; shareId?: string | null },
        ): Promise<Website>
      • Parameters

        • this: API
        • websiteId: string
        • parameters: { domain: string; name: string; shareId?: string | null }
          • domain: string

            The full domain of the tracked website

          • name: string

            The name of the website in Umami

          • OptionalshareId?: string | null

            A unique string to enable a share url. Set null to unshare

        Returns Promise<Website>

    Accessors

    • get expires(): Date

      The expiration date of your token

      Returns Date

    • set expires(date: Date): void

      Parameters

      • date: Date

      Returns void

    • get headers(): { [key: string]: any }

      Used in practically all requests, those are all the headers the package uses excluding Authorization, the one with the token

      Returns { [key: string]: any }

    • set headers(headers: { [key: string]: any }): void

      Parameters

      • headers: { [key: string]: any }

      Returns void

    • get password(): string

      The password of the account

      Returns string

    • set password(password: string): void

      Parameters

      • password: string

      Returns void

    • get retry_delay(): number

      In seconds, how long should it wait after a request failed before retrying? (defaults to 2)

      Returns number

    • set retry_delay(retry_delay: number): void

      Parameters

      • retry_delay: number

      Returns void

    • get retry_maximum_amount(): number

      How many retries maximum before throwing an APIError (defaults to 4)

      Returns number

      Pro tip: Set that to 0 to completely disable retries!

    • set retry_maximum_amount(retry_maximum_amount: number): void

      Parameters

      • retry_maximum_amount: number

      Returns void

    • get retry_on_new_token(): boolean

      Should it retry a request upon successfully setting a new token due to API.set_token_on_401 being true? (defaults to true)

      Returns boolean

    • set retry_on_new_token(retry_on_new_token: boolean): void

      Parameters

      • retry_on_new_token: boolean

      Returns void

    • get retry_on_status_codes(): number[]

      Upon failing a request and receiving a response, because of which received status code should the request be retried? (defaults to [429])

      Returns number[]

    • set retry_on_status_codes(retry_on_status_codes: number[]): void

      Parameters

      • retry_on_status_codes: number[]

      Returns void

    • get retry_on_timeout(): boolean

      Should it retry a request if that request failed because it has been aborted by the API.timeout? (defaults to false)

      Returns boolean

    • set retry_on_timeout(retry_on_timeout: boolean): void

      Parameters

      • retry_on_timeout: boolean

      Returns void

    • get server(): string

      The base URL where requests should land, should include the /api portion if applicable

      Returns string

    • set server(server: string): void

      Parameters

      • server: string

      Returns void

    • get set_token_on_401(): boolean

      If true, upon failing a request due to a 401, it will call API.setNewToken (defaults to true)

      Returns boolean

    • set set_token_on_401(bool: boolean): void

      Parameters

      • bool: boolean

      Returns void

    • get set_token_on_expires(): boolean

      If true, the application will silently call API.setNewToken when the API.token is set to expire, as determined by API.expires (defaults to false)

      Returns boolean

    • set set_token_on_expires(enabled: boolean): void

      Parameters

      • enabled: boolean

      Returns void

    • get signal(): AbortSignal | undefined

      The AbortSignal used in every request

      Returns AbortSignal | undefined

    • set signal(signal: AbortSignal | undefined): void

      Parameters

      • signal: AbortSignal | undefined

      Returns void

    • get timeout(): number

      The maximum amount of seconds requests should take before returning an answer (defaults to 20)

      Returns number

      0 means no maximum, no timeout

    • set timeout(timeout: number): void

      Parameters

      • timeout: number

      Returns void

    • get token(): string

      The key that allows you to talk with the API

      Returns string

    • set token(token: string): void

      Parameters

      • token: string

      Returns void

    • get token_timer(): Timeout | undefined

      Returns Timeout | undefined

    • set token_timer(timer: Timeout): void

      Parameters

      • timer: Timeout

      Returns void

    • get token_type(): string

      Should always be "Bearer"

      Returns string

    • set token_type(token: string): void

      Parameters

      • token: string

      Returns void

    • get user(): {
          createdAt: Date;
          id: string;
          isAdmin: boolean;
          role: string;
          username: string;
      }

      Information about the account that has been used to log in

      Returns {
          createdAt: Date;
          id: string;
          isAdmin: boolean;
          role: string;
          username: string;
      }

    • set user(
          user: {
              createdAt: Date;
              id: string;
              isAdmin: boolean;
              role: string;
              username: string;
          },
      ): void

      Parameters

      • user: {
            createdAt: Date;
            id: string;
            isAdmin: boolean;
            role: string;
            username: string;
        }

      Returns void

    • get username(): string

      The username of the account

      Returns string

    • set username(username: string): void

      Parameters

      • username: string

      Returns void

    • get verbose(): "none" | "errors" | "all" | undefined

      Which events should be logged (defaults to none)

      Returns "none" | "errors" | "all" | undefined

    • set verbose(verbose: "none" | "errors" | "all" | undefined): void

      Parameters

      • verbose: "none" | "errors" | "all" | undefined

      Returns void

    Methods

    • Parameters

      • website_id: string
      • startAt: Date
      • endAt: Date

      Returns Promise<
          {
              bounces: ValueAndPrev;
              pageviews: ValueAndPrev;
              totaltime: ValueAndPrev;
              visitors: ValueAndPrev;
              visits: ValueAndPrev;
          },
      >

      To be replaced by API.getWebsiteStats2, no deprecation warning as the new method is unreliable

    • The function that directly communicates with the API! Almost all functions of the API object uses this function!

      Parameters

      • method: "get" | "post" | "put" | "delete"

        The type of request, each endpoint uses a specific one (if it uses multiple, the intent and parameters become different)

      • endpoint: (string | number)[]

        What comes in the URL after api/, DO NOT USE TEMPLATE LITERALS (`) OR THE ADDITION OPERATOR (+), put everything separately for type safety

      • parameters: { [k: string]: any } = {}

        The things to specify in the request, such as the beatmap_id when looking for a beatmap

      Returns Promise<any>

      A Promise with the API's response

    • This contacts the server in order to get and set a new API.token!

      Returns Promise<boolean>

      Whether or not the token has changed (should be true as otherwise the server would complain and an APIError would be thrown to give you some details)

      The API object requires a API.username and a API.password to successfully get any token