Docs
← Back to site

The REST API

2 min readUpdated November 11, 2026
  1. 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).
  2. Send it as Authorization: Bearer nak_… (or X-Nahnu-Key if 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.

Settings › Data & API › API keys

Routes#

Base address: https://<your site>/wp-json/nahnu-analytics/v1/api/

MethodPathBody or queryNeeds
GETsitesread
GETstats/{site}period, compare, filtersread
GETstats/{site}/reportreport, period, limit, intervalread
GETrealtime/{site}read
GETcsv/{site}report, periodread
GET, POSTsites/{site}/goals{"kind": "event" or "page", "match", "label"}read, write
DELETEsites/{site}/goals/{goal}write
GET, POSTsites/{site}/funnels{"name", "steps": [{"kind", "match", "label"}]} (2–8 steps)read, write
PATCH, DELETEsites/{site}/funnels/{funnel}write
GETstats/{site}/funnelfunnel, periodread
GETstats/{site}/journeypath, periodread
POSTevents/{site}one event, or {"events": […]} (up to 50)write
POSTv2/querysite_id (a domain), metrics, date_range, dimensions, filtersread

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.

Settings › API playground

Was this helpful?