Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/plausible/index.ts>default

A zero-dependency, TypeScript library for interacting with the Plausible Analytics API, written in Deno!
Latest
class default
import { default } from "https://deno.land/x/plausible@v2.2.1/index.ts";

Constructors

new
default(
key: string,
site: string,
url?: string | null,
)

Properties

private
key: string
private
site: string
private
url: string

Methods

private
getAbstract(path: string, params?: URLSearchParams): Promise<any>
getAggregate<Compare extends boolean>(
period: Period,
metric: Metrics,
compare?: Compare | null,
filters?: string | null,
date?: string | null,
): Promise<Aggregated<Compare>>

This function aggregates metrics over a certain time period. If you are familiar with the Plausible dashboard, this function corresponds to the top row of stats that include Unique Visitors, Pageviews, Bounce rate and Visit duration. You can retrieve any number and combination of these metrics in one request.

getBreakdown<Property extends Properties, Metric extends Metrics>(
period: Period,
metric: Metric,
property: Property,
filter?: string | null,
limit?: number | null,
page?: number | null,
date?: string | null,
): Promise<Breakdowns<Property, Metric>>

This function allows you to breakdown your stats by some property. If you are familiar with SQL family databases, this function corresponds to running GROUP BY on a certain property in your stats.

Check out the properties section for a reference of all the properties you can use in this query.

getRealtime(): Promise<number>

This function returns the number of current visitors on your site. A current visitor is defined as a visitor who triggered a pageview on your site in the last 5 minutes.

getTimeseries<Metric extends Metrics>(
period: Period,
metric: Metric,
filters?: string | null,
interval?: Interval | null,
date?: string | null,
): Promise<Datapoints<Metric>>

This function provides timeseries data over a certain time period. If you are familiar with the Plausible dashboard, this function corresponds to the main visitor graph.