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

# Endpoints

Base URL: `https://nums.advay.ca/`

<Info>
  Only <b>/hit</b> requires authentication via <code>X-Auth-Token</code> (or <code>?token=</code>). Read endpoints are public on the hosted instance and serverless deployments. When running the standalone server in <code>./cmd/server</code>, setting a <code>SECRET\_TOKEN</code> also protects read endpoints.
</Info>

## Increment (GET/POST /hit)

<ParamField query="id" type="string">Counter id. Defaults to <code>home</code>.</ParamField>
<ParamField header="X-Auth-Token" type="string" required>Secret token for write access. Alternatively use <code>?token=</code>.</ParamField>
<ParamField query="token" type="string">Secret token (alternative to header).</ParamField>

<RequestExample>
  ```bash theme={null}
  curl -H "X-Auth-Token: $SECRET_TOKEN" "https://nums.advay.ca/hit?id=home"
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  { "id": "home", "hits": 73, "source": "redis" }
  ```
</ResponseExample>

## Read (JSON) — GET /count

<ParamField query="id" type="string">Counter id. Defaults to <code>home</code>.</ParamField>
<ParamField query="format" type="string">Optional <code>txt</code> or <code>text</code> to return plain text instead of JSON.</ParamField>

<RequestExample>
  ```bash theme={null}
  curl "https://nums.advay.ca/count?id=home"
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  { "id": "home", "hits": 73, "source": "redis" }
  ```
</ResponseExample>

## Read (Text) — GET /count.txt

<ParamField query="id" type="string">Counter id. Defaults to <code>home</code>.</ParamField>

<RequestExample>
  ```bash theme={null}
  curl "https://nums.advay.ca/count.txt?id=home"
  ```
</RequestExample>

<ResponseExample>
  ```text Success theme={null}
  73
  ```
</ResponseExample>

## Badge (SVG) — GET /badge

<ParamField query="id" type="string">Counter id. Defaults to <code>home</code>.</ParamField>
<ParamField query="label" type="string">Left-side text. Defaults to <code>views</code>.</ParamField>
<ParamField query="style" type="string">Badge style: <code>terminal</code> or default classic.</ParamField>
<ParamField query="color" type="string">Classic badge color (e.g., <code>blue</code>).</ParamField>
<ParamField query="bg" type="string">Terminal background (hex <code>#rrggbb</code> or allowed names).</ParamField>
<ParamField query="labelColor" type="string">Terminal label color (hex or allowed names).</ParamField>
<ParamField query="valueColor" type="string">Terminal value color (hex or allowed names).</ParamField>
<ParamField query="font" type="string">Custom font family.</ParamField>

<RequestExample>
  ```bash theme={null}
  open "https://nums.advay.ca/badge?id=home&style=terminal&label=hits&bg=%23101414&valueColor=%233cffb3"
  ```
</RequestExample>

## Badge (Shields endpoint) — GET /badge.json

<ParamField query="id" type="string" required>Counter id.</ParamField>
<ParamField query="label" type="string">Left-side text. Defaults to <code>views</code>.</ParamField>
<ParamField query="color" type="string">Badge color (e.g., <code>blue</code>).</ParamField>
<ParamField query="cacheSeconds" type="integer" default="60">Cache TTL in seconds (30–3600 enforced).</ParamField>

<RequestExample>
  ```bash theme={null}
  open "https://img.shields.io/endpoint?url=https%3A%2F%2Fnums.advay.ca%2Fbadge.json%3Fid%3Dhome%26label%3Dhits%26cacheSeconds%3D30"
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  { "schemaVersion": 1, "label": "views", "message": "73", "color": "blue", "cacheSeconds": 30 }
  ```
</ResponseExample>
