Skip to content

The Bideward API

Status: plan. Nothing here is built. The migration keeps today’s paths exactly as they are. The versioned API is added afterwards, beside them, without breaking any loader already pasted (see the backlog, section API).

Bideward has its own API on its own hostname api.bideward.com (ADR-0001). There is no shared catch-all API. Bideward’s API serves bots, loaders and the feed.

Hostname Serves Callers
api.bideward.com Ingestion, loaders, releases, feed, health; later /v1/... Bots, loaders, scripts, monitors
app.bideward.com The dashboard and its own same-origin calls People in a browser
admin.bideward.com Owner pages (after the migration) The owner, behind Cloudflare Access

The hub answers each route only on the hostname it belongs to (E.5, item 5).

The contract: OpenAPI 3.1 in the repository

Section titled “The contract: OpenAPI 3.1 in the repository”
  1. The API is described in docs/api/openapi.yaml (OpenAPI 3.1). The file is the source of truth; the docs site renders it and tests check the hub against it.
  2. A change to the API is a change to that file in the same pull request.
  3. A contract test runs every documented path against the hub and fails on any response that does not match its schema.
Rule Meaning
Path versions /v1/.... A new major version is /v2/..., served side by side.
/v1 is frozen once published Only additive changes (new optional fields, new endpoints). Anything that could break a caller is a new major version.
Today’s paths stay The existing paths keep working, mapped to the same code, until every loader has been updated and Frank approves removing them.
Deprecation is announced in the response Deprecation and Sunset headers (RFC 9745 and RFC 8594) with a link to the replacement, before anything is removed.

Every error is application/problem+json (RFC 9457) with type, title, status, detail and a request_id. A caller can always branch on status and type; detail is for humans. No error includes a secret, a stack trace or an internal path.

  1. GET /v1/status is public, cheap and shows only “ok / degraded / maintenance” and the time. It never shows internals.
  2. In maintenance mode every route answers 503 with a Retry-After header and a small problem+json body. Loaders already treat 503 as “receiver down” and back off (D.11).
  3. If the hub itself is unreachable, bots get the failure Cloudflare returns and retry; people on the dashboard see the branded page of D.11.

POSTs that create something (a bet record, a log post) accept an Idempotency-Key header (an IETF draft, widely used). The hub remembers the key for 24 hours and returns the first result for a repeat, so a bot that retries after a timeout cannot double-write.

List endpoints use a cursor (?limit= and an opaque cursor), never page numbers, so a list that grows while it is read does not skip or repeat rows. Responses carry next_cursor or none.

Today: the X-Titan-Key header that the bots already send, checked by Cloudflare at the edge and by the hub. Later: per-loader tokens that can be rotated and revoked one by one (secrets page). People use the dashboard session, never the API key.

Every response carries X-Request-Id; rate limits are enforced at Cloudflare and answer 429 with Retry-After. Both are logged so a failed call can be traced.

Question Where it goes
The exact list of /v1 endpoints Written with the OpenAPI file, from the paths in use today.
Whether the dashboard’s own calls get a documented form Decided with the OpenAPI file; they stay same-origin either way.