pub struct PlausibleClient { /* private fields */ }Expand description
High-level Plausible API client.
Implementations§
Source§impl PlausibleClient
impl PlausibleClient
Sourcepub fn new(api_key: impl Into<String>) -> Result<Self, ClientError>
pub fn new(api_key: impl Into<String>) -> Result<Self, ClientError>
Create a new client targeting the public Plausible API endpoint.
Sourcepub fn with_base_url(
api_key: impl Into<String>,
base_url: Url,
) -> Result<Self, ClientError>
pub fn with_base_url( api_key: impl Into<String>, base_url: Url, ) -> Result<Self, ClientError>
Create a client with a custom base URL (useful for self-hosted Plausible).
Sourcepub fn user_agent(&self) -> &str
pub fn user_agent(&self) -> &str
Returns the configured user agent string.
Sourcepub async fn list_sites(&self) -> Result<Vec<SiteSummary>, ClientError>
pub async fn list_sites(&self) -> Result<Vec<SiteSummary>, ClientError>
Fetch the list of sites accessible to the API key.
Sourcepub async fn create_site(
&self,
request: &CreateSiteRequest,
) -> Result<SiteSummary, ClientError>
pub async fn create_site( &self, request: &CreateSiteRequest, ) -> Result<SiteSummary, ClientError>
Create a Plausible site.
Sourcepub async fn update_site(
&self,
site_id: &str,
request: &UpdateSiteRequest,
) -> Result<SiteSummary, ClientError>
pub async fn update_site( &self, site_id: &str, request: &UpdateSiteRequest, ) -> Result<SiteSummary, ClientError>
Update mutable properties for a Plausible site.
Sourcepub async fn reset_site_stats(
&self,
site_id: &str,
request: &ResetSiteStatsRequest,
) -> Result<(), ClientError>
pub async fn reset_site_stats( &self, site_id: &str, request: &ResetSiteStatsRequest, ) -> Result<(), ClientError>
Reset statistics for a site.
Sourcepub async fn delete_site(&self, site_id: &str) -> Result<(), ClientError>
pub async fn delete_site(&self, site_id: &str) -> Result<(), ClientError>
Delete a Plausible site.
Sourcepub async fn stats_aggregate(
&self,
query: &AggregateQuery,
) -> Result<AggregateResponse, ClientError>
pub async fn stats_aggregate( &self, query: &AggregateQuery, ) -> Result<AggregateResponse, ClientError>
Query aggregate statistics for a site.
Sourcepub async fn stats_timeseries(
&self,
query: &TimeseriesQuery,
) -> Result<TimeseriesResponse, ClientError>
pub async fn stats_timeseries( &self, query: &TimeseriesQuery, ) -> Result<TimeseriesResponse, ClientError>
Query timeseries statistics for a site.
Sourcepub async fn stats_breakdown(
&self,
query: &BreakdownQuery,
) -> Result<BreakdownResponse, ClientError>
pub async fn stats_breakdown( &self, query: &BreakdownQuery, ) -> Result<BreakdownResponse, ClientError>
Query breakdown statistics for a site.
Sourcepub async fn stats_realtime_visitors(
&self,
site_id: &str,
) -> Result<RealtimeVisitorsResponse, ClientError>
pub async fn stats_realtime_visitors( &self, site_id: &str, ) -> Result<RealtimeVisitorsResponse, ClientError>
Fetch realtime visitor counts.
Sourcepub async fn send_event(&self, event: &Value) -> Result<(), ClientError>
pub async fn send_event(&self, event: &Value) -> Result<(), ClientError>
Send a custom event to Plausible.
Trait Implementations§
Source§impl Clone for PlausibleClient
impl Clone for PlausibleClient
Source§fn clone(&self) -> PlausibleClient
fn clone(&self) -> PlausibleClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PlausibleClient
impl !RefUnwindSafe for PlausibleClient
impl Send for PlausibleClient
impl Sync for PlausibleClient
impl Unpin for PlausibleClient
impl !UnwindSafe for PlausibleClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more