Access-Control-Allow-Origin: *), set no cookies, and count no pageview.
Endpoints
All paths are onhttps://in.crispstats.com, and also under /p/ for a first-party proxy.
One widget
GET https://in.crispstats.com/w/v1/d/{token}
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.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.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. 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:
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:s, m or l. The box in pixels for each layout is in Layouts and sizes.soft, outline, solid, tint or plain. See Styles.The raw figures for this kind. Every field the widget shows, unformatted; nothing it does not show.
The widget as text, ready to show, in the language asked with
l. Draw from view and you match the widget exactly.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.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 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: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:
Caching and freshness
Each answer says how long it may be kept. Fetching more often than that returns the same figures.
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
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
Embed a widget
The script, iframe and image forms that draw it for you.
Domain Rating
How the rating is read and the attribution rule.
REST API
Private, read-only access to all your analytics.