{
 "openapi": "3.1.0",
 "info": {
  "title": "NWWSter API",
  "version": "1.1.0",
  "description": "Turn a list of music albums into a poster in the style of the 1979 Nurse With Wound list, or a link to a vertical video reel of it. Auth: account API key from https://nwwster.fyi/developers sent as `Authorization: Bearer nwws_...`. Each poster render uses one of the account's 20 renders per day (resets at midnight Asia/Jerusalem), the same counter as the website; creating a reel link uses none. An MCP server with the same tools is at https://nwwster.fyi/mcp.",
  "contact": {
   "url": "https://nwwster.fyi/developers"
  }
 },
 "servers": [
  {
   "url": "https://nwwster.fyi"
  }
 ],
 "security": [
  {
   "apiKey": []
  }
 ],
 "paths": {
  "/api/v1/designs": {
   "get": {
    "operationId": "listDesigns",
    "summary": "List poster designs",
    "security": [],
    "responses": {
     "200": {
      "description": "Designs",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "designs": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Design"
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/albums/search": {
   "get": {
    "operationId": "searchAlbums",
    "summary": "Search albums (MusicBrainz)",
    "description": "Results are external catalog data. Pass the chosen result's id and cover_url to createPoster. 30 searches per minute per key.",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 200
      },
      "description": "\"Artist - Album\", or free text"
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 15,
       "default": 5
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Matches",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "results": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Album"
           }
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     },
     "502": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/api/v1/posters": {
   "post": {
    "operationId": "createPoster",
    "summary": "Render a poster",
    "description": "Uses one of the account's 20 daily renders. Send `Accept: image/png` (or image/jpeg with format=jpeg) to receive raw image bytes; otherwise JSON with base64. At most 6 renders per minute per key.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PosterRequest"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Rendered poster",
      "headers": {
       "X-Renders-Remaining": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PosterResult"
        }
       },
       "image/png": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       },
       "image/jpeg": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     },
     "502": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/api/v1/quota": {
   "get": {
    "operationId": "getQuota",
    "summary": "Renders left today",
    "responses": {
     "200": {
      "description": "Quota",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Quota"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/api/v1/options": {
   "get": {
    "operationId": "getPosterOptions",
    "summary": "List poster style options",
    "description": "Every optional style setting accepted by POST /api/v1/posters and POST /api/v1/reels, with valid values and ranges, plus what each design sets. No key needed.",
    "security": [],
    "responses": {
     "200": {
      "description": "Options",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PosterOptions"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/reels": {
   "post": {
    "operationId": "createReel",
    "summary": "Create a video reel link",
    "description": "Saves the poster spec for 30 days and returns links. Uses no render and no quota now. reel_url opens the poster on nwwster.fyi, renders it in the visitor's browser (one render from the visitor's own allowance: 3 per browser without an account, 20 per day signed in) and shows a \"Make video reel\" button that records a silent vertical 1080x1920 video (MP4 where the browser supports it, else WebM) in the browser. poster_url opens the same poster in the editor. At most 10 links per minute per key and 200 per account per day.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ReelRequest"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Links created",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ReelResult"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     },
     "503": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/api/shared/{id}": {
   "get": {
    "operationId": "getSharedPoster",
    "summary": "Read a shared poster spec",
    "description": "Public, no key. Used by the /r/{id} and /p/{id} pages. 404 when unknown, 410 when expired.",
    "security": [],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z0-9]{10,32}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Spec: {v, design, settings, entries:[{artist,title,src,rgid?}], expires_at}"
     },
     "404": {
      "description": "Unknown link"
     },
     "410": {
      "description": "Expired link"
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "apiKey": {
    "type": "http",
    "scheme": "bearer",
    "description": "Account API key, nwws_ followed by 48 hex characters"
   }
  },
  "responses": {
   "Error": {
    "description": "Error",
    "content": {
     "application/json": {
      "schema": {
       "type": "object",
       "properties": {
        "error": {
         "type": "object",
         "properties": {
          "code": {
           "type": "string",
           "examples": [
            "UNAUTHORIZED",
            "DAILY_LIMIT",
            "RATE_LIMITED",
            "UNKNOWN_DESIGN",
            "INVALID_ALBUMS",
            "INVALID_OPTION",
            "GRID_TOO_SMALL",
            "SHARE_LIMIT"
           ]
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "schemas": {
   "Design": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "enum": [
       "paper",
       "color-list",
       "dark-gallery",
       "archive",
       "xerox",
       "ink",
       "dither",
       "typed-list",
       "nww",
       "nww-circle",
       "nww-cover",
       "nww-cover-dark"
      ]
     },
     "name": {
      "type": "string"
     },
     "description": {
      "type": "string"
     },
     "preview_url": {
      "type": "string",
      "format": "uri"
     },
     "shows_album_names": {
      "type": "boolean"
     }
    }
   },
   "Album": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "description": "MusicBrainz release-group id"
     },
     "artist": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "year": {
      "type": [
       "string",
       "null"
      ]
     },
     "type": {
      "type": [
       "string",
       "null"
      ]
     },
     "cover_url": {
      "type": "string",
      "format": "uri"
     }
    }
   },
   "PosterRequest": {
    "type": "object",
    "required": [
     "albums"
    ],
    "properties": {
     "albums": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
       "type": "object",
       "properties": {
        "artist": {
         "type": "string"
        },
        "title": {
         "type": "string"
        },
        "id": {
         "type": "string",
         "description": "release-group id from search"
        },
        "cover_url": {
         "type": "string",
         "description": "cover_url from search (coverartarchive.org, archive.org or mzstatic.com)"
        }
       }
      },
      "description": "Albums in poster order. artist + title is enough; covers are looked up automatically."
     },
     "design": {
      "type": "string",
      "enum": [
       "paper",
       "color-list",
       "dark-gallery",
       "archive",
       "xerox",
       "ink",
       "dither",
       "typed-list",
       "nww",
       "nww-circle",
       "nww-cover",
       "nww-cover-dark"
      ],
      "default": "xerox",
      "description": "A design is a full look; the style options override parts of it (see GET /api/v1/options)."
     },
     "caption": {
      "type": "string",
      "maxLength": 60,
      "description": "Poster headline, top left (default \"THE LIST\"). Long captions are shrunk or wrapped to two lines to fit, never cut off."
     },
     "name": {
      "type": "string",
      "maxLength": 60,
      "description": "Name or @handle shown as compiler"
     },
     "show_album_names": {
      "type": "boolean",
      "description": "Shortcut for cover designs: true = covers plus typed album list (layout covers_list), false = covers only. Applied after layout."
     },
     "layout": {
      "type": "string",
      "enum": [
       "covers",
       "covers_list",
       "list",
       "block"
      ],
      "description": "Poster layout. \"covers\" = cover grid only; \"covers_list\" = cover grid plus a typed album list under it; \"list\" = typed album list only, no covers; \"block\" = the Nurse With Wound text block (album names as one dense typed block, shaped by block_shape). Default comes from the design."
     },
     "cols": {
      "type": "integer",
      "minimum": 1,
      "maximum": 10,
      "description": "Cover grid columns (covers / covers_list layouts). Omit cols and rows to let the server pick a grid with no empty slot (an incomplete last row is centred). If you set both cols and rows the grid size is kept: cols*rows must be >= the number of albums; spare slots are dropped and the last row is centred unless keep_empty_slots is true. Set only one of them to fix that side and let the server compute the other."
     },
     "rows": {
      "type": "integer",
      "minimum": 1,
      "maximum": 10,
      "description": "Cover grid rows. See cols."
     },
     "paper": {
      "type": "string",
      "enum": [
       "xerox",
       "toner",
       "aged"
      ],
      "description": "Paper colour. \"xerox\" = light grey photocopy paper with dark ink; \"toner\" = black paper with light ink; \"aged\" = yellowed cream paper."
     },
     "treatment": {
      "type": "string",
      "enum": [
       "raw",
       "xerox",
       "dither",
       "halftone"
      ],
      "description": "How covers are printed. \"raw\" = original full colour; \"xerox\" = high-contrast black and white photocopy; \"dither\" = fine black-and-white stipple; \"halftone\" = round halftone dots."
     },
     "catalogue_no": {
      "type": "string",
      "maxLength": 30,
      "description": "Small catalogue number printed top right under the name, e.g. \"No. 001\" (default) or \"NWW 1979\". Empty string hides it."
     },
     "numbers": {
      "type": "boolean",
      "description": "Number the typed album list (1. 2. 3.). Ignored when sort is true."
     },
     "uppercase": {
      "type": "boolean",
      "description": "Print the typed album list and no-cover cards in CAPITALS."
     },
     "artist_only": {
      "type": "boolean",
      "description": "Typed list / text block shows artist names only, each artist once (the original 1979 NWW list style)."
     },
     "sort": {
      "type": "boolean",
      "description": "Sort the typed list / text block alphabetically (ignores leading The/A/Die/Le…). Cover order is unchanged."
     },
     "tilt": {
      "type": "boolean",
      "description": "Slightly tilt and offset each cover like hand-pasted prints. false = perfectly straight grid."
     },
     "gap": {
      "type": "integer",
      "minimum": 0,
      "maximum": 30,
      "description": "Space between covers (0 = covers touch)."
     },
     "grain": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "Photocopy grain, specks and vignette. 0 = clean."
     },
     "block_shape": {
      "type": "string",
      "enum": [
       "none",
       "stripes",
       "circle",
       "cover"
      ],
      "description": "Block layout only: shape cut out of the text block. \"stripes\" = diagonal bands (classic NWW); \"circle\" = text around a circle; \"cover\" = text forms a picture of one album cover (see block_shape_cover); \"none\" = solid block."
     },
     "block_shape_cover": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100,
      "description": "Block layout with block_shape \"cover\": position (1-based) of the album whose cover shapes the text. Default 1."
     },
     "block_shape_threshold": {
      "type": "integer",
      "minimum": 10,
      "maximum": 95,
      "description": "Block layout with block_shape \"cover\": how much of the picture is filled with text (higher = more text)."
     },
     "block_shape_invert": {
      "type": "boolean",
      "description": "Block layout: swap where the text and the empty space go."
     },
     "block_shape_tone": {
      "type": "boolean",
      "description": "Block layout with block_shape \"cover\": vary letter darkness with the picture for a photographic look."
     },
     "block_repeat": {
      "type": "boolean",
      "description": "Block layout: repeat the album names until the whole shape is filled (default true). false = print them once."
     },
     "block_font": {
      "type": "string",
      "enum": [
       "mono",
       "type"
      ],
      "description": "Block layout font. \"mono\" = bold Courier; \"type\" = worn typewriter."
     },
     "find_covers": {
      "type": "boolean",
      "default": true,
      "description": "Look up covers (Apple Music, then MusicBrainz) for albums sent without id/cover_url"
     },
     "format": {
      "type": "string",
      "enum": [
       "png",
       "jpeg"
      ],
      "default": "png"
     },
     "keep_empty_slots": {
      "type": "boolean",
      "description": "Cover grid only, with both cols and rows set: draw spare slots as empty numbered boxes. Default false: no empty boxes, incomplete last row centred."
     }
    }
   },
   "PosterResult": {
    "type": "object",
    "properties": {
     "image_base64": {
      "type": "string"
     },
     "mime": {
      "type": "string"
     },
     "width": {
      "type": "integer"
     },
     "height": {
      "type": "integer"
     },
     "design": {
      "type": "string"
     },
     "albums": {
      "type": "integer"
     },
     "renders_remaining": {
      "type": "integer"
     },
     "daily_limit": {
      "type": "integer"
     },
     "layout": {
      "type": "string"
     },
     "cols": {
      "type": "integer"
     },
     "rows": {
      "type": "integer"
     },
     "warnings": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "E.g. empty slots left by an explicit cols x rows grid"
     }
    }
   },
   "Quota": {
    "type": "object",
    "properties": {
     "remaining": {
      "type": "integer"
     },
     "limit": {
      "type": "integer"
     },
     "period": {
      "type": "string"
     },
     "resets": {
      "type": "string"
     }
    }
   },
   "ReelRequest": {
    "allOf": [
     {
      "$ref": "#/components/schemas/PosterRequest"
     }
    ],
    "type": "object",
    "properties": {
     "language": {
      "type": "string",
      "enum": [
       "en",
       "he",
       "de",
       "fr"
      ],
      "description": "Site language when the link opens (adds ?lang=). Default: the visitor's saved choice, else Hebrew."
     }
    },
    "description": "Same fields as PosterRequest (format is ignored) plus language."
   },
   "ReelResult": {
    "type": "object",
    "properties": {
     "reel_url": {
      "type": "string",
      "format": "uri",
      "examples": [
       "https://nwwster.fyi/r/Ab3dEf6hJk8mNp?lang=en"
      ]
     },
     "poster_url": {
      "type": "string",
      "format": "uri"
     },
     "id": {
      "type": "string"
     },
     "expires_at": {
      "type": "string",
      "format": "date-time"
     },
     "design": {
      "type": "string"
     },
     "albums": {
      "type": "integer"
     },
     "layout": {
      "type": "string"
     },
     "cols": {
      "type": "integer"
     },
     "rows": {
      "type": "integer"
     },
     "renders_used": {
      "type": "integer",
      "const": 0
     },
     "how_it_works": {
      "type": "string"
     },
     "warnings": {
      "type": "array",
      "items": {
       "type": "string"
      }
     }
    }
   },
   "PosterOptions": {
    "type": "object",
    "properties": {
     "options": {
      "type": "object",
      "description": "Option name -> JSON schema with description"
     },
     "designs": {
      "type": "array",
      "items": {
       "type": "object"
      },
      "description": "What each design sets for each option"
     },
     "text": {
      "type": "object"
     },
     "languages": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "limits": {
      "type": "object"
     }
    }
   }
  }
 }
}