---
title: "The install tag for a site"
method: GET
path: "/sites/{id}/snippet"
tags: ["Sites"]
---

# The install tag for a site

`GET /sites/{id}/snippet`

## Request

- Base URL: `https://statable.com/api/v1`
- URL: `https://statable.com/api/v1/sites/{id}/snippet`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/statable/apis/statable-stats-api/docs/sites/:id/snippet/get.ts> (a function with typed inputs; its response is checked against the schema)

Returns the script URL and the ready-to-paste tag. Scope `read`, not `sites:write`: the snippet is public information (it ends up in the page source), and shared users may install tracking too. `type` selects a widget instead of the tracker: a hobby site gets the bundled `/t/` build, which counts as well as draws, a paid site the widget-only build — its counting is the tracker tag it installs separately.

## Query parameters

- `type` 'globe' | 'live-users' | 'map' | 'countries'

## Response `200`

The install URL and snippet.

- SiteSnippet
  - `site_id` integer, required
  - `script_url` string, required
  - `snippet` string, required: The tag to paste, ready as it stands — install it verbatim rather than rebuilding it from `script_url`. A hobby site's tag carries a `data-id` attribute as well: its script is a `/t/` bundle addressed by hash, and that attribute is the only place the counter inside it can read the site id. A tag for a paid site needs no attributes.

## Other responses

- `400`: `invalid_request` — unknown snippet type.
- `401`: Missing/malformed/invalid/revoked bearer token (`unauthorized`), or a key past its expiry (`key_expired`; the message names the expiry time).
- `403`: `insufficient_scope` or `key_not_scoped`.
- `404`: `write_disabled` or `unknown_site`.
- `429`: Hourly account (default 2000/h) or per-key (default 600/h) limit hit (`rate_limited`). Retry after the `Retry-After` seconds. The X-RateLimit-* headers report the window that tripped (account on an account limit).
- `500`: Unexpected server error (`internal`). Report it with the `request_id` from the body or the X-Request-ID header: it is what lets the exact log entry be found, and without it a 500 can only be matched by guessing at a time window.

---

[API](https://skmtc.dev/statable/apis/statable-stats-api.md) - [All operations](https://skmtc.dev/statable/apis/statable-stats-api/llms.txt) - [OpenAPI document](https://skmtc.dev/statable/apis/statable-stats-api/revisions/352b6d47c186?raw)
