{
  "openapi": "3.1.0",
  "info": {
    "title": "shadertown",
    "version": "1.0.0",
    "summary": "The registry behind 82 production WebGPU shaders.",
    "description": "shadertown serves 82 WebGPU shaders — animated backgrounds, image effects and GPU simulations — as vendorable source.\n\nThe catalogue is read without authentication: `GET /r/` lists every shader, and `GET /r/{slug}.json` returns one shader's complete files — the WGSL, a typed preset, an example, a README and the licence.\n\n16 of 82 shaders hand over their source to anyone. The other 66 answer 402 unless the request carries a device token from an account on a paid plan (Gold at $19.99 once). Previewing and tuning every shader is free and needs no account at all.\n\nEvery control is a query parameter. Pass `?speed=0.4&colorA=1b2f4a` to pin those values into the preset the registry writes.",
    "contact": {
      "name": "shadertown",
      "email": "hello@shadertown.com",
      "url": "https://www.shadertown.com/contact"
    },
    "license": {
      "name": "MIT",
      "identifier": "MIT"
    },
    "termsOfService": "https://www.shadertown.com/terms"
  },
  "externalDocs": {
    "description": "Documentation, and the agent index",
    "url": "https://www.shadertown.com/llms.txt"
  },
  "servers": [
    {
      "url": "https://www.shadertown.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "registry",
      "description": "Reading the catalogue and taking shader source."
    },
    {
      "name": "device authorization",
      "description": "Connecting a terminal to an account, for the paid tier."
    },
    {
      "name": "agents",
      "description": "Endpoints written for coding agents rather than browsers."
    }
  ],
  "paths": {
    "/r": {
      "get": {
        "operationId": "listShaders",
        "tags": [
          "registry"
        ],
        "summary": "List every shader in the catalogue",
        "description": "The whole catalogue as one document: slug, name, tagline, family, tags, rendering cost and tier for every shader. No authentication. Call this first — the slugs it returns are what every other operation takes. `/r/` answers the same thing.",
        "security": [],
        "responses": {
          "200": {
            "description": "The catalogue index.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogueIndex"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/r/{slug}.json": {
      "get": {
        "operationId": "getShaderSource",
        "tags": [
          "registry"
        ],
        "summary": "Take one shader's complete source files",
        "description": "Returns the five files that make up a shader: the complete WGSL with the shared prelude inlined, a typed preset pinned to the parameters in the query string, a working React example, a README documenting every control, and the licence. The `.json` suffix is optional.\n\nFree shaders answer to anyone. Professional shaders answer 402 unless an `Authorization: Bearer <token>` header carries a device token from an account on a paid plan.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Slug"
          },
          {
            "$ref": "#/components/parameters/Control"
          }
        ],
        "security": [
          {},
          {
            "deviceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "The shader, with its files.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShaderItem"
                }
              }
            }
          },
          "402": {
            "description": "A Professional shader, asked for without a paid plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No shader by that slug.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "callMcp",
        "tags": [
          "agents"
        ],
        "summary": "Call the MCP server over Streamable HTTP",
        "description": "A Model Context Protocol server, speaking JSON-RPC 2.0 over Streamable HTTP. Tools: `search_shaders`, `get_shader`, `get_shader_source`. The same server runs over stdio as `npx shadertown mcp`, which adds the tools that write files. Send `Authorization: Bearer <token>` to read Professional source.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          }
        },
        "security": [
          {},
          {
            "deviceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "A JSON-RPC response. A tool that fails answers 200 with `isError` set — the call was made, and the model is meant to read why it did not work.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "202": {
            "description": "The message was a notification, so there is nothing to answer."
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "operationId": "getAgentIndex",
        "tags": [
          "agents"
        ],
        "summary": "The site, indexed for agents",
        "description": "What shadertown is for, when to reach for it, and every URL an agent can call, as markdown. Every page listed in it also answers `Accept: text/markdown`.",
        "security": [],
        "responses": {
          "200": {
            "description": "The index.",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/device/start": {
      "post": {
        "operationId": "startDeviceAuthorization",
        "tags": [
          "device authorization"
        ],
        "summary": "Begin connecting a terminal to an account",
        "description": "Issues a device code for the client to keep and a short user code for the person to type at the verification URI. This is step one of `npx shadertown login`, and the only way a machine obtains a token.",
        "security": [],
        "responses": {
          "200": {
            "description": "The codes, and where to send the person.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceFlow"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/device/poll": {
      "post": {
        "operationId": "pollDeviceAuthorization",
        "tags": [
          "device authorization"
        ],
        "summary": "Ask whether the terminal has been approved yet",
        "description": "Poll no faster than the `interval` from `startDeviceAuthorization`. 202 means nobody has approved yet, 429 means slow down, 410 means the code expired and the flow has to start again.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DevicePollRequest"
              }
            }
          }
        },
        "security": [],
        "responses": {
          "200": {
            "description": "Approved. The token is the licence for this machine.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceToken"
                }
              }
            }
          },
          "202": {
            "description": "Not approved yet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "No device code in the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "The device code expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Polling faster than the interval asked for.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/device/approve": {
      "post": {
        "operationId": "approveDeviceAuthorization",
        "tags": [
          "device authorization"
        ],
        "summary": "Approve a terminal from the browser",
        "description": "Called by the signed-in browser on behalf of the person, not by the terminal. It needs the session cookie, so it is documented here for completeness rather than as an operation a machine client can make.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceApproveRequest"
              }
            }
          }
        },
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Approved; the terminal's next poll receives its token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceApproval"
                }
              }
            }
          },
          "401": {
            "description": "Nobody is signed in.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "That user code expired or was never issued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "That code was already approved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "deviceToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "A device token from `npx shadertown login`. It names the account and the plan it held at sign-in, so an upgrade needs a fresh login to reach a terminal."
      },
      "session": {
        "type": "apiKey",
        "in": "cookie",
        "name": "better-auth.session_token",
        "description": "The browser session. Only `approveDeviceAuthorization` uses it."
      }
    },
    "responses": {
      "Error": {
        "description": "The call did not work, said in the one shape every failure here takes.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "parameters": {
      "Slug": {
        "name": "slug",
        "in": "path",
        "required": true,
        "description": "The shader's slug, from `listShaders`.",
        "schema": {
          "$ref": "#/components/schemas/Slug"
        }
      },
      "Control": {
        "name": "control",
        "in": "query",
        "required": false,
        "style": "form",
        "explode": true,
        "description": "Any of the shader's own controls, by name, to pin into the preset that is written. Numbers for controls; six-digit hex without the `#` for `colorA`, `colorB` and `colorC`.\n\nWhich names a shader takes is part of the shader: `getShaderSource` returns them in its README, and the markdown rendering of `/shaders/{slug}` tables every one with its range and default. Omitted controls keep the catalogue default.",
        "schema": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "example": {
          "speed": "0.4",
          "intensity": "1.15",
          "colorA": "1b2f4a"
        }
      }
    },
    "schemas": {
      "Slug": {
        "type": "string",
        "description": "One of the catalogue's shader slugs.",
        "enum": [
          "aurora",
          "liquid-light",
          "alloy",
          "chromatic-city",
          "caustics",
          "basalt",
          "blueprint",
          "ferro",
          "filament",
          "strata",
          "spectra",
          "shafts",
          "billow",
          "gossamer",
          "swell",
          "meadow",
          "pixel-isle",
          "voronoi",
          "dunes",
          "starfield",
          "ripple",
          "louvres",
          "truchet",
          "kaleidoscope",
          "halftone",
          "tunnel",
          "julia",
          "silk",
          "neon-grid",
          "bokeh",
          "dither",
          "mesh-gradient",
          "film-grain",
          "radiance",
          "lumen",
          "beacon",
          "orb",
          "eyes",
          "tesla",
          "magnet",
          "torch",
          "parallax",
          "gravity",
          "particles",
          "fluid",
          "cloth",
          "chladni",
          "liquid-metal",
          "maelstrom",
          "plasma",
          "pulsar",
          "glass",
          "lens",
          "bloom",
          "shockwave",
          "swirl",
          "flow",
          "duotone",
          "edges",
          "mosaic",
          "reveal",
          "neon-sign",
          "ascii",
          "shatter",
          "melt",
          "pixel-sea",
          "pixel-clouds",
          "pixel-fire",
          "pixel-rain",
          "lagoon",
          "island",
          "shore",
          "caldera",
          "archipelago",
          "blossom",
          "hills",
          "cumulus",
          "contour",
          "nebula",
          "iridescence",
          "glyph-rain",
          "hyperspeed"
        ]
      },
      "Tier": {
        "type": "string",
        "description": "`free` hands over its source to anyone. `professional` needs a paid plan for the source; previewing and tuning stay free.",
        "enum": [
          "free",
          "professional"
        ]
      },
      "Cost": {
        "type": "string",
        "description": "The work this shader does per pixel per frame.",
        "enum": [
          "light",
          "medium",
          "heavy"
        ]
      },
      "CatalogueIndex": {
        "type": "object",
        "required": [
          "name",
          "homepage",
          "items"
        ],
        "properties": {
          "$schema": {
            "type": "string",
            "format": "uri"
          },
          "name": {
            "type": "string",
            "const": "shadertown"
          },
          "homepage": {
            "type": "string",
            "format": "uri"
          },
          "paywallEnabled": {
            "type": "boolean",
            "description": "False means every shader's source answers to anyone, whatever its tier."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CatalogueEntry"
            }
          }
        }
      },
      "CatalogueEntry": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "tagline",
          "family",
          "tags",
          "cost",
          "tier",
          "url"
        ],
        "properties": {
          "slug": {
            "$ref": "#/components/schemas/Slug"
          },
          "name": {
            "type": "string",
            "description": "The shader's display name."
          },
          "tagline": {
            "type": "string",
            "description": "One line describing what it looks like."
          },
          "family": {
            "type": "string",
            "description": "The kind of picture it makes.",
            "enum": [
              "organic",
              "spatial",
              "drafting",
              "particles",
              "light",
              "scene",
              "pixel",
              "geometric",
              "gradient",
              "texture",
              "fractal",
              "compute",
              "optical",
              "distortion",
              "image",
              "transition"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cost": {
            "$ref": "#/components/schemas/Cost"
          },
          "tier": {
            "$ref": "#/components/schemas/Tier"
          },
          "url": {
            "type": "string",
            "description": "Where to fetch this shader's files, relative to the server."
          }
        }
      },
      "ShaderItem": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "tagline",
          "description",
          "family",
          "tags",
          "cost",
          "tier",
          "license",
          "dependencies",
          "files"
        ],
        "properties": {
          "$schema": {
            "type": "string",
            "format": "uri"
          },
          "slug": {
            "$ref": "#/components/schemas/Slug"
          },
          "name": {
            "type": "string"
          },
          "tagline": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "description": "A paragraph on what it draws and how it behaves."
          },
          "family": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cost": {
            "$ref": "#/components/schemas/Cost"
          },
          "tier": {
            "$ref": "#/components/schemas/Tier"
          },
          "license": {
            "type": "string",
            "const": "MIT"
          },
          "dependencies": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "npm packages the written files import."
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ShaderFile"
            }
          }
        }
      },
      "ShaderFile": {
        "type": "object",
        "required": [
          "path",
          "type",
          "content"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "Where to write it, relative to the output directory."
          },
          "type": {
            "type": "string",
            "enum": [
              "wgsl",
              "preset",
              "example",
              "readme",
              "license"
            ],
            "description": "What the file is, so a client can write only the parts it wants."
          },
          "content": {
            "type": "string",
            "description": "The file, in full."
          }
        }
      },
      "DeviceFlow": {
        "type": "object",
        "required": [
          "device_code",
          "user_code",
          "verification_uri",
          "expires_in",
          "interval"
        ],
        "properties": {
          "device_code": {
            "type": "string",
            "description": "Kept by the client and sent when polling."
          },
          "user_code": {
            "type": "string",
            "description": "Shown to the person to type."
          },
          "verification_uri": {
            "type": "string",
            "format": "uri"
          },
          "verification_uri_complete": {
            "type": "string",
            "format": "uri",
            "description": "The same page with the code filled in."
          },
          "expires_in": {
            "type": "integer",
            "description": "Seconds until the codes stop working."
          },
          "interval": {
            "type": "integer",
            "description": "Seconds to wait between polls."
          }
        }
      },
      "DevicePollRequest": {
        "type": "object",
        "required": [
          "device_code"
        ],
        "properties": {
          "device_code": {
            "type": "string"
          }
        }
      },
      "DeviceToken": {
        "type": "object",
        "required": [
          "access_token"
        ],
        "properties": {
          "access_token": {
            "type": "string",
            "description": "Send as `Authorization: Bearer <token>`."
          },
          "licensee": {
            "type": "string",
            "description": "The name written into the licence files."
          }
        }
      },
      "DeviceApproveRequest": {
        "type": "object",
        "required": [
          "user_code"
        ],
        "properties": {
          "user_code": {
            "type": "string"
          }
        }
      },
      "DeviceApproval": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "licensee": {
            "type": "string"
          },
          "plan": {
            "$ref": "#/components/schemas/Tier"
          }
        }
      },
      "JsonRpcRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "description": "Omit for a notification, which is answered with 202 and no body."
          },
          "method": {
            "type": "string",
            "description": "An MCP method.",
            "enum": [
              "initialize",
              "ping",
              "tools/list",
              "tools/call"
            ]
          },
          "params": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "JsonRpcResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {},
          "result": {
            "type": "object",
            "additionalProperties": true
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "The one shape every failure here takes.",
        "required": [
          "error",
          "message",
          "docs"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "A stable code to branch on. Codes are added, never renamed.",
            "enum": [
              "not_found",
              "payment_required",
              "invalid_request",
              "not_signed_in",
              "unknown_code",
              "already_approved",
              "authorization_pending",
              "slow_down",
              "expired_token",
              "unknown_endpoint",
              "not_acceptable"
            ]
          },
          "message": {
            "type": "string",
            "description": "The failure, in a sentence."
          },
          "hint": {
            "type": "string",
            "description": "What to do about it."
          },
          "reason": {
            "type": "string",
            "description": "Why, when the why is not obvious from the code."
          },
          "upgrade": {
            "type": "string",
            "format": "uri",
            "description": "Where to buy a plan, on a 402."
          },
          "interval": {
            "type": "integer",
            "description": "Seconds to wait, when polling."
          },
          "docs": {
            "type": "string",
            "format": "uri",
            "const": "https://www.shadertown.com/openapi.json"
          }
        }
      }
    }
  }
}