<!-- https://developers.silktide.com/v1/governance/websites/get-website-stats | Governance / Websites -->

# Get headline statistics for every website

`GET /v1/websites/stats`

Returns the headline statistics of every live website in one call: scores,
issue counts, page counts and the technology Silktide found. Websites still
in `setup` are left out.

`websites` and each `sections` are objects keyed by id, not arrays, and stay
objects (`{}`) when empty. Section `0`, the whole website, is not in
`sections`: its statistics are the website's own `stats`.

Websites do not all have the same statistics, so read them by id and expect
some to be missing. A statistic with no value yet is
`null`.

This call returns everything at once, which is slow for an account with many
websites. To read one website, or a statistic over time, use the results
queries instead.

## Response

Status `200`.

- `websites` (map of objects, required): Each live website the API key's user can see, by website id.
  - `name` (string, required): The website's name.
  - `homeUrl` (string, required): Its home page.
  - `websiteId` (integer, required, at least 1): The website.
  - `stats` (map of objects, required): Headline statistics by id, such as `overall.score` or `website.pages`.
    - `label` (string, required): The statistic's name, in the API user's language.
    - `value` (number or string, required, can be null): Its value. Usually a number; a name for technology statistics; null when there is none yet.
  - `sections` (map of objects, required): Its sections other than section `0`, by section id. `{}` when it has none.
    - `name` (string, required): The section's name.
    - `homeUrl` (string, required): Its home page. Can be empty.
    - `sectionId` (integer, required): The section.
    - `stats` (map of objects, required): Headline statistics by id, such as `overall.score` or `website.pages`.
      - `label` (string, required): The statistic's name, in the API user's language.
      - `value` (number or string, required, can be null): Its value. Usually a number; a name for technology statistics; null when there is none yet.

## Errors

| Status | Type | When |
| --- | --- | --- |
| 401 | `NotLoggedIn` | No API key was sent, or it is not a key for this region. |
| 429 | `TooManyRequests` | Too many requests to this path in five seconds. Retry after the number of seconds in the `Retry-After` header, which `properties.retryAfter` repeats. |
| 503 | - | Silktide is busy. Retry after the number of seconds in the `Retry-After` header. |

## Access

- Permission: any user of the account
- Plan feature: none
- Edition: Silktide 4 and Silktide 5
- Cost: free
- Stability: stable, since 1.0.0

## Example: One website with one section

```bash
curl "https://api.eu.silktide.com/v1/websites/stats" \
  -H "Authorization: silktide token=$SILKTIDE_API_KEY"
```

Response:

```json
{
  "websites": {
    "2": {
      "name": "Example",
      "homeUrl": "https://example.com/",
      "websiteId": 2,
      "stats": {
        "overall.score": {
          "label": "Overall score",
          "value": 73.6
        },
        "wcag-22-aa.score": {
          "label": "WCAG 2.2 AA score",
          "value": 88.2
        },
        "website.pages": {
          "label": "Pages tested",
          "value": 812
        },
        "technology.cms": {
          "label": "Most used CMS",
          "value": "WordPress"
        }
      },
      "sections": {
        "3": {
          "name": "Blog",
          "homeUrl": "https://example.com/blog/",
          "sectionId": 3,
          "stats": {
            "overall.score": {
              "label": "Overall score",
              "value": 70.1
            }
          }
        }
      }
    }
  }
}
```
