@suhodolskiy/plausible-api
v1.0.0
Published
A simple wrapper over Plausible API
Downloads
4
Readme
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
}
]