Hit Counter and Badges API

Count page views, downloads or events per key with atomic increments, unique-visitor windows and daily history, and show the value as a public SVG badge.

GETPOSTPATCHDELETEhttps://apibox.io.vn/v1/counter/{namespace}/{key}/hit

Counters belong to your account and live under a namespace: POST /v1/counter/{namespace}/{key}/hit adds 1 and returns the new value (the counter is created on the first hit), /increment?by=5 and /decrement change it by any amount up to 1 000 000, /set (value) and /reset (optionally clear_history=true) overwrite it, GET /v1/counter/{namespace}/{key} reads it with daily hits for the last days (default 30, up to 365), PATCH changes options and DELETE removes it. GET /v1/counter lists your counters, GET /v1/counter/{namespace} one namespace with its total, and POST /v1/counter creates one explicitly with a start value. Increments are atomic, so concurrent hits are never lost.

With unique_window_s (up to 30 days) a hit counts once per visitor per window: the visitor is your visitor value (a session or user id) or the request IP, stored only as a short keyed hash that expires with the window; hits_total keeps every hit. With public_read=true the counter gets a public, read-only badge at https://apibox.io.vn/c/{id}.svg (shields-style; label, color, style=flat-square, number_format=full|plain) and JSON at /c/{id}.json: no API key, cached for 5 minutes, not counted in your quota. ?preview=badge&value=1234&label=views renders a badge without an account.

Every /v1 call — including each hit — counts as one request of your monthly quota, so call hit from your server or page script for real events and use the free badge URL to display the number. Plans: Free 20 counters, Starter 500, Pro 5 000.

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
namespacepathstringyesGroup name: 1-64 letters, digits, "_", "-", ".".
keypathstringyesCounter name (same characters). Followed by /hit, /increment, /decrement, /set or /reset.
byquery|bodynumberno1increment / decrement: amount (1-1 000 000).
valuequery|bodynumbernoset / reset / create: new value.
visitorquery|bodystringnoVisitor id for unique counting (default: request IP), hashed.
unique_window_squery|bodynumberno0Count each visitor once per window (0 = every hit, max 2 592 000).
public_readquery|bodybooleannofalseEnable the public badge /c/{id}.svg and /c/{id}.json.
daysquerynumberno30GET: days of daily history (0-365).
clear_historybodybooleannofalsereset: also delete the daily history.
previewquerystringnobadge: render a badge from value, label, color, style without an account.

Example

curl -X POST "https://apibox.io.vn/v1/counter/blog/hello-world/hit" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "id": "cnt_lqeuenf28r8b7my7",
  "namespace": "blog",
  "key": "hello-world",
  "value": 2,
  "public_read": true,
  "unique_window_s": 86400,
  "hits_total": 3,
  "created_at": "2026-11-11T10:47:43.000Z",
  "updated_at": "2026-11-11T10:47:43.000Z",
  "last_hit_at": "2026-11-11T10:47:43.000Z",
  "badge_url": "https://apibox.io.vn/c/cnt_lqeuenf28r8b7my7.svg",
  "json_url": "https://apibox.io.vn/c/cnt_lqeuenf28r8b7my7.json",
  "counted": false,
  "note": "Already counted for this visitor within 86400 s"
}

Use cases

  • Show a views or downloads badge in a GitHub README, blog or Notion page
  • Count page views of a static site, landing page or documentation without analytics
  • Count file downloads, button clicks, votes or game plays
  • Keep simple per-day event statistics for a dashboard or sparkline

FAQ

Does showing the badge use my quota?

No. The badge and JSON under /c/ are free and cached 5 minutes. Only /v1/counter calls (hit, get, reset…) count.

Can visitors increase the counter without my key?

No. Hits need your API key, so call hit from your backend (or a serverless function) and keep the key secret.

Is the IP address stored?

No. Only a truncated keyed hash is kept for unique counting, and it is deleted when the window ends.

Related APIs

Start with 1,000 free requests every month. Get free API key →