const res = await fetch("https://api.openrevenue.com/api/v1/projects/example.com/stats?period=30d", {
headers: { Authorization: `Bearer ${OPENREVENUE_API_KEY}` },
})
const stats = await res.json()
curl "https://api.openrevenue.com/api/v1/projects/example.com/stats?period=30d" \
-H "Authorization: Bearer openrevenue_your_key"
{
"period": "30d",
"pageviews": 130,
"visitors": 35,
"sessions": 48,
"avgDurationSeconds": 94
}
Stats
Returns aggregate stats for a project over the given period: total pageviews, unique visitors, sessions, and average session duration in seconds.
GET
/
api
/
v1
/
projects
/
{domain}
/
stats
const res = await fetch("https://api.openrevenue.com/api/v1/projects/example.com/stats?period=30d", {
headers: { Authorization: `Bearer ${OPENREVENUE_API_KEY}` },
})
const stats = await res.json()
curl "https://api.openrevenue.com/api/v1/projects/example.com/stats?period=30d" \
-H "Authorization: Bearer openrevenue_your_key"
{
"period": "30d",
"pageviews": 130,
"visitors": 35,
"sessions": 48,
"avgDurationSeconds": 94
}
Time period. See Periods on Account API page. Defaults to 30d.
Response
Errors
| Status | Error | Description |
|---|---|---|
401 | Invalid or missing API key | The Authorization header is missing or the Bearer token is invalid. |
404 | Project not found | No project with that domain exists for the authenticated user. |
const res = await fetch("https://api.openrevenue.com/api/v1/projects/example.com/stats?period=30d", {
headers: { Authorization: `Bearer ${OPENREVENUE_API_KEY}` },
})
const stats = await res.json()
curl "https://api.openrevenue.com/api/v1/projects/example.com/stats?period=30d" \
-H "Authorization: Bearer openrevenue_your_key"
{
"period": "30d",
"pageviews": 130,
"visitors": 35,
"sessions": 48,
"avgDurationSeconds": 94
}
Was this page helpful?