Skip to main content

umami_api/website_stats/
mod.rs

1use serde::Deserialize;
2
3use crate::{Timestamps, Umami, website_stats::get_stats::GetStatsRequestBuilder};
4
5pub mod get_stats;
6
7#[derive(Clone, Debug, Deserialize)]
8pub struct Stats {
9  /// Page hits
10  pub pageviews: u64,
11  /// Number of unique visitors
12  pub visitors: u64,
13  /// Number of unique visitors
14  pub visits: u64,
15  /// Number of visitors who only visit a single page
16  pub bounces: u64,
17  /// Time spent on the website
18  pub totaltime: u64,
19}
20
21#[derive(Clone, Debug, Deserialize)]
22pub struct StatsWithComparison {
23  /// The Stats for a given time period
24  #[serde(flatten)]
25  pub base: Stats,
26  /// The Stats for a time period which is of the same length as a given time period, and ends when that given time period begins
27  pub comparison: Stats,
28}
29
30impl Umami {
31  // Gets summarized website statistics: <https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidstats>
32  pub fn get_stats(
33    &'_ self,
34    website_id: impl Into<String>,
35    timestamps: Timestamps,
36  ) -> GetStatsRequestBuilder<'_> {
37    GetStatsRequestBuilder::new(self, website_id.into(), timestamps)
38  }
39}