> ## 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.

# Widget JSON and endpoints

> Fetch a CrispStats widget's data as JSON to draw it yourself: the WidgetPayload fields, the batch endpoint, the shields.io endpoint, caching, errors and the /w/v1 compatibility promise.

Every widget's data is public JSON at a stable URL, so you can draw it in your own design: in a static site generator, a native app, a TV dashboard or anywhere a script or an image does not fit. The JSON holds exactly what the widget shows and nothing more, already formatted, with the raw figures beside the text.

```js wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
const res = await fetch("https://in.crispstats.com/w/v1/d/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD");
const widget = await res.json(); // WidgetPayload; 404 when off.
```

The endpoints need no key: a widget is public once you create it, and its token is in every copy of its code. They answer any origin (`Access-Control-Allow-Origin: *`), set no cookies, and count no pageview.

## Endpoints

All paths are on `https://in.crispstats.com`, and also under `/p/` for a [first-party proxy](https://docs.crispstats.com/share/widgets/embed.md#first-party-proxy).

| Method and path | Returns |
| - | - |
| `GET /w/v1/d/{token}` | One widget's `WidgetPayload`. |
| `GET /w/v1/d?ids={token},{token}` | Several widgets at once, at most 8. |
| `GET /w/v1/s/{token}` | A [shields.io endpoint](https://shields.io/badges/endpoint-badge) badge. |
| `GET /w/v1/i/{token}.svg` | The widget as an SVG image. |
| `GET /w/v1/f/{token}` | The widget as an HTML document for an iframe. |
| `GET /w/v1/loader.js` | The widget script. |
| `GET /w/v1/b/{file}` | A [brand badge](https://docs.crispstats.com/share/widgets/brand-badge.md) image, such as `powered-light-m.svg`. |

### One widget

`GET https://in.crispstats.com/w/v1/d/{token}`

**token** `string` *required*

The widget's token: `cs_wd_` followed by 24 letters and digits. It is in the widget's code and under **Copy token** in **Settings**, **Sharing and widgets**.

**l** `string`

A language tag, such as `de` or `fr-CA`, for numbers and dates in `view`. Only the language, script and region are read; anything after them is ignored, and an unknown tag falls back to `en`. Default `en`.

**theme** `string`

`auto`, `light` or `dark`. Replaces the widget's theme in the answer's `theme` field. Default: the widget's setting.

### Several widgets

`GET https://in.crispstats.com/w/v1/d?ids={token},{token}&l=en`

The answer is an object keyed by token, in the order asked. A token that would answer `404` on its own (unknown, paused, deleted) is left out rather than failing the request; a widget with nothing to show is included with `"hidden": true`. More than 8 tokens answer `400` with `{"error":"too_many_ids"}`. The widget script uses this endpoint to load every widget on a page in one request.

### shields.io

`GET https://in.crispstats.com/w/v1/s/{token}` answers in the [shields.io endpoint format](https://shields.io/badges/endpoint-badge). Pass its URL to `https://img.shields.io/endpoint?url=`; the **shields** tab of the widget builds the whole Markdown for you. For the demo README badge it answers:

```json wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "schemaVersion": 1,
  "label": "visitors 30d",
  "message": "72.2k",
  "color": "f2600c",
  "labelColor": "555555",
  "cacheSeconds": 300
}
```

`color` is the widget's accent colour. A widget with nothing to show answers `"message": "not yet"` in grey, so a README never shows a broken badge. For a Domain Rating widget `label` is always `Domain Rating by Ahrefs`.

## The payload

A real answer, from the public demo's visitors card:

```json wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "v": 1,
  "token": "cs_wd_demoVisitorsCard00000000",
  "kind": "stat",
  "layout": "card",
  "size": "m",
  "theme": "auto",
  "style": "soft",
  "accent": "brand",
  "site": {
    "name": "Quillbook",
    "domain": "quillbook.example"
  },
  "asOf": "2026-11-23T15:47:31.409Z",
  "data": {
    "kind": "stat",
    "metric": "visitors",
    "range": "30d",
    "value": 72229,
    "previous": 58738,
    "series": [1457, 2124, 2079, 2264, 2076, 2006, 1594, 1655, 2190, 2129, 5293, 3481, 2596, 1795, 1597, 2127, 2240, 2343, 2601, 2282, 1710, 5694, 3622, 2981, 2536, 2562, 2305, 1655, 1663, 1572]
  },
  "view": {
    "state": "ready",
    "text": "72.2k visitors in the last 30 days",
    "label": "Visitors",
    "value": "72,229",
    "delta": {
      "text": "+23% vs previous 30 days",
      "tone": "up"
    },
    "footer": "Last 30 days",
    "aria": "Visitors: 72,229 in the last 30 days, up 23% vs previous 30 days. Powered by CrispStats.",
    "spark": [256, 373, 365, 398, 365, 352, 280, 291, 385, 374, 930, 611, 456, 315, 280, 374, 393, 411, 457, 401, 300, 1000, 636, 524, 445, 450, 405, 291, 292, 276],
    "bars": null,
    "rows": null,
    "strip": null,
    "progress": null,
    "gauge": null,
    "live": false,
    "refreshMs": 0,
    "hidden": false,
    "badge": {
      "label": "visitors 30d",
      "message": "72.2k"
    }
  },
  "attribution": {
    "text": "Powered by CrispStats",
    "href": "https://crispstats.com/share/quillbook"
  },
  "source": null,
  "colors": {
    "light": {
      "surface": "#ffffff",
      "ground": "#ffffff",
      "ink": "#23211e",
      "muted": "#6e6a64",
      "border": "rgba(35,33,30,0.12)",
      "shadow": "0 1px 2px rgba(0,0,0,0.06)",
      "track": "rgba(35,33,30,0.10)",
      "accent": "#f2600c",
      "focus": "#f2600c"
    },
    "dark": {
      "surface": "#1e1d1a",
      "ground": "#1e1d1a",
      "ink": "#f0eeea",
      "muted": "#9a968f",
      "border": "rgba(240,238,234,0.14)",
      "shadow": "0 1px 2px rgba(0,0,0,0.3)",
      "track": "rgba(240,238,234,0.10)",
      "accent": "#ff7a2e",
      "focus": "#ff7a2e"
    }
  }
}
```

**v** `number`

The payload version, always `1` on `/w/v1`.

**token** `string`

The widget's token.

**kind** `string`

`live`, `stat`, `revenue`, `sales`, `uptime`, `dr` (Domain Rating) or `summary` (site summary).

**layout** `string`

`pill`, `card`, `goal`, `strip` or `badge`.

**size** `string`

`s`, `m` or `l`. The box in pixels for each layout is in [Layouts and sizes](https://docs.crispstats.com/share/widgets.md#layouts-and-sizes).

**theme** `string`

`auto`, `light` or `dark`.

**style** `string`

`soft`, `outline`, `solid`, `tint` or `plain`. See [Styles](https://docs.crispstats.com/share/widgets.md#styles).

**accent** `string`

A preset name (`brand`, `ink`, `blue`, `green`, `violet`, `pink`) or a hex colour such as `#2563eb`.

**site** `object`

The site's public identity: `name` and `domain`. Nothing else about the site.

**asOf** `string`

When the figures were computed, ISO 8601 in UTC.

**data** `object`

The raw figures for this kind. Every field the widget shows, unformatted; nothing it does not show.

**data by kind**

**live** `object`

`count`: visitors in the last 5 minutes, or `null` between 1 and the floor (the widget shows "A few people"). `perMinute`: 30 counts, oldest first, on the card. `countries`: up to 3 `{ code, visitors }`, each with at least 3 visitors, on the large card with countries on.

**stat** `object`

`metric`, `range`, `value`, `previous` (the period before, `null` for all time), `series` (up to 31 values, oldest first, on a card with the chart) and, for AI visitors, `assistants` (up to 2 names).

**revenue** `object`

`metric` (`mrr` or `revenue`), `range`, `currency`, `display` (the display applied, `verified_only` below the floors), `valueMinor` (exact only, in minor units such as cents), `bandFloorMinor` (band only), `change` (`0.18` is +18%), `progress` and `goalMinor` (goal only; `progress` is rounded down to a whole percent unless the display is exact, so the public goal never gives the amount back), `spark` (the chart's shape, 0 to 1000, never amounts), `providers`, `since` (the first verified payment, `YYYY-MM-DD`) and `otherCurrencies`.

**sales** `object`

`range`, `count`, `previous`, `lastSale` (`today`, `this_week`, `this_month` or `null`) and `providers`.

**uptime** `object`

`name` (the monitor's name, never its URL), `status` (`up`, `degraded`, `down` or `paused`), `ratio` (0 to 1), `days` (30 or 90) and, on the strip, `daily` (one of `up`, `partial`, `down`, `none` per day, oldest first).

**dr** `object`

`domain` (the rated domain), `value` (0 to 100, `null` before the first reading), `readOn` (`YYYY-MM-DD`), `change` (whole points over about 30 days, or `null`) and, on a card with the line and at least 14 readings, `spark` (up to 90 daily values).

**summary** `object`

`visitors` (the last 30 days), `series` (up to 31 daily visitor counts, oldest first, only when `visitors` is above 0), `domain`, `rating` (0 to 100 with one decimal, or `null` when there is no reading) and `readOn` (`YYYY-MM-DD`, or `null` without a rating).

**view** `object`

The widget as text, ready to show, in the language asked with `l`. Draw from `view` and you match the widget exactly.

**view fields**

**state** `string`

`ready`, `quiet` (a phrase instead of a small number) or `stale` (the figures are older than usual because CrispStats could not refresh them).

**hidden** `boolean`

`true` when the widget has nothing to show. Show nothing and keep no space for it.

**text** `string`

The pill's sentence, such as `71.9k visitors in the last 30 days`, or `DR 43`.

**label** `string`

The card's heading, or the badge's left side.

**value** `string`

The figure as shown: `71,942`, `$10k+`, `+18%`, `63%`, `43`.

**delta** `object | null`

`text` (`+23% vs previous 30 days`) and `tone` (`up`, `down` or `flat`). The sign is in the text; draw an arrow from the tone if you like.

**footer** `string`

The footer, such as `Last 30 days`. Add the age yourself from `asOf` if you want "updated 2 min ago".

**aria** `string`

One sentence for screen readers, with the credit and the source attribution.

**spark, bars, strip, rows, progress, gauge** `various`

What the chart, the live bars, the uptime strip, the country rows, the goal bar and the Domain Rating gauge draw: integers from 0 to 1000 for charts and bars, day states for the strip, `{ label, value }` rows, and 0 to 1 for the goal and the gauge. `null` when the layout has none.

**badge** `object`

`label` and `message`, the two sides of the badge image.

**live, refreshMs** `boolean, number`

Whether the figure is live, and how often the widget script asks again, in milliseconds (`0` means every 10 minutes).

**attribution** `object | null`

Our credit: `text` (`Powered by CrispStats` or `Verified by CrispStats`) and `href`. `null` when a paid plan hides it. If you draw the widget yourself, show it as a link the way the widget does.

**source** `object | null`

The data source's attribution, for Domain Rating, and for a site summary while it shows a rating; `null` otherwise. See [The source field](#the-source-field).

**colors** `object`

The widget's colours with its style and accent applied, for a light page (`light`) and a dark page (`dark`): `surface`, `ground`, `ink`, `muted`, `border`, `shadow`, `track`, `accent` and `focus`, as CSS values. Pick the one that matches where you draw it and you get the colours the widget script would use, contrast fixes included.

## The source field

A Domain Rating payload carries Ahrefs' attribution as data:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
"source": {
  "text": "Domain Rating by Ahrefs",
  "linkText": "Ahrefs",
  "href": "https://ahrefs.com/"
}
```

Wherever you show the number, show `source.text` next to it, with the words `source.linkText` as a link to `source.href`. Ahrefs' licence requires it, and it applies to your own drawing as much as to ours. A full Domain Rating answer from the demo:

```json wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "v": 1,
  "token": "cs_wd_demoDomainRating00000000",
  "kind": "dr",
  "layout": "card",
  "size": "m",
  "theme": "auto",
  "style": "soft",
  "accent": "brand",
  "site": {
    "name": "Quillbook",
    "domain": "quillbook.example"
  },
  "asOf": "2026-11-23T15:47:31.409Z",
  "data": {
    "kind": "dr",
    "domain": "quillbook.example",
    "value": 42.6,
    "readOn": "2026-11-23",
    "change": 3,
    "spark": [42.6, 42.6, 42.5, 42.6, 42.6, 42.9, 42.8, 42.7, 42.8, 42.8, 42.8, 42.8, 42.5, 42, 41.9, 41.4, 41.3, 40.9, 40.8, 40.6, 40.1, 40.2, 39.9, 40, 39.9, 39.6, 39.8, 39.9, 39.8, 39.9, 39.8, 40, 40, 40, 39.7, 39.5, 39.4, 39.2, 39, 38.7, 38.7, 38.5, 38.4, 38.1, 38.1, 38.4, 38.2, 38.5, 38.6, 38.9, 39, 39.3, 39.5, 39.9, 40, 40.2, 40.1, 40.4, 40.2, 40.3, 40.5, 40.2, 40.3, 40.1, 40.2, 40.2, 40.2, 40.6, 40.6, 40.6, 41, 41.3, 41.6, 41.8, 42.2, 42.4, 42.6, 42.7, 42.9, 43.3, 43.4, 43.3, 43.2, 43.1, 43, 43, 42.7, 42.7, 42.7, 42.6]
  },
  "view": {
    "state": "ready",
    "text": "DR 43",
    "label": "Domain Rating",
    "value": "43",
    "delta": {
      "text": "+3 in 30 days",
      "tone": "up"
    },
    "footer": "Read today",
    "aria": "Domain Rating 43 out of 100 for quillbook.example, up 3 in 30 days, read today. Domain Rating by Ahrefs. Powered by CrispStats.",
    "spark": [685, 685, 675, 685, 685, 715, 705, 695, 705, 705, 705, 705, 675, 625, 615, 565, 555, 515, 505, 485, 435, 445, 415, 425, 415, 385, 405, 415, 405, 415, 405, 425, 425, 425, 395, 375, 365, 345, 325, 295, 295, 275, 265, 235, 235, 265, 245, 275, 285, 315, 325, 355, 375, 415, 425, 445, 435, 465, 445, 455, 475, 445, 455, 435, 445, 445, 445, 485, 485, 485, 525, 555, 585, 605, 645, 665, 685, 695, 715, 755, 765, 755, 745, 735, 725, 725, 695, 695, 695, 685],
    "bars": null,
    "rows": null,
    "strip": null,
    "progress": null,
    "gauge": 0.426,
    "live": false,
    "refreshMs": 0,
    "hidden": false,
    "badge": {
      "label": "Domain Rating by Ahrefs",
      "message": "43"
    }
  },
  "attribution": {
    "text": "Powered by CrispStats",
    "href": "https://crispstats.com/share/quillbook"
  },
  "source": {
    "text": "Domain Rating by Ahrefs",
    "linkText": "Ahrefs",
    "href": "https://ahrefs.com/"
  },
  "colors": {
    "light": {
      "surface": "#ffffff",
      "ground": "#ffffff",
      "ink": "#23211e",
      "muted": "#6e6a64",
      "border": "rgba(35,33,30,0.12)",
      "shadow": "0 1px 2px rgba(0,0,0,0.06)",
      "track": "rgba(35,33,30,0.10)",
      "accent": "#f2600c",
      "focus": "#f2600c"
    },
    "dark": {
      "surface": "#1e1d1a",
      "ground": "#1e1d1a",
      "ink": "#f0eeea",
      "muted": "#9a968f",
      "border": "rgba(240,238,234,0.14)",
      "shadow": "0 1px 2px rgba(0,0,0,0.3)",
      "track": "rgba(240,238,234,0.10)",
      "accent": "#ff7a2e",
      "focus": "#ff7a2e"
    }
  }
}
```

## Caching and freshness

Each answer says how long it may be kept. Fetching more often than that returns the same figures.

| Endpoint | `Cache-Control` |
| - | - |
| Data, live widgets | `public, max-age=10` |
| Data, every other kind | `public, max-age=60, stale-while-revalidate=30` |
| Several widgets | The shortest of its widgets' |
| `404` | `public, max-age=60` |
| shields.io | `public, max-age=60`, and `cacheSeconds: 300` in the body for shields.io itself |
| SVG image | `no-cache`, with an `ETag`, so caches check back each time |
| iframe | `public, max-age=60` |
| Widget script | `public, max-age=3600, stale-while-revalidate=86400` |
| Brand badge | `public, max-age=86400, stale-while-revalidate=604800` |

Behind the cache, CrispStats recomputes a widget's figures at most every 300 seconds for traffic figures (300 for the site summary), 900 for revenue and sales, 120 for uptime and 3,600 for Domain Rating. Live counts are always current. If the figures cannot be refreshed, the last ones are served with `"state": "stale"` for up to 6 hours; after that the widget answers `404`. When you edit, pause or delete a widget, every answer reflects it within 3 minutes, and figures cached under the old settings are never served again. shields.io keeps its own copy of a badge for at least 5 minutes, whatever the endpoint says.

## Errors

| Status | Body | When |
| - | - | - |
| `404` | `{"error":"not_found"}` | The token is malformed or unknown, the widget is paused or deleted, its workspace is over the plan's widget limit or suspended, the page is not in **Allowed sites** (or hides its address while the list is set), or its data is gone (a deleted monitor, a disconnected payment provider). |
| `400` | `{"error":"too_many_ids"}` | More than 8 tokens in one batch request. |
| `429` | `{"error":"rate_limited"}` | Too many uncached requests from one address. Each token in a batch counts as one request. Wait for `Retry-After` (30 seconds). |

Every reason for a `404` gives the same bytes, so the answer never tells anyone whether a token exists. A widget that exists but has nothing to show yet answers `200` with `"hidden": true`, not `404`.

## The /w/v1 promise

Everything under `/w/v1` only grows. Fields may be added to the payload and new kinds, layouts and styles may appear, but no field is removed, renamed or given another meaning, and the element name `crispstats-widget` and its attributes stay. Code you write against `/w/v1` today keeps working. A change that cannot keep that promise would arrive as `/w/v2`, next to `/w/v1`, not instead of it. Ignore fields and values you do not know.

## Next steps

> [card] [Embed a widget](https://docs.crispstats.com/share/widgets/embed.md)
>
> The script, iframe and image forms that draw it for you.

> [card] [Domain Rating](https://docs.crispstats.com/share/widgets/domain-rating.md)
>
> How the rating is read and the attribution rule.

> [card] [REST API](https://docs.crispstats.com/api-reference/introduction.md)
>
> Private, read-only access to all your analytics.


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