StatsHub Docs

API

Two HTTP surfaces over one Go implementation — the byte-compatible /api and the described /api/v2 — and where to look up either.

StatsHub exposes its data over HTTP from apps/statshub-api, a Go service that is a route-for-route port of the 218 Next.js route files it replaced. It serves the same data twice:

PrefixWhat it is
/apiThe original surface. Byte-compatible with the Next.js routes it was ported from, untyped bodies, four different error envelopes. Existing clients depend on all of it.
/api/v2The same 298 operations through typed Go structs, one application/problem+json error model, and an OpenAPI document generated from those types.

Base URL

https://statshub.com/api

Locally that is http://localhost:8080/api when you run bun run dev:api.

Authentication

Most endpoints are open. Those that are not resolve a Supabase session through internal/auth; the endpoint reference marks which.

Some write endpoints are unauthenticated on purpose

PUT /api/admin/bot-routing and POST /api/bot/telegram have no authentication, in the original Next.js routes and in the Go port. That was kept faithful rather than fixed silently, and each is flagged in the handler's own doc comment — which is what the generated reference shows.

Responses

On /api, a successful body is whatever the original route returned, and a failure is one of four envelopes: {message}, {error}, or {message, error} with error as either an object or a string. internal/httpx documents that distinction as load-bearing for existing clients.

On /api/v2, every failure is application/problem+json carrying the same text, so a client has one error shape to handle instead of four.

Treat any non-2xx as a failure and log both the status code and the body before retrying.

Machine-readable

https://statshub.com/api/v2/openapi.json      served by the API
/openapi.json                                 the copy this site builds from
/statshub.postman_collection.json             a Postman collection

On this page