const res = await fetch("https://api.openrevenue.com/api/v1/projects/example.com/cities?period=30d", {
headers: { Authorization: `Bearer ${OPENREVENUE_API_KEY}` },
})
const cities = await res.json()
curl "https://api.openrevenue.com/api/v1/projects/example.com/cities?period=30d" \
-H "Authorization: Bearer openrevenue_your_key"
{
"period": "30d",
"data": [
{ "city": "Casablanca", "country": "Morocco", "country_code": "MA", "visitors": 14, "pageviews": 38 },
{ "city": "Rabat", "country": "Morocco", "country_code": "MA", "visitors": 8, "pageviews": 21 },
{ "city": "New York", "country": "United States", "country_code": "US", "visitors": 3, "pageviews": 5 }
]
}
Cities
Returns visitor breakdown by city, ranked by unique visitors. Only cities with known geo data are returned.
GET
/
api
/
v1
/
projects
/
{domain}
/
cities
const res = await fetch("https://api.openrevenue.com/api/v1/projects/example.com/cities?period=30d", {
headers: { Authorization: `Bearer ${OPENREVENUE_API_KEY}` },
})
const cities = await res.json()
curl "https://api.openrevenue.com/api/v1/projects/example.com/cities?period=30d" \
-H "Authorization: Bearer openrevenue_your_key"
{
"period": "30d",
"data": [
{ "city": "Casablanca", "country": "Morocco", "country_code": "MA", "visitors": 14, "pageviews": 38 },
{ "city": "Rabat", "country": "Morocco", "country_code": "MA", "visitors": 8, "pageviews": 21 },
{ "city": "New York", "country": "United States", "country_code": "US", "visitors": 3, "pageviews": 5 }
]
}
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/cities?period=30d", {
headers: { Authorization: `Bearer ${OPENREVENUE_API_KEY}` },
})
const cities = await res.json()
curl "https://api.openrevenue.com/api/v1/projects/example.com/cities?period=30d" \
-H "Authorization: Bearer openrevenue_your_key"
{
"period": "30d",
"data": [
{ "city": "Casablanca", "country": "Morocco", "country_code": "MA", "visitors": 14, "pageviews": 38 },
{ "city": "Rabat", "country": "Morocco", "country_code": "MA", "visitors": 8, "pageviews": 21 },
{ "city": "New York", "country": "United States", "country_code": "US", "visitors": 3, "pageviews": 5 }
]
}
Was this page helpful?