@suhodolskiy/plausible-api
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Plausible Stats

A simple wrapper over Plausible API

Installation

$ npm install @suhodolskiy/plausible-api

Example

import Plausible from '@suhodolskiy/plausible-api'

const stats = new Plausible.Stats({
  apiUrl: 'https://plausible.io', // or your own domain
  apiKey: '',
})

Realtime Visitors

const result = await stats.realtimeVisitors('siteId')

console.log(result) // 99

Breakdown Stats

const results = await stats.breakdown('siteId', 'event:props:method', {
  period: '6mo',
  filters: {
    'event:name': 'Download',
  },
})

console.log(results)
[
  {
    "method": "HTTP",
    "visitors": 1477
  },
  {
    "method": "Magnet",
    "visitors": 370
  }
]

Readme

Keywords

Package Sidebar

Install

npm i @suhodolskiy/plausible-api

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

35.3 kB

Total Files

19

Last publish

Collaborators

  • suhodolskiy