Swift SDK for the Plausible Analytics API, focused on Apple-platform dashboard apps and event tracking.
Use it to build native iOS/macOS analytics dashboards with the Stats API v2 and Sites API, with Events API ingestion included for pageviews and custom events.
- Apple-only Swift Package with Swift Concurrency-first API
- Public
import Plausiblesurface with split modules underneath:PlausibleCorePlausibleAPIPlausibleTracker
- Stats API v2 support:
- typed metrics and dimensions
- custom date ranges
- simple, logical, behavioral, and segment filters
- ordering, includes, and pagination
- Sites API support:
- sites and teams
- shared links
- goals
- custom properties
- guests
- Tracker support:
- pageviews
- custom events and properties
- revenue and non-interactive events
- dropped-event detection
- Raw API escape hatch for upstream routes not yet wrapped
- iOS 15+
- macOS 12+
- tvOS 15+
- watchOS 8+
- visionOS 1+
- Swift tools 6.0+
Add to Package.swift:
dependencies: [ .package(url: "https://github.com/wiedymi/swift-plausible.git", from: "0.1.0") ]
Then add the library target:
.target( name: "YourApp", dependencies: [ .product(name: "Plausible", package: "swift-plausible") ] )
import Foundation import Plausible let configuration = PlausibleConfiguration( baseURL: URL(string: "https://plausible.io")!, userAgent: "MyDashboard/1.0" ) let client = PlausibleAPIClient( configuration: configuration, auth: .apiKey("your-stats-api-key") ) let response = try await client.stats.query( .init( siteID: "example.com", metrics: [.visitors, .pageviews, .bounceRate], dateRange: .last30Days, dimensions: [.timeDay], include: .init(timeLabels: true) ) ) for row in response.results { print(row.dimensions, row.metrics) }
import Foundation import Plausible let tracker = PlausibleTrackerClient(domain: "example.com") try await tracker.pageview(url: "https://example.com/pricing") try await tracker.event( name: "Purchase", url: "https://example.com/checkout", props: ["plan": "team", "seats": 5], revenue: .init(currency: "USD", amount: Decimal(string: "99.00")!) )
swift build
swift testSPEC.md- SDK scope and implementation plan- Plausible upstream source - optional reference, not included in package checkouts
- Plausible Stats API
- Plausible Sites API
- Plausible Events API
baseURLdefaults tohttps://plausible.io; set it to your self-hosted Plausible server origin when needed.- Stats and Sites requests use bearer API keys, while Events API requests are unauthenticated.
- Plausible derives unique visitors from the
User-Agentand client IP. Servers relaying app events should setEventRequest.forwardedForto the end user's IP. - Set
interactive: falseon a custom event to exclude it from bounce-rate calculations. - API contracts were validated against the Plausible documentation on July 20, 2026, and the upstream commit pinned in
SPEC.md.
MIT