Sha256: f7cf1c3ab2e37885be81e46cf800abd9dd0cb60d93f34127e5c5386d48a71029
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
# Plausible API (Work In Progress) This is a simple wrapper to read the Plausible API with Ruby. It's based on the WIP [API guide](https://plausible.io/docs/stats-api) ## Usage Add this gem to your Gemfile: ```rb gem 'plausible_api' ``` Then you need to initialize a Client with your `site_id` (the domain) and your `token`. ```rb c = PlausibleApi::Client.new(site_id: 'dailytics.com', token: '123123') ``` ### Stats > Aggregate You have all these options to get the aggregate stats ```rb # Use the default parameters (3mo period + the 4 main metrics) c.aggregate # Set parameters (period, metrics, filter, date) c.aggregate({ period: '30d' }) c.aggregate({ period: '30d', metrics: 'visitors,pageviews' }) c.aggregate({ period: '30d', metrics: 'visitors,pageviews', filters: 'event:page==/order/confirmation' }) # You'll get something like this: => {"bounce_rate"=>{"value"=>81.0}, "pageviews"=>{"value"=>29}, "visit_duration"=>{"value"=>247.0}, "visitors"=>{"value"=>14}} ``` ### Stats > Timeseries You have all these options to get the timeseries ```rb # Use the default parameters (3mo period) c.timeseries # Set parameters (period, metrics, filter, date) c.timeseries({ period: '7d' }) c.timeseries({ period: '7d', filters: 'event:page==/order/confirmation', date: '2020/02/10' }) # You'll get something like this: => [{"date"=>"2021-01-11", "value"=>100}, {"date"=>"2021-01-12", "value"=>120}, {"date"=>"2021-01-13", "value"=>80}...] ``` ### Realtime >> Visitors You have a uniq way to call this data ```rb c.realtime_visitors ``` ## Development ``` $ gem build plausible_api.gemspec $ gem install ./plausible_api-X.X.X.gem $ irb irb(main) > require 'plausible_api' ``` ## Todo - Tests - Options validation
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plausible_api-0.0.3 | README.md |