ClickTheWheel public API v1

Add a stateless random spin to your website

Send a bounded list of text entries and receive one server-selected result. The first version is intentionally small: one public endpoint, uniform selection by array position, predictable JSON, and no account or saved data.

Free usage: up to 10 requests per website per UTC day, subject to a shared service capacity of 1,000 free API requests per UTC day.

Endpoint

POST /api/v1/spin

Use Content-Type: application/json. Browser requests are supported with public CORS and no credentials.

Browser calls are grouped by normalized Origin. Server and other no-Origin calls fall back to the best available proxy-controlled client address. Every POST attempt counts before its body is processed; CORS preflight OPTIONS requests do not.

curl -X POST https://www.clickthewheel.com/api/v1/spin \
  -H 'Content-Type: application/json' \
  -d '{"entries":["Tea","Coffee","Water"],"removeSelected":false}'

Request

{
  "entries": ["Red", "Blue", "Green"],
  "removeSelected": true
}
entries — required
2–100 nonblank strings. Each entry is trimmed and may contain up to 120 characters.
removeSelected — optional
Boolean, default false. When true, remainingEntries excludes only the selected array position.

Success response

{
  "ok": true,
  "data": {
    "selected": { "index": 1, "value": "Blue" },
    "entryCount": 3,
    "removeSelected": true,
    "remainingEntries": ["Red", "Green"]
  },
  "meta": {
    "apiVersion": "v1",
    "requestId": "generated-request-id"
  }
}

Duplicate values are allowed and occupy separate positions, so duplicates intentionally increase that value's chance of selection.

A discussion-prompt picker you can copy

Save this as an HTML page and serve it from your website. Each click requests one prompt, then keeps the returned remaining list in this page. Your host decides how people use the prompt; the API does not assign speakers or record their participation.

<button id="choose" type="button">Choose a discussion prompt</button>
<p id="result" role="status" aria-live="polite"></p>
<script>
const button = document.querySelector("#choose");
const output = document.querySelector("#result");
let entries = ["Share a question", "Explain an example", "Summarize a point"];
let retryAt = 0;

button.addEventListener("click", async () => {
  if (Date.now() < retryAt) {
    output.textContent = "Wait until " + new Date(retryAt).toLocaleTimeString()
      + " before trying again.";
    return;
  }
  button.disabled = true;
  try {
    const response = await fetch("https://www.clickthewheel.com/api/v1/spin", {
      method: "POST",
      credentials: "omit",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ entries, removeSelected: true })
    });
    const payload = await response.json();
    if (!response.ok) {
      if (response.status === 429) {
        const seconds = Number(response.headers.get("Retry-After"));
        if (Number.isFinite(seconds) && seconds > 0) {
          retryAt = Date.now() + seconds * 1000;
        }
      }
      throw new Error(payload.error?.message || "The request did not succeed.");
    }
    entries = payload.data.remainingEntries;
    output.textContent = "Selected: " + payload.data.selected.value;
    if (entries.length === 1) {
      output.textContent += ". One prompt remains: " + entries[0]
        + ". Use it directly; another request needs at least two entries.";
    }
  } catch (error) {
    output.textContent = error instanceof Error ? error.message : "Request failed.";
  } finally {
    button.disabled = entries.length < 2;
  }
});
</script>
  1. Keep your current entries in the caller. With removeSelected: true, pass remainingEntries into the next manual request. Reloading this example restores its original list.
  2. selected.index is zero-based within the submitted, trimmed array. Identical text can occupy multiple positions; removal excludes just the selected position.
  3. A 429 pauses requests. Read Retry-After before trying again; this example never retries automatically. Each POST attempt is subject to the limits below.
  4. If a response is lost, another POST is a new random selection. There is no idempotency key, replay endpoint or server-side draw history. Avoid blind retries when an outcome matters.

Server-side JavaScript

const response = await fetch("https://www.clickthewheel.com/api/v1/spin", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ entries: ["Alice", "Bob", "Casey"] })
});

const result = await response.json();
if (!result.ok) {
  console.error(result.error.code, result.error.message);
  process.exitCode = 1;
} else {
  console.log(result.data.selected);
}

Errors

{
  "ok": false,
  "error": {
    "code": "TOO_FEW_ENTRIES",
    "message": "Provide at least 2 entries.",
    "details": { "minEntries": 2 }
  },
  "meta": {
    "apiVersion": "v1",
    "requestId": "generated-request-id",
    "docsUrl": "https://www.clickthewheel.com/developers"
  }
}

Expected statuses are 400 for invalid JSON or fields, 413 for an oversized body, 415 for the wrong content type, 429 for rate limiting, 405 for GET, and 500 for an unexpected server error. OPTIONS returns an empty 204 response for preflight.

Free daily limit response

{
  "ok": false,
  "error": {
    "code": "FREE_SITE_DAILY_LIMIT_REACHED",
    "message": "Free usage is limited to 10 requests per website per UTC day. Try again after the UTC reset.",
    "details": {
      "limit": 10,
      "period": "UTC day",
      "resetAt": 1788048000
    }
  },
  "meta": {
    "apiVersion": "v1",
    "requestId": "generated-request-id",
    "docsUrl": "https://www.clickthewheel.com/developers"
  }
}

A 429 response includes Retry-After, UTC reset time, and X-RateLimit-Policy. A website that reaches its allowance does not consume more shared daily capacity. If shared free capacity is exhausted, availability can pause for every integration until the next UTC day.

Website exhaustion uses FREE_SITE_DAILY_LIMIT_REACHED. Shared service exhaustion uses the distinct FREE_GLOBAL_DAILY_CAPACITY_REACHED code without returning any website, client, or internal bucket identifier.

Limits and safety

  • Maximum request body: 16 KB.
  • Maximum combined entry text: 5,000 characters.
  • Free usage: 10 POST attempts per normalized website Origin per UTC day.
  • Shared free capacity: 1,000 POST attempts per UTC day across the running service.
  • Additional safety limits: 60 requests per minute per client and 600 per minute per running server instance.
  • Successful response rate-limit headers describe the website's free daily allowance. A blocking response identifies the policy that paused the request.
  • The API uses Node's cryptographic randomInt to select uniformly among submitted array positions.
  • The endpoint does not read or mutate accounts, rooms, saved wheels, admin data, or Supabase records.

These limits are best-effort, in-memory, and single-process. They reset on restart, do not coordinate across multiple instances, and are not a billing guarantee. A non-browser caller can forge or rotate Origin values, while proxies and distributed callers can change the fallback identity. Stronger protection would require API keys, a persistent distributed counter, and AWS budget alarms.

What this integration includes

This is a JSON selection API, not an animated-wheel embed or a live-room integration. Your website renders the result and owns any list or session state. No API key or ClickTheWheel account is required. Send ordinary demonstration labels, not confidential names or records.

For a reproducible integration problem, contact us with the HTTP status, error code and request ID. Omit private entries and invitation links. Service availability and support response times are not guaranteed.

Responsible use

This API is for ordinary website choices, games, classroom prompts, and similar low-stakes uses. It is not a certified lottery system, audit log, randomness beacon, or substitute for legal, medical, financial, safety, eligibility, or professional judgment. Do not send confidential entries; standard hosting infrastructure may retain ordinary access logs even though the API itself does not persist request bodies or results.