Basic Query - Total Visitors
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors", "pageviews"],
"date_range": "7d"
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```
Docs: https://plausible.io/docs/stats-api
Query with Dimensions (Breakdown)
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors", "pageviews", "bounce_rate"],
"date_range": "30d",
"dimensions": ["visit:source"]
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```
Top Pages
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors", "pageviews"],
"date_range": "7d",
"dimensions": ["event:page"],
"order_by": [["pageviews", "desc"]],
"pagination": {
"limit": 10
}
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```
Geographic Breakdown
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors"],
"date_range": "30d",
"dimensions": ["visit:country_name", "visit:city_name"]
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```
Device & Browser Stats
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors"],
"date_range": "7d",
"dimensions": ["visit:device"]
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```
Time Series (Daily)
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors", "pageviews"],
"date_range": "30d",
"dimensions": ["time:day"]
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```
Filter by Page Path
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors", "pageviews"],
"date_range": "7d",
"filters": [["contains", "event:page", ["/blog"]]]
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```
UTM Campaign Analysis
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors", "conversion_rate"],
"date_range": "30d",
"dimensions": ["visit:utm_source", "visit:utm_campaign"]
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```
Custom Date Range
Write to /tmp/plausible_request.json:
```json
{
"site_id": "",
"metrics": ["visitors", "pageviews"],
"date_range": ["2024-01-01", "2024-01-31"]
}
```
Replace with your actual site ID (typically your domain like "example.com"):
```bash
bash -c 'curl -s -X POST "https://plausible.io/api/v2/query" -H "Authorization: Bearer $PLAUSIBLE_API_KEY" -H "Content-Type: application/json" -d @/tmp/plausible_request.json'
```