> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crispstats.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> CrispStats is a hosted, privacy-first web analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing, no mobile SDKs and no data import except a site's history from a Plausible export (Settings, Import and export).
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> There is no npm package to install. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# CrispStats REST API overview

> Read stats, breakdowns, revenue, funnels, visitors and site health from the read-only CrispStats REST API at crispstats.com/api/v1, with a keyless demo site.

The CrispStats REST API gives you read-only access to the same numbers the dashboard shows: key metrics, traffic over time, breakdowns by any dimension, revenue and payments, goals, events, funnels, retention, visitors, web vitals, JavaScript errors, uptime and AI traffic. Every endpoint is a `GET` under `https://crispstats.com/api/v1`, authenticated with a secret API key, and every response is JSON. To send events from your server instead, see [server-side events](https://docs.crispstats.com/track/server-side-events.md).

You can try it right now without a key: the public demo site, `demo`, answers anonymous requests.

## Make your first request

**1. Call the demo site**

Ask for the last seven days of key metrics. No key is needed for `demo`:

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl "https://crispstats.com/api/v1/sites/demo/stats?range=7d"
```

```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
const response = await fetch("https://crispstats.com/api/v1/sites/demo/stats?range=7d");
const report = await response.json();
console.log(report.summary);
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import requests

response = requests.get("https://crispstats.com/api/v1/sites/demo/stats", params={"range": "7d"})
print(response.json()["summary"])
```

The response states the period it covers, the metrics, and a one-sentence `summary` with the headline figures already formatted. The demo numbers change every day; the shape stays the same:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "range": {
    "preset": "7d",
    "from": "2026-11-10T00:00:00.000Z",
    "to": "2026-11-16T14:31:27.017Z",
    "label": "Last 7 days"
  },
  "compare": null,
  "currency": "USD",
  "metrics": {
    "visitors": { "value": 15091, "previous": null, "change": null },
    "sessions": { "value": 16021, "previous": null, "change": null },
    "pageviews": { "value": 33745, "previous": null, "change": null },
    "viewsPerVisit": { "value": 2.11, "previous": null, "change": null },
    "bounceRate": { "value": 0.4901, "previous": null, "change": null },
    "avgDuration": { "value": 159, "previous": null, "change": null },
    "revenue": { "value": 415100, "previous": null, "change": null },
    "conversionRate": { "value": 0.0042, "previous": null, "change": null },
    "revenuePerVisitor": { "value": 28, "previous": null, "change": null }
  },
  "summary": "Last 7 days: 15,091 visitors, 16,021 sessions, 33,745 pageviews, bounce rate 49%, average visit 2m 39s, revenue $4,151, conversion rate 0.42%."
}
```

**2. Create an API key**

In the dashboard, open the workspace page (**Workspace** in the account menu, or **Team and API keys** below a site's settings tabs), and under **API keys** select **Create key**. Keep the **Read** scope. The key starts with `cs_sk_` and is shown once, so store it in a secret manager or an environment variable. Owners and admins can create keys. See [authentication](https://docs.crispstats.com/api-reference/authentication.md).

**3. List your sites**

Send the key as a bearer token. `GET /sites` returns every site the key can read, with the `id` you use in every other path:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl "https://crispstats.com/api/v1/sites" \
  -H "Authorization: Bearer $CRISPSTATS_API_KEY"
```

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "sites": [
    {
      "id": "demo",
      "name": "Quillbook",
      "domain": "quillbook.example",
      "timezone": "UTC",
      "currency": "USD",
      "createdAt": "2025-03-04T09:00:00.000Z",
      "installed": true,
      "imported": null
    }
  ]
}
```

The site id is also the segment after `/app/` in your dashboard URL. `imported` describes history the site [imported from Plausible](https://docs.crispstats.com/api-reference/query-parameters.md#imported-history), or is `null`.

**4. Read your own site**

Replace `demo` with your site id and keep the header:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl "https://crispstats.com/api/v1/sites/YOUR_SITE_ID/breakdown/source?range=30d&limit=5" \
  -H "Authorization: Bearer $CRISPSTATS_API_KEY"
```

## Base URL and scope

| Property | Value |
| - | - |
| Base URL | `https://crispstats.com/api/v1` |
| Methods | `GET` only. `POST`, `PUT`, `PATCH` and `DELETE` return `405 method_not_allowed`. |
| Format | JSON responses. Errors use one [error envelope](https://docs.crispstats.com/api-reference/errors.md). |
| Authentication | `Authorization: Bearer cs_sk_…`. Optional for the demo site only. |
| CORS | Any origin may call the API. Keep secret keys on a server anyway. |
| Caching | Endpoint responses carry `Cache-Control: private, no-store`. The OpenAPI document is public and cached for 5 minutes. |
| Specification | OpenAPI 3.1 at `https://crispstats.com/api/v1/openapi.json`, generated from the same schemas the API validates with. |

The API is read-only. It cannot create sites, goals, funnels or keys, and it cannot send events. To send events from a server, use the [collector](https://docs.crispstats.com/api-reference/collector.md) with a key that has the **Events** scope.

A `GET` to a path under `/api/v1` that is not an endpoint answers `404 not_found` in the same JSON envelope.

## Units and conventions

Every endpoint follows the same rules, so you can parse responses without special cases:

| Value | Format |
| - | - |
| Money | Integer minor units (cents) in the `currency` field of the response. `415100` with `USD` is \$4,151.00. |
| Rates | A number from 0 to 1. `0.4901` is 49.01%. |
| Durations | Seconds, except web vitals, which are milliseconds (CLS has no unit). |
| Timestamps | ISO 8601 in UTC. |
| `change` | A ratio against the comparison period: `0.12` is +12%. It is `null` unless you pass `compare`. |
| `range` | Every report echoes the period: `preset`, `from` (inclusive), `to` (exclusive) and a readable `label`. |
| `summary` | One sentence with the headline figures, formatted for people. |

Metrics that support comparison come as `{ "value", "previous", "change" }`. Lists are capped in rows: each endpoint's limits are in [query parameters](https://docs.crispstats.com/api-reference/query-parameters.md).

## Endpoints

Every path below is relative to `https://crispstats.com/api/v1`. Each one has its own page with parameters and a live playground in the **Endpoints** group of this tab.

| Endpoint | Returns |
| - | - |
| `GET /sites` | The sites the key can read. |
| `GET /sites/{siteId}/stats` | Visitors, sessions, pageviews, bounce rate, average duration, revenue, conversion rate. |
| `GET /sites/{siteId}/timeseries` | The same metrics per hour, day, week or month. |
| `GET /sites/{siteId}/breakdown/{dimension}` | Top values of one dimension: pages, sources, countries, devices, events, AI assistants and more. |
| `GET /sites/{siteId}/realtime` | Visitors active in the last 5 minutes, per-minute counts and recent events. |
| `GET /sites/{siteId}/revenue` | Gross, new and renewal revenue, refunds, MRR, customers, average order value. |
| `GET /sites/{siteId}/payments` | Individual payments with first-touch attribution. |
| `GET /sites/{siteId}/goals` | Goals with completions, conversion rate and revenue. |
| `GET /sites/{siteId}/events` | Custom events with counts and unique visitors. |
| `GET /sites/{siteId}/events/{event}/properties` | The properties of one event and their most common values. |
| `GET /sites/{siteId}/funnels` | Funnel definitions and their ids. |
| `GET /sites/{siteId}/funnels/{funnelId}` | Step-by-step conversion for one funnel, optionally split by a dimension. |
| `GET /sites/{siteId}/retention` | Cohort retention by day, week or month. |
| `GET /sites/{siteId}/visitors` | Individual visitors, filtered by segment and sorted. |
| `GET /sites/{siteId}/visitors/{visitorId}` | One visitor's profile and recent sessions. |
| `GET /sites/{siteId}/vitals` | Core Web Vitals percentiles, ratings and slowest pages. |
| `GET /sites/{siteId}/errors` | JavaScript error groups. |
| `GET /sites/{siteId}/uptime` | Uptime monitors and incidents. |
| `GET /sites/{siteId}/ai-traffic` | Visits from AI assistants and AI crawler hits. |

## The demo site

`demo` is a public site with generated data. Without a key you can call `GET /sites` (which lists only `demo`) and every `/sites/demo/…` endpoint, up to 500 requests a day and 10 every 10 seconds. Any other site id without a key returns `401 unauthorized`. The demo exists so the examples in these docs run as written; build on your own site with a key.

## Other interfaces

The REST API is one of three ways to read or send data:

* The [MCP server](https://docs.crispstats.com/api-reference/mcp.md) at `https://crispstats.com/api/mcp` exposes the same reports as read-only tools for AI assistants.
* The [collector](https://docs.crispstats.com/api-reference/collector.md) at `https://in.crispstats.com` receives events from the script and from your server. The REST API cannot write data: to send custom events, revenue or `identify` calls from your backend, use [server-side events](https://docs.crispstats.com/track/server-side-events.md), a `POST` to the collector with a secret key that has the **Events** scope.
* [Alert webhooks](https://docs.crispstats.com/api-reference/webhooks.md) push signed JSON to your endpoint when an alert fires.

## Next steps

> [card] [Authentication](https://docs.crispstats.com/api-reference/authentication.md)
>
> Create a key, send it as a bearer token and understand 401, 403 and 404.

> [card] [Query parameters](https://docs.crispstats.com/api-reference/query-parameters.md)
>
> Date ranges, comparison, filters, granularity and pagination.

> [card] [Rate limits](https://docs.crispstats.com/api-reference/rate-limits.md)
>
> Daily allowance per plan, burst limit and the headers to watch.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.