The REST API
- Create a key under Settings › Data & API › API keys. A key reads every website or one client’s websites. Choose what it Can do: Read stats; Read, manage goals & funnels, send events; or Platform (see the Nahnu Analytics SDK docs).
- Send it as
Authorization: Bearer nak_…(orX-Nahnu-Keyif your host strips Authorization).
Copy the key when it is made: it is not shown again, and only its hash is stored. Each key has 600 requests an hour (20,000 for a platform key); a batch of events counts as one. Every answer carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset.

Routes#
Base address: https://<your site>/wp-json/nahnu-analytics/v1/api/
| Method | Path | Body or query | Needs |
|---|---|---|---|
| GET | sites | read | |
| GET | stats/{site} | period, compare, filters | read |
| GET | stats/{site}/report | report, period, limit, interval | read |
| GET | realtime/{site} | read | |
| GET | csv/{site} | report, period | read |
| GET, POST | sites/{site}/goals | {"kind": "event" or "page", "match", "label"} | read, write |
| DELETE | sites/{site}/goals/{goal} | write | |
| GET, POST | sites/{site}/funnels | {"name", "steps": [{"kind", "match", "label"}]} (2–8 steps) | read, write |
| PATCH, DELETE | sites/{site}/funnels/{funnel} | write | |
| GET | stats/{site}/funnel | funnel, period | read |
| GET | stats/{site}/journey | path, period | read |
| POST | events/{site} | one event, or {"events": […]} (up to 50) | write |
| POST | v2/query | site_id (a domain), metrics, date_range, dimensions, filters | read |
period: today, yesterday, 24h, 7d, 28d, 30d (default), 91d, month, 6mo, year, 12m, all, or custom with from and to (YYYY-MM-DD). compare: previous (default), year or none. interval: hour, day, week or month.
Sending events#
An event:
{"name": "Lead won", "props": {"plan": "pro"}, "revenue": {"amount": 490, "currency": "USD"}, "url": "https://example.com/thanks", "ip": "203.0.113.9", "user_agent": "Mozilla/5.0 …", "id": "order-1001"} Only name is required. With ip and user_agent the event joins that visitor’s visit; without them it counts as its own visitor. The same id again within three days counts once, so a retried webhook is not a second sale.
# Declare the goal once
curl -X POST -H "Authorization: Bearer nak_…" -H "Content-Type: application/json" \
-d '{"kind": "event", "match": "Lead won", "label": "Lead won (CRM)"}' \
https://youragency.com/wp-json/nahnu-analytics/v1/api/sites/SITE_ID/goals
# Then send events from the CRM's webhook
curl -X POST -H "Authorization: Bearer nak_…" -H "Content-Type: application/json" \
-d '{"name": "Lead won", "revenue": {"amount": 490, "currency": "USD"}}' \
https://youragency.com/wp-json/nahnu-analytics/v1/api/events/example.com API playground#
Settings › API playground tries any route with your key and shows the answer.

Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!



