Expand description
HTTP client-agnostic Rust bindings for the Matomo Reporting API, focused on data export and migration.
The crate is split into a transport-agnostic core (Client, Endpoint,
Query) and an optional reqwest-backed transport behind a feature
flag. Bring your own HTTP client by implementing Client.
Matomo’s API is a single dispatch endpoint: every call is a
POST {base}/index.php with a module=API&method=Module.action&format=json
form body. Errors arrive as HTTP 200 with a {"result":"error",...} JSON
envelope rather than via status codes, so Endpoint::parse_response
detects that envelope instead of mapping status codes.
§Features
reqwest— enablescrate::reqwest::MatomoClient, a ready-madeClient. No TLS backend is selected by default; pair it with one below.reqwest-rustls—reqwestwithrustls.reqwest-native-tls—reqwestwith the OS-native TLS stack.chrono/time—Fromconversions intoDate.
All features are off by default. If none of the reqwest-* features fit,
implement Client yourself against any HTTP backend.
Re-exports§
pub use reqwest::Cursor;pub use reqwest::MatomoClient;pub use reqwest::MatomoClientError;pub use reqwest::VisitStream;
Modules§
- endpoints
Endpointimpls for each typed Matomo call. These build aParamsbag and name aModule.action; the blanketcrate::Queryturns them into a request. They carry no transport.- reqwest
reqwest-backedClientimplementation and the ergonomic high-level API.
Structs§
- Action
Page - A node in
Actions.getPageUrls/Actions.getPageTitles. These are recursive trees: a node may carry an inlinesubtable(when Matomo is queried withflat=0and expanded) or just anidsubdatatablepointer to fetch the children separately. - Download
Actions.getDownloadsrow.- Goal
Conversion - A goal conversion attached to a visit.
- Outlink
Actions.getOutlinksrow.- Params
- A reusable, standalone bag of API call parameters.
- Referrer
All Referrers.getAllrow. Note Matomo’s misspelledreferer_typefield.- Referrer
Type Referrers.getReferrerTyperow. Note the field isreferrer_typehere.- Segment
- A raw segment expression. Passed verbatim in the POST body; reqwest url-encodes it for us, so do not pre-encode.
- Visit
- A single visit from
Live.getLastVisitsDetails. - Visits
Summary VisitsSummary.get. Note the mixed numerics:bounce_rateis a string like"64%",nb_actions_per_visitis a float, the rest are ints.
Enums§
- Action
Detail - An entry in
actionDetails. Internally tagged on Matomo’stypefield.actionanddownloadare typed precisely from harvested data; the others are modeled minimally; anything else falls through toUnknownfor forward-compat. Never#[serde(untagged)]. - ApiError
Kind - Best-effort classification of an API error, sniffed from the message text. This is a heuristic; Matomo does not return machine-readable error codes.
- Auth
- How the client authenticates against the Matomo instance.
- Date
- A Matomo date in its query grammar.
- Date
Range - A date range used with
Period::Range. Matomo only accepts a single rolling keyword (lastN/previousN) or an absolute start paired with an absolute ortoday/yesterdayend — a keyword start likelast7,todayis rejected, so it is unrepresentable here. - Error
- IdSite
- One or more site ids, or all sites.
- Limit
filter_limit.Allmaps to-1.- Parse
Error - Outcome of
Endpoint::parse_response, lifted intoQueryErrorby the blanketQueryimpl. - Period
- A period paired with the date(s) it applies to. Illegal (period, date)
combinations are unrepresentable:
Rangecarries its ownDateRange, the others carry a singleDate. - Query
Error - Error returned by
Query::execute, generic over the transport error. - Range
End - The end of an absolute-start range. Matomo accepts an absolute date or the
today/yesterdaykeywords here, but notlastN-style keywords. - Visitor
Type
Traits§
- Client
- A transport capable of dispatching a single Matomo API request.
- Endpoint
- A single Matomo API endpoint: its
Module.actionmethod name, its form params, and how to decode the response. - Query
- An asynchronous query against a
Client.