Developers · HTTP API

A web analytics API for any language.

Read stats, manage goals and funnels, and send events from a CRM, a payment webhook or a script, with one key. For a SaaS, the platform API also sets up users and their websites.

Terminalbash
curl -H "Authorization: Bearer nak_…" \
  "https://youragency.com/wp-json/nahnu-analytics/v1/api/stats/SITE_ID?period=30d&compare=previous"

Keys and limits

One key, scoped to what it needs.

Make a key under Settings › Data & API › API keys. It reads every website or one client’s websites, and you choose what it can do.

  • Read stats; read, manage goals and funnels and send events; or Platform
  • 600 requests an hour per key, 20,000 for a platform key
  • A batch of events counts as one request
  • Only a hash of the key is stored, so copy it when it’s made
The REST API in the docs →
youragency.com/wp-admin · Data & API
Settings › Data & API › API keys: key name, sites and what the key can do

Routes

Everything on the dashboard, as JSON.

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

GETsitesEvery website the key can read
GETstats/{site}Key numbers for a period, with a comparison and filters
GETstats/{site}/reportOne report: sources, pages, countries and more
GETrealtime/{site}Who is on the website right now
GETcsv/{site}A report as CSV
GET · POSTsites/{site}/goalsList or add page and event goals
GET · POSTsites/{site}/funnelsList or add funnels of 2 to 8 steps
GETstats/{site}/funnel · /journeyA funnel’s or a journey’s numbers
POSTevents/{site}One event, or up to 50 at once
POSTv2/queryMetrics and dimensions for Looker Studio and scripts

Periods: today, yesterday, 24h, 7d, 28d, 30d, 91d, month, 6mo, year, 12m, all, or custom with from and to.

Goals from your own systems

Count a lead won in your CRM.

Declare the goal once, then send the event from your CRM’s webhook. With the visitor’s address and browser, it joins their visit and the source gets the credit.

  • Only name is required
  • The same id within 3 days counts once, so a retried webhook isn’t a second sale
  • Revenue in any currency
  • Without the visitor’s address, the event still counts, as its own visitor
More about server-side events →
Declare the goal oncebash
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 CRMbash
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

Platform API

For a SaaS that adds its own users.

With a platform key, your product makes clients, portal users and websites, links websites, signs users in and reads usage for billing, all from your own code.

  • Your own refs, such as your user id, for clients and sites
  • An OpenAPI 3.1 file in the SDK package describes every route
  • Import it into Postman or Insomnia, or generate a client
  • Or use the TypeScript SDK, which wraps it all
The HTTP API in the SDK docs →
PUT/platform/clients/{ref}Make or update a client
POST/platform/clients/{ref}/usersAdd someone who signs in to the portal
POST/platform/clients/{ref}/loginA one-time sign-in link
PUT/platform/sites/{ref}Make or update a website, with its tracking code
GET/platform/sites/{ref}/statusIs it receiving visits?
GET/platform/usageVisitors and pageviews, for billing

Some of the platform routes

API playground

Try any route before you write code.

Settings › API playground runs any route with your key and shows exactly what it answers, with the same request as curl to copy.

youragency.com/wp-admin · API playground
The API playground: pick a route, a website and a key, then send

Questions

API questions

Something else? Ask us.

How do I authenticate?

Send the key as Authorization: Bearer nak_…, or as X-Nahnu-Key if your host strips the Authorization header.

What are the rate limits?

600 requests an hour per key, and 20,000 for a platform key. A batch of events counts as one. Every answer carries X-RateLimit-Limit, -Remaining and -Reset.

Can a key read only one client’s websites?

Yes. A key reads every website or one client’s websites.

My site has no pretty permalinks. Does it still work?

Yes. Use ?rest_route=/nahnu-analytics/v1/api… instead of /wp-json/.

Can I connect Looker Studio or Google Sheets?

Yes. The v2 query API is made for Looker Studio connectors and scripts, and Settings › Data & API explains Google Sheets.

Build on your analytics.

Unlimited websites, every feature, the API included.