Dough Git

commit

Add genshin data

commit
7ade7524199625e0b67326fcccbe321149af88bd
author
Clove Twilight <[email protected]>
date
2026-08-02 11:10

diff --git a/src/apidata.ts b/src/apidata.ts
index 67c063f..9eb8cca 100644
--- a/src/apidata.ts
+++ b/src/apidata.ts
@@ -1,276 +1,314 @@
 /* =====================================================================
- * apidata.ts — the single source of truth for the endpoint catalogue.
+ * docs.ts — the /docs API reference page.
  *
- * Consumed by docs.ts (rendered client-side on /docs) and openapi.ts
- * (converted to the /openapi.json spec). Keep this in sync when routes
- * change — nothing else needs editing.
+ * A single self-contained HTML page (no build step, no external deps). All
+ * endpoints are described by the GROUPS data structure in the embedded
+ * script and rendered client-side, with a live filter box. Keep this in
+ * sync when routes change.
  * ===================================================================== */
 
-export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "WS";
-export type AuthKind = "public" | "auth" | "admin" | "owner" | "pet" | "jwt" | "bot" | "key";
-
-export interface EndpointDef {
-  m: HttpMethod;
-  path: string;
-  auth: AuthKind;
-  desc: string;
-  /** [name, description] pairs; names starting with "?" are query params. */
-  params?: [string, string][];
-  example?: string;
-  note?: string;
-  /** True when the path is at the site root rather than under /v2. */
-  root?: boolean;
+import { GROUPS } from "./apidata";
+
+// Serialised for the client-side renderer; "<" escaped so "</script>" in a
+// description can never terminate the inline script block.
+const GROUPS_JSON = JSON.stringify(GROUPS).replace(/</g, "\\u003c");
+
+export const DOCS_HTML = `<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<link rel="icon" type="image/png" href="/icon.png" />
+<title>Doughmination API reference</title>
+<style>
+  /* Comic Code + info dark palette, matching every other app. */
+  @font-face { font-family: "Comic Code";
+    src: url("https://fonts.doughmination.co.uk/ComicCode-Regular_2022-05-24-151938_hsmz.woff2") format("woff2");
+    font-weight: 400; font-style: normal; font-display: swap; }
+  @font-face { font-family: "Comic Code";
+    src: url("https://fonts.doughmination.co.uk/ComicCode-Medium_2022-05-24-151941_ugqm.woff2") format("woff2");
+    font-weight: 500; font-style: normal; font-display: swap; }
+  @font-face { font-family: "Comic Code";
+    src: url("https://fonts.doughmination.co.uk/ComicCode-Bold_2022-05-24-152309_zqkm.woff2") format("woff2");
+    font-weight: 700; font-style: normal; font-display: swap; }
+  :root {
+    color-scheme: dark;
+
+    /* Info dark palette (was Catppuccin Mocha). */
+    --base: #0a0b10;
+    --mantle: #070810;
+    --crust: #050609;
+    --surface0: #12141c;
+    --surface1: #1b1e2a;
+    --surface2: #232838;
+    --overlay0: #5b6480;
+    --overlay1: #6b7391;
+    --overlay2: #9aa3c2;
+    --subtext0: #9aa3c2;
+    --subtext1: #c9cfe0;
+    --text: #f4f6fb;
+    --pink: #f5a9b8;
+    /* HTTP-method hues kept distinguishable so the badges stay readable. */
+    --mauve: #c9a9f0;
+    --red: #f38ba8;
+    --peach: #fab387;
+    --yellow: #f9e2af;
+    --green: #a6e3a1;
+    --sky: #89dceb;
+    --blue: #89b4fa;
+
+    /* App aliases */
+    --bg: var(--base);
+    --panel: var(--surface0);
+    --panel2: var(--surface1);
+    --line: var(--surface2);
+    --fg: var(--text);
+    --muted: var(--subtext0);
+    --mono: "Comic Code", ui-monospace, SFMono-Regular, Menlo, monospace;
+    --accent: var(--pink);
+
+    --get: var(--green); --post: var(--yellow); --put: var(--blue); --del: var(--red); --ws: var(--mauve);
+  }
+  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; min-width: 0; }
+  html { scroll-behavior: smooth; }
+  body { margin: 0; font: 15px/1.6 "Comic Code", ui-monospace, monospace; background: var(--bg); color: var(--fg); overflow-x: hidden; }
+
+  header {
+    padding: 24px 20px 14px; border-bottom: 1px solid var(--line);
+    position: sticky; top: 0; background: linear-gradient(var(--bg), rgba(10,11,16,.94));
+    backdrop-filter: blur(6px); z-index: 20;
+    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
+  }
+  .header-text { min-width: 0; }
+  h1 { margin: 0 0 4px; font-size: 21px; color: var(--fg); }
+  h1 .accent-dot { color: var(--accent); }
+  header p { margin: 0; color: var(--subtext0); font-size: 13.5px; }
+  header p.disclaimer { margin: 6px 0 0; font-size: 12px; color: var(--muted); font-style: italic; }
+  header code { color: var(--pink); background: var(--surface0); border: 1px solid var(--line); word-break: break-all; }
+
+  .nav-toggle {
+    display: none; flex-shrink: 0; width: 38px; height: 38px; align-items: center; justify-content: center;
+    background: var(--surface0); border: 1px solid var(--line); border-radius: 8px;
+    color: var(--fg); font-size: 17px; cursor: pointer;
+  }
+  .nav-toggle:hover { background: var(--surface1); }
+  .nav-toggle:focus-visible { outline: 2px solid var(--pink); outline-offset: 1px; }
+
+  .wrap { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 20px; max-width: 980px; margin: 0 auto; padding: 20px; }
+
+  nav {
+    position: sticky; top: 108px; align-self: start; font-size: 14px;
+    max-height: calc(100vh - 130px); overflow: auto; padding-right: 4px;
+  }
+  nav a {
+    display: block; color: var(--subtext0); text-decoration: none; padding: 6px 10px;
+    border-radius: 7px; border-left: 2px solid transparent; margin-bottom: 1px;
+  }
+  nav a:hover { color: var(--fg); background: var(--surface0); }
+  nav a:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }
+
+  #filter {
+    width: 100%; padding: 10px 14px; border-radius: 9px; border: 1px solid var(--line);
+    background: var(--surface0); color: var(--fg); font: inherit; margin-bottom: 14px;
+  }
+  #filter::placeholder { color: var(--overlay1); }
+  #filter:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px rgba(245,169,184,.18); }
+
+  section { margin-bottom: 32px; scroll-margin-top: 116px; }
+  section > h2 { font-size: 16.5px; margin: 0 0 3px; color: var(--fg); }
+  section > .blurb { color: var(--subtext0); font-size: 13.5px; margin: 0 0 14px; }
+
+  .ep {
+    border: 1px solid var(--line); background: var(--surface0); border-radius: 10px;
+    padding: 12px 14px; margin-bottom: 10px;
+  }
+  .ep-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
+
+  .m {
+    font: 700 12px var(--mono); padding: 2px 8px; border-radius: 5px; letter-spacing: .04em;
+    border: 1px solid transparent; flex-shrink: 0;
+  }
+  .m.GET    { background: rgba(166,227,161,.14); color: var(--get);  border-color: rgba(166,227,161,.35); }
+  .m.POST   { background: rgba(249,226,175,.14); color: var(--post); border-color: rgba(249,226,175,.35); }
+  .m.PUT    { background: rgba(137,180,250,.16); color: var(--put);  border-color: rgba(137,180,250,.35); }
+  .m.DELETE { background: rgba(243,139,168,.16); color: var(--del);  border-color: rgba(243,139,168,.35); }
+  .m.WS     { background: rgba(203,166,247,.16); color: var(--ws);   border-color: rgba(203,166,247,.35); }
+
+  .path { font: 600 14px/1.35 var(--mono); word-break: break-all; color: var(--fg); }
+
+  .auth {
+    margin-left: auto; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
+    color: var(--subtext0); border: 1px solid var(--line); padding: 2px 8px; border-radius: 20px;
+    flex-shrink: 0;
+  }
+  .auth.public { color: var(--green); border-color: rgba(166,227,161,.4); }
+  .auth.jwt, .auth.auth { color: var(--blue); border-color: rgba(137,180,250,.4); }
+  .auth.admin, .auth.owner, .auth.pet { color: var(--peach); border-color: rgba(250,179,135,.4); }
+  .auth.bot, .auth.key { color: var(--mauve); border-color: rgba(203,166,247,.4); }
+
+  .desc { margin: 9px 0 0; color: var(--subtext1); font-size: 14px; }
+
+  .params { margin: 10px 0 0; border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 13px; }
+  .params td { padding: 4px 10px 4px 0; vertical-align: top; border-top: 1px solid var(--surface1); word-break: break-word; }
+  .params tr:first-child td { border-top: none; }
+  .params td:first-child { width: 30%; font: 600 12px var(--mono); color: var(--pink); }
+
+  .note { margin: 9px 0 0; font-size: 13px; color: var(--muted); }
+
+  pre {
+    margin: 9px 0 0; background: var(--mantle); border: 1px solid var(--line); border-radius: 8px;
+    padding: 9px 11px; overflow: auto; font: 12px/1.5 var(--mono); color: var(--subtext1);
+  }
+  code { font: 12px var(--mono); background: var(--mantle); color: var(--pink); padding: 1px 5px; border-radius: 4px; }
+
+  .hidden { display: none; }
+  a.self { color: var(--accent); text-decoration: none; }
+
+  ::selection { background: rgba(245,169,184,.28); color: var(--fg); }
+
+  /* Scrollbars, for the browsers that respect this */
+  * { scrollbar-color: var(--surface2) var(--mantle); scrollbar-width: thin; }
+
+  /* ---------- Responsive ---------- */
+  @media (max-width: 760px) {
+    .wrap { grid-template-columns: 1fr; gap: 14px; padding: 14px; }
+    .nav-toggle { display: flex; }
+    nav {
+      position: static; z-index: auto; align-self: auto;
+      display: flex; flex-direction: column; gap: 2px;
+      max-height: 0; overflow: hidden; padding: 0 6px;
+      background: var(--mantle); border: 1px solid var(--line); border-radius: 10px;
+      transition: max-height .22s ease, padding .22s ease, margin .22s ease;
+      margin-bottom: 0;
+    }
+    body.nav-open nav {
+      max-height: 60vh; overflow-y: auto; padding: 8px 6px; margin-bottom: 4px;
+    }
+    nav a { white-space: normal; padding: 9px 10px; border-radius: 7px; }
+    nav a:hover { background: var(--surface1); }
+    header { padding: 18px 14px 12px; }
+    h1 { font-size: 18px; }
+    header p { font-size: 13px; }
+  }
+
+
+  @media (max-width: 480px) {
+    body { font-size: 14px; }
+    .ep { padding: 11px 12px; }
+    .ep-head { gap: 8px; }
+    .auth { margin-left: 0; order: 3; flex-basis: 100%; }
+    .path { font-size: 13px; }
+    .params td { display: block; padding: 2px 0; }
+    .params td:first-child { padding-top: 6px; }
+    .params tr:first-child td:first-child { padding-top: 2px; }
+    #filter { font-size: 16px; } /* avoid iOS zoom-on-focus */
+  }
+</style>
+</head>
+<body>
+<header>
+  <div class="header-text">
+    <h1>Doughmination API reference</h1>
+    <p>Universal API: live Discord presence, Discord profiles, Minecraft skins & Hypixel stats, Genshin roster tracking, the plural system, and misc services. Base URL: <code>https://doughmination.uk/v2</code> · <a class="self" href="/openapi.json">OpenAPI spec</a> · <a class="self" href="/abuse">Abuse</a> · <a class="self" href="/terms">Terms</a> · <a class="self" href="/privacy">Privacy</a></p>
+    <p class="disclaimer">Not affiliated with, endorsed by, or associated with Hypixel Inc. or Mojang/Microsoft. Hypixel stats are provided via the Hypixel Public API for the operator's own accounts only.</p>
+  </div>
+  <button id="navToggle" class="nav-toggle" type="button" aria-expanded="false" aria-controls="nav">
+    <span aria-hidden="true">☰</span>
+  </button>
+</header>
+
+<div class="wrap">
+  <nav id="nav"></nav>
+  <div>
+    <input id="filter" placeholder="Filter endpoints… (e.g. fronters, devices, ws)" autocomplete="off" />
+    <div id="content"></div>
+  </div>
+</div>
+
+<script>
+// Auth legend: public | auth (any logged-in) | admin | owner | pet | jwt | bot | key
+var GROUPS = ${GROUPS_JSON};
+
+function esc(s) {
+  return String(s == null ? "" : s).replace(/[&<>"']/g, function (c) {
+    return { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c];
+  });
 }
 
-export interface GroupDef {
-  id: string;
-  name: string;
-  blurb: string;
-  endpoints: EndpointDef[];
+function epHtml(ep) {
+  var params = "";
+  if (ep.params && ep.params.length) {
+    params = '<table class="params">' + ep.params.map(function (p) {
+      return "<tr><td>" + esc(p[0]) + "</td><td>" + esc(p[1]) + "</td></tr>";
+    }).join("") + "</table>";
+  }
+  var note = ep.note ? '<p class="note">' + esc(ep.note) + "</p>" : "";
+  var example = ep.example ? "<pre>" + esc(ep.example) + "</pre>" : "";
+  return '<div class="ep" data-q="' + esc((ep.m + " " + ep.path + " " + ep.desc).toLowerCase()) + '">' +
+    '<div class="ep-head">' +
+    '<span class="m ' + ep.m + '">' + ep.m + "</span>" +
+    '<span class="path">' + esc(ep.path) + "</span>" +
+    '<span class="auth ' + ep.auth + '">' + ep.auth + "</span>" +
+    "</div>" +
+    '<p class="desc">' + esc(ep.desc) + "</p>" +
+    params + note + example +
+    "</div>";
 }
 
-export const GROUPS: GroupDef[] = [
-  {
-    id: "auth-overview", name: "Authentication", blurb: "How protected endpoints are secured.",
-    endpoints: [
-      { m: "GET", path: "Bearer JWT", auth: "jwt",
-        desc: "Most /plural write endpoints need a login token. Get one from POST /plural/login, then send it as 'Authorization: Bearer <token>'. Tokens last 24 hours. Some routes additionally require an admin, owner, or pet role." },
-      { m: "GET", path: "X-Battery-Key", auth: "key",
-        desc: "Reporting or deleting device state (POST/DELETE /devices) needs your device key, sent as the 'X-Battery-Key' header." },
-      { m: "GET", path: "Bot token", auth: "bot",
-        desc: "The /plural/bot/* endpoints are for the companion Discord bot: they need both a 'User-Agent: CloveShortcuts/<version>' header and the bot's token as 'Authorization: Bearer <token>'." },
-    ],
-  },
-  {
-    id: "discord", name: "Discord — profiles, presence & guilds", blurb: "One merged record: profile, badges, equipped collectibles, and live presence.",
-    endpoints: [
-      { m: "GET", path: "/discord/users/:id", auth: "public",
-        desc: "A user's full record in one call: profile (avatar, banner, badges, connected accounts, and — when available — bio, pronouns and reviews), the collectibles they have equipped (nameplate, profile frame, profile effect, avatar decoration — each resolved to its name and image assets), and their live presence (status, activities, Spotify, platforms). Fetched fresh on every request. Presence is null if the user shares no tracked server with the bot.",
-        params: [["id", "Discord user ID."], ["?fresh / ?nocache / ?refresh", "Force fresh sub-resource lookups (collectibles/wishlist) instead of their short shared caches."]] },
-      { m: "GET", path: "/discord/status", auth: "public",
-        desc: "Live-presence connection health: whether it's connected, how many users are tracked, and recent reconnect activity." },
-      { m: "GET", path: "/discord/guilds/:invite", auth: "public",
-        desc: "Public guild info resolved from an invite code: name, icon/banner/splash, member + online counts.",
-        params: [["invite", "Invite code (the part after discord.gg/)."]] },
-      { m: "GET", path: "/discord/girls/:idType/:id", auth: "public",
-        desc: "Look up a role or a member inside the 'girls' server.",
-        params: [["idType", "'role' or 'member'."], ["id", "The role ID or member (user) ID."]] },
-    ],
-  },
-  {
-    id: "minecraft", name: "Minecraft", blurb: "Skins and Hypixel stats for a Minecraft account.",
-    endpoints: [
-      { m: "GET", path: "/minecraft/general/:uuid", auth: "public",
-        desc: "A player's Mojang identity: username, UUID (both dashed and short forms), skin and cape texture URLs, the skin's arm model (classic or slim), every cape the player has across providers (Minecraft, OptiFine, MinecraftCapes, LabyMod, 5zig, TLauncher, SkinMC — plus a custom 'doughmination' cape for hand-picked accounts) via the capes array, and a set of ready-to-embed mc-heads render images (face, head, body, player, combo, skin) — each render includes the overlay/hat layer, with _flat variants for the inner skin only. Returns 404 if no Minecraft account has that UUID.",
-        params: [["uuid", "Minecraft UUID — 32 hex characters, dashes optional."], ["?fresh / ?nocache / ?refresh", "Skip the cache and fetch fresh."]],
-        example: 'GET /minecraft/general/853c80ef3c3749fdaa49938b674adae6  →  { name, uuid, skin_url, cape_url, skin_model, capes: [ { source, cape_url } ], render: { face, head, body, player, combo, skin } }' },
-      { m: "GET", path: "/minecraft/capes", auth: "public",
-        desc: "The set of vanilla (Mojang) capes the API has seen, persisted to memory. It grows over time: every account looked up via /minecraft/general has its equipped vanilla cape remembered, deduped by texture hash. Third-party capes (OptiFine, LabyMod, etc.) are loaded fresh per request and are not persisted here.",
-        params: [],
-        example: 'GET /minecraft/capes  →  { count, capes: [ { source: "minecraft", cape_url } ] }' },
-      { m: "GET", path: "/minecraft/hypixel/:uuid", auth: "public",
-        desc: "Hypixel stats for one of the operator's OWN Minecraft accounts: the player object (network level and per-game stats — Bedwars, SkyWars, Duels, and the rest) plus their SkyBlock profiles. Per Hypixel API policy this only serves the operator's allowlisted accounts — any other UUID returns 403. Cache-first with a 5-minute TTL (no manual cache-bypass). Always returns 200 for an allowed account; the 'source' field says whether each section loaded ('ok') or why it's null ('not_found' if the account never joined Hypixel, 'unavailable' if Hypixel data isn't configured). Not affiliated with or endorsed by Hypixel Inc.",
-        params: [["uuid", "Minecraft UUID (32 hex, dashes optional) — must be one of the operator's own accounts."]],
-        example: 'GET /minecraft/hypixel/853c80ef3c3749fdaa49938b674adae6  →  { name, player: {…}, skyblock: [{…}], source: { player: "ok", skyblock: "ok" } }' },
-    ],
-  },
-  {
-    id: "plural-auth", name: "Plural — accounts & auth", blurb: "Login, signup, password reset, and the current user.",
-    endpoints: [
-      { m: "POST", path: "/plural/login", auth: "public",
-        desc: "Log in with your username and password (plus a Turnstile captcha token). Returns an access token to use on protected endpoints.",
-        example: 'POST body: { "username": "admin", "password": "…", "turnstile_token": "…" }  →  { "access_token": "…", "token_type": "bearer", "success": true }' },
-      { m: "POST", path: "/plural/signup", auth: "public",
-        desc: "Create a non-admin account. Body { username, password (≥10 chars), email, display_name?, turnstile_token }. Email is required and unique. The account starts UNCONFIRMED: login is refused until the emailed link is used, and unconfirmed accounts are deleted after 24 hours. The response includes a short-lived correction_token — hold onto it, it's the only way to fix a mistyped address without a password.",
-        example: 'POST body: { "username": "clove", "password": "…", "email": "[email protected]", "turnstile_token": "…" }  →  { "success": true, "email_sent": true, "correction_token": "…", "user": { … } }' },
-      { m: "POST", path: "/plural/verify-email", auth: "public",
-        desc: "Confirm an address using the token from the email. Body { token }. Single use, valid 24 hours. Also applies a pending email change." },
-      { m: "POST", path: "/plural/resend-verification", auth: "public",
-        desc: "Send the confirmation link again. Body { turnstile_token } plus either { correction_token } or { username, password }. Rate limited to one per IP per minute." },
-      { m: "POST", path: "/plural/correct-email", auth: "public",
-        desc: "Fix a mistyped address before confirmation, without a password. Body { correction_token, email, turnstile_token }. The correction token is issued only to the client that signed up, lasts 2 hours, and stops working once the account is confirmed — it is what stops anyone repointing an unconfirmed account at their own inbox." },
-      { m: "GET", path: "/plural/users/check-username?username=", auth: "public",
-        desc: "Check username availability. Returns { username, exists, available }." },
-      { m: "GET", path: "/plural/users/check-email?email=", auth: "public",
-        desc: "Check email availability. Returns { email, exists, available }. Rate limited to 20 lookups per IP per minute." },
-      { m: "POST", path: "/plural/forgot-password", auth: "public",
-        desc: "Request a password-reset link by USERNAME. Body { username, turnstile_token }. The link is emailed to the address on file for that account; the response reports a masked hint so the user knows which inbox to check. Returns 404 for an unknown username and 409 if the account has no email on file. Rate limited to one request per IP per minute.",
-        example: 'POST body: { "username": "clove", "turnstile_token": "…" }  →  { "success": true, "message": "Reset link sent. The link expires in 15 minutes.", "sent_to": "a•••@d•••.win" }' },
-      { m: "POST", path: "/plural/forgot-username", auth: "public",
-        desc: "Recover a forgotten username by EMAIL. Body { email, turnstile_token }. The username is emailed to that address rather than returned, so knowing an address isn't enough to learn the username on it. Returns 404 if the address isn't registered. Rate limited to one request per IP per minute.",
-        example: 'POST body: { "email": "[email protected]", "turnstile_token": "…" }  →  { "success": true, "message": "We\'ve sent your username to that address.", "sent_to": "y•••@e•••.com" }' },
-      { m: "GET", path: "/plural/reset-password/check?token=", auth: "public",
-        desc: "Check whether a reset token is still usable before rendering the form. Returns { valid }." },
-      { m: "POST", path: "/plural/reset-password", auth: "public",
-        desc: "Set a new password using a token from the reset email. Body { token, new_password (≥10 chars), turnstile_token }. Tokens last 15 minutes, are single-use, and requesting a new one revokes the previous.",
-        example: 'POST body: { "token": "…", "new_password": "…", "turnstile_token": "…" }  →  { "success": true, "message": "Your password has been reset. …" }' },
-      { m: "GET", path: "/plural/user_info", auth: "auth",
-        desc: "The current authenticated user (no password hash)." },
-      { m: "GET", path: "/plural/auth/is_admin", auth: "auth", desc: "{ isAdmin } for the current user." },
-      { m: "GET", path: "/plural/auth/is_owner", auth: "auth", desc: "{ isOwner } for the current user." },
-      { m: "GET", path: "/plural/auth/is_pet", auth: "auth", desc: "{ isPet } for the current user." },
-    ],
-  },
-  {
-    id: "plural-system", name: "Plural — system & mental state", blurb: "PluralKit system info and the tracked mental state.",
-    endpoints: [
-      { m: "GET", path: "/plural/system", auth: "public",
-        desc: "PluralKit system info (name, description, tag) with the current mental_state attached." },
-      { m: "GET", path: "/plural/mental-state", auth: "public",
-        desc: "Current mental state: { level, updated_at, notes }." },
-      { m: "POST", path: "/plural/mental-state", auth: "admin",
-        desc: "Update mental state. Body { level, notes? }. Broadcasts a mental_state_update over /ws." },
-    ],
-  },
-  {
-    id: "plural-members", name: "Plural — members & tags", blurb: "System members, their tags and custom status.",
-    endpoints: [
-      { m: "GET", path: "/plural/members", auth: "public",
-        desc: "All members enriched with tags and custom status." },
-      { m: "GET", path: "/plural/member/:member_id", auth: "public",
-        desc: "One member by id OR name (case-insensitive), enriched with tags + status.",
-        params: [["member_id", "PluralKit member id or name."]] },
-      { m: "GET", path: "/plural/member-tags", auth: "admin", desc: "The full member → tags map." },
-      { m: "POST", path: "/plural/member-tags/:member_identifier", auth: "admin",
-        desc: "Replace a member's tag list. Body: string[] (JSON array of tags)." },
-      { m: "POST", path: "/plural/member-tags/:member_identifier/add", auth: "admin",
-        desc: "Add one tag. Body { tag }." },
-      { m: "DELETE", path: "/plural/member-tags/:member_identifier/:tag", auth: "admin",
-        desc: "Remove one tag from a member." },
-      { m: "GET", path: "/plural/members/:member_identifier/status", auth: "public",
-        desc: "A member's custom status ({ text, emoji, updated_at }) or null." },
-      { m: "POST", path: "/plural/members/:member_identifier/status", auth: "admin",
-        desc: "Set/update a member's status. Body { text (≤100 chars), emoji? }." },
-      { m: "DELETE", path: "/plural/members/:member_identifier/status", auth: "admin",
-        desc: "Clear a member's status." },
-    ],
-  },
-  {
-    id: "plural-fronting", name: "Plural — fronting", blurb: "Who is fronting, and switching.",
-    endpoints: [
-      { m: "GET", path: "/plural/fronters", auth: "public",
-        desc: "Current fronters, enriched with tags + status. { members: [...] }." },
-      { m: "POST", path: "/plural/switch", auth: "auth",
-        desc: "Set the front to a list. Body { members: string[] }. Broadcasts fronters_update." },
-      { m: "POST", path: "/plural/switch_front", auth: "auth",
-        desc: "Switch to a single fronter. Body { member_id }." },
-      { m: "POST", path: "/plural/multi_switch", auth: "auth",
-        desc: "Switch to several fronters with detailed feedback. Body { member_ids: string[] }." },
-    ],
-  },
-  {
-    id: "plural-users", name: "Plural — user management", blurb: "Admin CRUD over accounts.",
-    endpoints: [
-      { m: "GET", path: "/plural/users", auth: "admin", desc: "List all users (no password hashes)." },
-      { m: "POST", path: "/plural/users", auth: "admin",
-        desc: "Create a user. Body { username, password, email?, display_name?, is_admin?, is_pet? }. Accounts created here are pre-confirmed — the address is being assigned deliberately — so they can log in immediately and are never touched by the unconfirmed-account sweep." },
-      { m: "PUT", path: "/plural/users/:user_id", auth: "auth",
-        desc: "Update a user (admin, or the user themselves). Body may include display_name, current_password + new_password, avatar_url (an EXTERNAL image URL — uploads were removed), is_admin, is_pet, email. EMAIL RULES: a user may change their own address but must supply current_password, and the new address is held in pending_email until confirmed (the old one keeps working, and gets an alert). The owner may set anyone's address outright. A plain admin may NOT change someone else's." },
-      { m: "DELETE", path: "/plural/users/:user_id", auth: "admin",
-        desc: "Delete a user. Cannot delete yourself or the owner." },
-    ],
-  },
-  {
-    id: "plural-metrics", name: "Plural — metrics", blurb: "Fronting analytics.",
-    endpoints: [
-      { m: "GET", path: "/plural/metrics/fronting-time?days=30", auth: "auth",
-        desc: "Per-member fronting time across 24h/48h/5d/7d/30d windows and totals." },
-      { m: "GET", path: "/plural/metrics/switch-frequency?days=30", auth: "auth",
-        desc: "Switch counts per window and average switches/day." },
-    ],
-  },
-  {
-    id: "plural-realtime", name: "Plural — realtime & admin", blurb: "The unified WebSocket + broadcast controls.",
-    endpoints: [
-      { m: "WS", path: "/ws", auth: "public",
-        desc: "The single realtime socket for ALL live updates. On connect you get a connection_established message. Fronting (fronters_update), mental state (mental_state_update), device/battery (device_update) and force_refresh events are pushed to every client automatically. For live Discord presence, send a subscribe frame — either { \"type\": \"subscribe\", \"all\": true } or { \"type\": \"subscribe\", \"ids\": [\"<user id>\", …] }; you'll get an init_state snapshot immediately and presence_update events thereafter (only for the users you subscribed to). Every message is a { type, data } object. Send 'ping' to get 'pong'." },
-      { m: "POST", path: "/plural/admin/refresh", auth: "admin",
-        desc: "Broadcast a force_refresh to every connected /ws client." },
-    ],
-  },
-  {
-    id: "plural-bot", name: "Plural — bot API", blurb: "For the Discord bot (User-Agent + bot token).",
-    endpoints: [
-      { m: "GET", path: "/plural/bot/health", auth: "bot", desc: "Liveness check." },
-      { m: "GET", path: "/plural/bot/system/info", auth: "bot", desc: "System info wrapped as { success, data }." },
-      { m: "GET", path: "/plural/bot/members", auth: "bot", desc: "Members with tags + status." },
-      { m: "GET", path: "/plural/bot/fronters", auth: "bot", desc: "Current fronters." },
-      { m: "POST", path: "/plural/bot/switch", auth: "bot",
-        desc: "Switch fronters with validation. Body { member_ids: string[] }." },
-      { m: "POST", path: "/plural/bot/token/regenerate", auth: "owner",
-        desc: "No longer available — returns 410. The bot token is now set manually by the server operator." },
-    ],
-  },
-  {
-    id: "plural-seo", name: "Plural — SEO", blurb: "Data-driven crawler files.",
-    endpoints: [
-      { m: "GET", path: "/plural/robots.txt", auth: "public", desc: "robots.txt." },
-      { m: "GET", path: "/plural/sitemap.xml", auth: "public", desc: "Sitemap generated from the member list." },
-    ],
-  },
-  {
-    id: "devices", name: "Devices", blurb: "Latest known device state (battery, charging, low power mode, wifi).",
-    endpoints: [
-      { m: "GET", path: "/devices", auth: "public", desc: "All devices → { device, level, charging, lowPowerMode, wifi, watch, airpods, updated_at }." },
-      { m: "GET", path: "/devices/:device", auth: "public", desc: "One device, or 404." },
-      { m: "POST", path: "/devices?device=iphone&level=25&charging=1&lpm=0&wifi=Home&watch=1&airpods=0", auth: "key",
-        desc: "Report device state. Only 'device' is required; supplied fields are updated, the rest untouched. Send the X-Battery-Key header.",
-        params: [["device", "1–64 chars (required)."], ["level", "Optional. Integer 0–100."], ["charging", "Optional. 1 (true) or 0 (false)."], ["lpm", "Optional. 1 (true) or 0 (false) → lowPowerMode."], ["wifi", "Optional. Any string (network name), ≤128 chars."], ["watch", "Optional. 1 (connected) or 0 (not connected)."], ["airpods", "Optional. 1 (connected) or 0 (not connected)."]] },
-      { m: "DELETE", path: "/devices?device=iphone", auth: "key",
-        desc: "Delete a device's state. Returns 404 if the device doesn't exist. Send the X-Battery-Key header.",
-        params: [["device", "1–64 chars (required)."]] },
-    ],
-  },
-  {
-    id: "guestbook", name: "Guestbook", blurb: "Public guestbook. Each entry gets a random UID so it can be deleted individually.",
-    endpoints: [
-      { m: "GET", path: "/guestbook?limit=50&offset=0", auth: "public",
-        desc: "List entries, newest first → { entries: [{ id, name, message, website, ts }], total, limit, offset }.",
-        params: [["limit", "Optional. 1–200, default 50."], ["offset", "Optional. ≥0, default 0."]] },
-      { m: "POST", path: "/guestbook", auth: "public",
-        desc: "Sign the guestbook. Honeypot (url2) + Turnstile (when configured) + per-IP rate limit (60s). Returns { ok, entry } with the new UID.",
-        example: 'POST body: { "name": "Clove", "message": "hi!", "website": "https://…", "turnstileToken": "…" }' },
-      { m: "DELETE", path: "/guestbook/:id", auth: "key",
-        desc: "Delete an entry by its UID. Returns 404 if not found. Send the X-Battery-Key header.",
-        params: [["id", "The entry's UID (required)."]] },
-      { m: "POST", path: "/guestbook/import", auth: "key",
-        desc: "Migration import: insert an entry with a fresh UID, bypassing captcha + rate limit. Send the X-Battery-Key header. Body { name, message, website? }." },
-    ],
-  },
-  {
-    id: "system-data", name: "System-data — visitor logs", blurb: "Visit logging plus an admin-only log viewer.",
-    endpoints: [
-      { m: "POST", path: "/system-data/helper", auth: "public",
-        desc: "Log a page visit (the frontend pings this on navigation). Body { path? }." },
-      { m: "GET", path: "/system-data/helper?path=", auth: "public", desc: "Log a page visit via a plain GET, for cases where a POST isn't convenient." },
-      { m: "GET", path: "/system-data", auth: "admin", desc: "HTML log viewer (single page)." },
-      { m: "GET", path: "/system-data/api/stats", auth: "admin", desc: "Totals, unique IPs, last-24h, top paths." },
-      { m: "GET", path: "/system-data/api/recent?limit=100", auth: "admin", desc: "Recent visits." },
-      { m: "GET", path: "/system-data/api/by-ip/:ip", auth: "admin", desc: "Visits from an IP." },
-      { m: "GET", path: "/system-data/api/by-path?q=", auth: "admin", desc: "Visits matching a path substring." },
-      { m: "GET", path: "/system-data/api/suspicious", auth: "admin", desc: ">20 hits/hour from one IP." },
-      { m: "GET", path: "/system-data/api/entry/:id", auth: "admin", desc: "One full log row." },
-    ],
-  },
-  {
-    id: "contrib", name: "Contrib", blurb: "Merged git contribution heatmaps.",
-    endpoints: [
-      { m: "GET", path: "/contribapi", auth: "public",
-        desc: "A single contribution heatmap that merges activity from GitHub and Codeberg. Updated at most hourly." },
-    ],
-  },
-  {
-    id: "meta", name: "Meta", blurb: "Service info, health, docs, and legal pages.",
-    endpoints: [
-      { m: "GET", path: "/", auth: "public", desc: "Service info (JSON) — the namespace map, plus docs/health/abuse/terms/privacy links.", root: true },
-      { m: "GET", path: "/health", auth: "public",
-        desc: "Liveness: Discord gateway connection state + tracked-user count + SYSTEM DO reachability. Returns HTTP 200 when everything is up, 503 when degraded — point your uptime monitor here." },
-      { m: "GET", path: "/docs", auth: "public", desc: "This page.", root: true },
-      { m: "GET", path: "/openapi.json", auth: "public", desc: "Machine-readable OpenAPI 3.1 spec generated from the same catalogue that renders this page.", root: true },
-      { m: "GET", path: "/abuse", auth: "public", desc: "Abuse & contact page: how to report abuse, request data removal / opt-out, or disclose a vulnerability.", root: true },
-      { m: "GET", path: "/terms", auth: "public", desc: "Terms of service — the short version: be reasonable with request volume or your IP gets blocked.", root: true },
-      { m: "GET", path: "/privacy", auth: "public", desc: "Privacy page: what's logged (visitor IPs, guestbook entries, cached Discord data), why, and how to get it removed.", root: true },
-      { m: "GET", path: "/.well-known/security.txt", auth: "public", desc: "RFC 9116 security contact file. Also available at /security.txt.", root: true },
-    ],
-  },
-];
+function render() {
+  var nav = document.getElementById("nav");
+  var content = document.getElementById("content");
+  nav.innerHTML = GROUPS.map(function (g) {
+    return '<a href="#' + g.id + '">' + esc(g.name) + "</a>";
+  }).join("");
+  content.innerHTML = GROUPS.map(function (g) {
+    return '<section id="' + g.id + '">' +
+      "<h2>" + esc(g.name) + "</h2>" +
+      (g.blurb ? '<p class="blurb">' + esc(g.blurb) + "</p>" : "") +
+      g.endpoints.map(epHtml).join("") +
+      "</section>";
+  }).join("");
+}
+
+render();
+
+var navToggle = document.getElementById("navToggle");
+var navEl = document.getElementById("nav");
+
+function setNavOpen(open) {
+  document.body.classList.toggle("nav-open", open);
+  navToggle.setAttribute("aria-expanded", open ? "true" : "false");
+  navToggle.querySelector("span").textContent = open ? "✕" : "☰";
+}
+
+navToggle.addEventListener("click", function () {
+  setNavOpen(!document.body.classList.contains("nav-open"));
+});
+
+navEl.addEventListener("click", function (e) {
+  if (e.target.tagName === "A") setNavOpen(false);
+});
+
+document.addEventListener("click", function (e) {
+  if (!document.body.classList.contains("nav-open")) return;
+  if (navEl.contains(e.target) || navToggle.contains(e.target)) return;
+  setNavOpen(false);
+});
+
+
+document.getElementById("filter").addEventListener("input", function (e) {
+  var q = e.target.value.trim().toLowerCase();
+  document.querySelectorAll("section").forEach(function (sec) {
+    var any = false;
+    sec.querySelectorAll(".ep").forEach(function (ep) {
+      var hit = !q || ep.dataset.q.indexOf(q) !== -1;
+      ep.classList.toggle("hidden", !hit);
+      if (hit) any = true;
+    });
+    sec.classList.toggle("hidden", !any);
+  });
+});
+</script>
+</body>
+</html>
+`;
\ No newline at end of file
diff --git a/src/docs.ts b/src/docs.ts
index 8277295..9eb8cca 100644
--- a/src/docs.ts
+++ b/src/docs.ts
@@ -209,7 +209,7 @@ export const DOCS_HTML = `<!doctype html>
 <header>
   <div class="header-text">
     <h1>Doughmination API reference</h1>
-    <p>Universal API: live Discord presence, Discord profiles, Minecraft skins & Hypixel stats, the plural system, and misc services. Base URL: <code>https://doughmination.uk/v2</code> · <a class="self" href="/openapi.json">OpenAPI spec</a> · <a class="self" href="/abuse">Abuse</a> · <a class="self" href="/terms">Terms</a> · <a class="self" href="/privacy">Privacy</a></p>
+    <p>Universal API: live Discord presence, Discord profiles, Minecraft skins & Hypixel stats, Genshin roster tracking, the plural system, and misc services. Base URL: <code>https://doughmination.uk/v2</code> · <a class="self" href="/openapi.json">OpenAPI spec</a> · <a class="self" href="/abuse">Abuse</a> · <a class="self" href="/terms">Terms</a> · <a class="self" href="/privacy">Privacy</a></p>
     <p class="disclaimer">Not affiliated with, endorsed by, or associated with Hypixel Inc. or Mojang/Microsoft. Hypixel stats are provided via the Hypixel Public API for the operator's own accounts only.</p>
   </div>
   <button id="navToggle" class="nav-toggle" type="button" aria-expanded="false" aria-controls="nav">
diff --git a/src/genshin.ts b/src/genshin.ts
new file mode 100644
index 0000000..64b92d8
--- /dev/null
+++ b/src/genshin.ts
@@ -0,0 +1,217 @@
+/* =====================================================================
+ * genshin.ts — Enka.Network passthrough + static-data merge for a
+ * player's Genshin character roster (owned/not-owned + level).
+ *
+ * Two independent cache tiers in the same PROFILE_CACHE KV, since they
+ * change at very different rates:
+ *   - the character *catalog* (Enka's store/characters.json + store/loc.json,
+ *     merged into id -> {name, element, rarity, icon}) barely ever changes —
+ *     cached ~24h.
+ *   - a given player's *roster* (their UID response) can change any time
+ *     they refresh their in-game showcase — cached using the `ttl` Enka
+ *     itself returns, so we never serve staler data than Enka intends.
+ *
+ * Note: Enka only returns a player's full owned roster (`avatarInfoList`)
+ * if they've enabled "Display all your characters" on their in-game
+ * Character Showcase. Otherwise only the pinned showcase characters
+ * (`showAvatarInfoList`, up to 8) come back — the response below flags
+ * this via `partial: true` so callers/UIs can prompt the user to enable it.
+ * ===================================================================== */
+
+import type { Env, UnifiedGenshinCharacter, UnifiedGenshinRoster } from "./types";
+import { ABUSE_CONTACT } from "./abuse";
+
+const ENKA_UID_BASE = "https://enka.network/api/uid";
+const CHARACTERS_JSON_URL =
+  "https://raw.githubusercontent.com/EnkaNetwork/API-docs/master/store/characters.json";
+const LOC_JSON_URL = "https://raw.githubusercontent.com/EnkaNetwork/API-docs/master/store/loc.json";
+const ICON_BASE = "https://enka.network/ui";
+const ENKA_USER_AGENT = `doughmination-genshin-roster/2.0 (+https://doughmination.uk; contact: ${ABUSE_CONTACT})`;
+
+const CATALOG_TTL_SECONDS = 60 * 60 * 24; // static game data — refresh daily
+const ROSTER_MIN_TTL_SECONDS = 30; // floor under Enka's own ttl, avoids 0/negative
+const CATALOG_KEY = "genshin:catalog:v1";
+const rosterKey = (uid: string) => `genshin:roster:${uid}`;
+
+const ELEMENT_NAMES: Record<string, string> = {
+  Fire: "Pyro",
+  Water: "Hydro",
+  Wind: "Anemo",
+  Electric: "Electro",
+  Ice: "Cryo",
+  Rock: "Geo",
+  Grass: "Dendro",
+};
+
+interface RawCharacterEntry {
+  Element?: string;
+  QualityType?: string;
+  SideIconName?: string;
+  NameTextMapHash?: number;
+}
+type RawCharacters = Record<string, RawCharacterEntry>;
+type RawLoc = Record<string, Record<string, string>>; // lang -> hash -> name
+
+interface EnkaShowAvatar {
+  avatarId: number;
+  level: number;
+}
+interface EnkaAvatarInfo {
+  avatarId: number;
+  propMap?: Record<string, { ival?: string }>;
+}
+interface EnkaUidResponse {
+  playerInfo: {
+    nickname?: string;
+    level?: number;
+    showAvatarInfoList?: EnkaShowAvatar[];
+    avatarInfoList?: EnkaAvatarInfo[];
+  };
+  ttl?: number;
+}
+
+/** Character ids that are real, currently-playable characters — excludes empty
+ *  placeholder entries, alt-costume/trial recolors (10000900+, 11000000+),
+ *  and per-element Traveler skill variants (ids containing a hyphen). */
+function isPlayableId(id: string, entry: RawCharacterEntry): boolean {
+  if (!entry || !entry.QualityType) return false;
+  if (id.includes("-")) return false;
+  const n = Number(id);
+  if (!Number.isFinite(n)) return false;
+  if (n >= 11000000) return false; // duplicate/legacy recolors
+  if (n >= 10000900 && n < 10001000) return false; // trial/alt-costume recolors
+  return true;
+}
+
+async function fetchJson<T>(url: string): Promise<T> {
+  const res = await fetch(url, { headers: { "User-Agent": ENKA_USER_AGENT, Accept: "application/json" } });
+  if (!res.ok) throw new Error(`Upstream ${url} returned ${res.status}`);
+  return (await res.json()) as T;
+}
+
+interface CatalogEntry {
+  name: string;
+  element: string;
+  rarity: number;
+  iconUrl: string;
+  sideIconUrl: string;
+}
+type Catalog = Record<string, CatalogEntry>;
+
+/** Build (or fetch from cache) the full playable-character catalog. */
+async function getCatalog(env: Env, ctx?: ExecutionContext, force = false): Promise<Catalog> {
+  if (!force) {
+    const cached = (await env.PROFILE_CACHE.get(CATALOG_KEY, "json")) as Catalog | null;
+    if (cached) return cached;
+  }
+
+  const [characters, loc] = await Promise.all([
+    fetchJson<RawCharacters>(CHARACTERS_JSON_URL),
+    fetchJson<RawLoc>(LOC_JSON_URL),
+  ]);
+  const en = loc.en ?? {};
+
+  const catalog: Catalog = {};
+  for (const [id, entry] of Object.entries(characters)) {
+    if (!isPlayableId(id, entry)) continue;
+    const name = entry.NameTextMapHash != null ? en[String(entry.NameTextMapHash)] : undefined;
+    const sideIcon = entry.SideIconName ?? "";
+    // "UI_AvatarIcon_Side_Ayaka" -> "UI_AvatarIcon_Ayaka" (front-facing icon)
+    const fullIcon = sideIcon.replace("_Side_", "_");
+    catalog[id] = {
+      name: name ?? `Traveler ${id}`,
+      element: ELEMENT_NAMES[entry.Element ?? ""] ?? entry.Element ?? "Unknown",
+      rarity: entry.QualityType?.startsWith("QUALITY_ORANGE") ? 5 : 4,
+      iconUrl: fullIcon ? `${ICON_BASE}/${fullIcon}.png` : "",
+      sideIconUrl: sideIcon ? `${ICON_BASE}/${sideIcon}.png` : "",
+    };
+  }
+
+  const write = env.PROFILE_CACHE.put(CATALOG_KEY, JSON.stringify(catalog), {
+    expirationTtl: CATALOG_TTL_SECONDS,
+  });
+  if (ctx) ctx.waitUntil(write);
+  else await write;
+
+  return catalog;
+}
+
+/** Thrown when Enka has no record of this UID (private/unindexed/typo'd). */
+export class EnkaNotFoundError extends Error {
+  constructor(uid: string) {
+    super(`No Enka.Network record for UID ${uid}`);
+    this.name = "EnkaNotFoundError";
+  }
+}
+
+/** Full owned/not-owned roster for a UID, merged against the character catalog.
+ *  Cache-first, honoring the `ttl` Enka itself returns for that profile. */
+export async function getGenshinRoster(
+  env: Env,
+  uid: string,
+  ctx?: ExecutionContext,
+  force = false,
+): Promise<UnifiedGenshinRoster> {
+  if (!force) {
+    const cached = (await env.PROFILE_CACHE.get(rosterKey(uid), "json")) as UnifiedGenshinRoster | null;
+    if (cached) return cached;
+  }
+
+  const [raw, catalog] = await Promise.all([
+    (async () => {
+      const res = await fetch(`${ENKA_UID_BASE}/${uid}`, {
+        headers: { "User-Agent": ENKA_USER_AGENT, Accept: "application/json" },
+      });
+      if (res.status === 404 || res.status === 400) throw new EnkaNotFoundError(uid);
+      if (!res.ok) throw new Error(`Enka upstream returned ${res.status}`);
+      return (await res.json()) as EnkaUidResponse;
+    })(),
+    getCatalog(env, ctx, force),
+  ]);
+
+  // Prefer the full roster (only present if the player enabled "Display all
+  // your characters"); fall back to the pinned showcase otherwise.
+  const full = raw.playerInfo.avatarInfoList;
+  const partial = !full || full.length === 0;
+  const owned = new Map<string, number>(); // avatarId -> level
+
+  if (full) {
+    for (const c of full) {
+      const level = Number(c.propMap?.["4001"]?.ival ?? 0);
+      owned.set(String(c.avatarId), level);
+    }
+  } else {
+    for (const c of raw.playerInfo.showAvatarInfoList ?? []) {
+      owned.set(String(c.avatarId), c.level);
+    }
+  }
+
+  const characters: UnifiedGenshinCharacter[] = Object.entries(catalog).map(([id, meta]) => ({
+    id,
+    name: meta.name,
+    element: meta.element,
+    rarity: meta.rarity,
+    icon_url: meta.iconUrl,
+    owned: owned.has(id),
+    level: owned.get(id) ?? null,
+  }));
+  characters.sort((a, b) => (b.owned === a.owned ? a.name.localeCompare(b.name) : b.owned ? 1 : -1));
+
+  const result: UnifiedGenshinRoster = {
+    uid,
+    nickname: raw.playerInfo.nickname ?? null,
+    player_level: raw.playerInfo.level ?? null,
+    partial,
+    owned_count: owned.size,
+    total_count: characters.length,
+    characters,
+    updated_at: Date.now(),
+  };
+
+  const ttl = Math.max(ROSTER_MIN_TTL_SECONDS, raw.ttl ?? ROSTER_MIN_TTL_SECONDS);
+  const write = env.PROFILE_CACHE.put(rosterKey(uid), JSON.stringify(result), { expirationTtl: ttl });
+  if (ctx) ctx.waitUntil(write);
+  else await write;
+
+  return result;
+}
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
index 7ab4d9e..43123d1 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -32,6 +32,7 @@ import type {
   UnifiedMinecraftGeneral,
   UnifiedMinecraftHypixel,
   VanillaCapeList,
+  UnifiedGenshinRoster,
 } from "./types";
 import { getProfile } from "./profile";
 import { GatewayManager } from "./gateway";
@@ -39,6 +40,7 @@ import { getGuildInvite } from "./guild";
 import { getGirlsResource, isGirlsIdType } from "./girls";
 import { getMinecraftGeneral, getMinecraftHypixel, getVanillaCapeList, normalizeMcUuid, isAllowedHypixelUuid, MojangUpstreamError } from "./minecraft";
 import { getContributions } from "./contribapi";
+import { getGenshinRoster, EnkaNotFoundError } from "./genshin";
 import { DOCS_HTML } from "./docs";
 import { ABUSE_HTML, ABUSE_CONTACT, securityTxt } from "./abuse";
 import { TERMS_HTML, PRIVACY_HTML, NOT_FOUND_HTML } from "./pages";
@@ -244,7 +246,7 @@ export default {
         success: true,
         data: {
           service: "Doughmination API",
-          description: "Universal API: live Discord presence + profiles + plural system.",
+          description: "Universal API: live Discord presence + profiles + plural system + Genshin roster tracking.",
           licence: "DASL-1.0",
           repository_url: "https://github.com/doughmination/api",
           docs: "/docs",
@@ -383,6 +385,27 @@ export default {
       return json<UnifiedMinecraftHypixel>({ success: true, data });
     }
 
+    // ---- /v2/genshin/roster/:uid  (owned/not-owned + level, via Enka.Network) ----
+    // Stateless passthrough + merge: Enka's live UID data joined against the
+    // (separately, long-) cached character catalog. See ./genshin.ts for the
+    // `partial` caveat (player must enable "Display all your characters").
+    const gs = path.match(/^\/v2\/genshin\/roster\/(\d{1,12})$/);
+    if (gs) {
+      const uid = gs[1];
+      try {
+        const data = await getGenshinRoster(env, uid, ctx, wantsForce(url));
+        return json<UnifiedGenshinRoster>({ success: true, data });
+      } catch (err) {
+        if (err instanceof EnkaNotFoundError) {
+          return json({ success: false, error: { code: "not_found", message: err.message } }, 404);
+        }
+        return json(
+          { success: false, error: { code: "upstream_error", message: (err as Error).message } },
+          502,
+        );
+      }
+    }
+
     // ---- /v2/discord/users/:id  (merged profile + presence) --------------
     // Profile (REST) + presence (gateway) in parallel — the full user record
     // the website's presence cards render from.
@@ -429,5 +452,4 @@ function isInsecure(req: Request, url: URL): boolean {
   const visitor = req.headers.get("cf-visitor");
   if (visitor && /"scheme"\s*:\s*"http"/i.test(visitor)) return true;
   return false;
-}
-
+}
\ No newline at end of file
diff --git a/src/types.ts b/src/types.ts
index ca27b55..6890db0 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -541,4 +541,35 @@ export interface ApiEnvelope<T> {
   success: boolean;
   data?: T;
   error?: { code: string; message: string };
+}
+
+// ---- genshin (/v2/genshin/roster/:uid) -------------------------------------
+
+export interface UnifiedGenshinCharacter {
+  /** Enka/game avatarId, as a string (matches the catalog + API responses). */
+  id: string;
+  name: string;
+  /** Localized element name, e.g. "Pyro", "Cryo". */
+  element: string;
+  /** 4 or 5. */
+  rarity: number;
+  icon_url: string;
+  owned: boolean;
+  /** Character level, or null if not owned. */
+  level: number | null;
+}
+
+export interface UnifiedGenshinRoster {
+  uid: string;
+  nickname: string | null;
+  player_level: number | null;
+  /** True when Enka only returned the player's pinned showcase (<= 8 chars)
+   *  rather than their full roster — i.e. they haven't enabled "Display all
+   *  your characters" on their in-game Character Showcase. `owned`/`level`
+   *  below are then only accurate for the characters they've pinned. */
+  partial: boolean;
+  owned_count: number;
+  total_count: number;
+  characters: UnifiedGenshinCharacter[];
+  updated_at: number;
 }
\ No newline at end of file