{
  "openapi": "3.1.0",
  "info": {
    "title": "拍板 · Paiban",
    "summary": "A shared shopping list with an approval step.",
    "description": "拍板 (Paiban) is a shared shopping list with an approval step. People paste shop links (Taobao, Tmall, Xianyu, JD or any other shop) or plain lines such as `护眼台灯 ¥89`, and each line becomes an item. The person who created the list approves items; the others add and tidy them. Prices are per unit, in yuan (CNY).\n\n## Two ways in\n\n**1. A list's own links: no passphrase.** Every list has three links, each with its own key in the path:\n\n| Link | Page | The same key in the API |\n|---|---|---|\n| creator | `/a/{key}` | `/api/k/{key}`: everything, approving included |\n| shared | `/l/{key}` | `/api/k/{key}`: add and tidy items, but not approve |\n| view-only | `/v/{key}` | `/api/k/{key}`: read only |\n\nAnyone can create a list with `POST /api/lists`; the answer's `ownerUrl` is its creator link, whose last path segment is the key. If someone gave you a list's link, take the key from it and use the `/api/k/{key}` routes. Keep a creator link private: it is the only way to approve.\n\n**2. The passphrase API: `/api/v1`.** Every list on the site, with the creator's rights on each, plus totals. Each request needs `Authorization: Bearer <passphrase>`, a passphrase the site's operator gives out. Without the right one the answer is `401`; after 10 wrong passphrases in a minute from one address, `429` with `Retry-After` (seconds), even for the right one.\n\n## What each link can do\n\n| | creator key / passphrase API | shared key | view-only key |\n|---|---|---|---|\n| Read the list, items, pictures, links | yes | yes | yes |\n| Add items | yes | yes | no |\n| Write notes, tick bought | yes | yes, any item | no |\n| Change title, option, price, quantity | yes | only while the item isn't approved | no |\n| Give an item a link it lacks | yes | yes, any item | no |\n| Replace an item's link | yes | only while the item isn't approved | no |\n| Add a photo to an item with no picture | yes | yes, any item | no |\n| Replace or remove an item's photo | yes | only while the item isn't approved | no |\n| Remove an item | yes | only while the item isn't approved | no |\n| Approve or disapprove items, approve all | yes | no | no |\n| Rename the list, set or remove its cover photo | yes | no | no |\n| Delete the list | passphrase API only | no | no |\n\nA key that may not do something gets `403`. The shared key's answers never contain the creator link, and the view-only key's never contain the shared link.\n\n## Items\n\n`text` is read one item per line: the first `http(s)://` address on a line is its link, the first price written `¥89`, `￥89`, `89元` or `89块` is its price, and the rest is its title (the 「…」 of a Taobao or Xianyu app share text is the title, and the rest of the share text is dropped). `title` adds one item exactly as written, with nothing picked out of it. Items with a link are looked up in the background for a picture, a title and, for Taobao listings with one price for all options, a price: they come back with `\"status\": \"fetching\"`; read the list again a few seconds later. Text is cut to 300 characters for a title, 200 for an option, 1000 for a note and 80 for a list name. A list holds at most 500 items.\n\n## Both languages\n\nTitles, options, notes and list names are machine-translated between English and Chinese. A caller that writes both languages can send them in `i18n`, kept exactly as sent and never machine-translated: `{\"i18n\": {\"title\": {\"en\": \"Desk lamp\", \"zh\": \"台灯\"}}}`. Each item then carries `src` (the language each field is written in), `tr` (the field in the other language) and `supplied` (fields whose `tr` came from the caller).\n\n## Photos\n\nAn item's photo, or a list's cover, is uploaded as the request body itself (`Content-Type: image/jpeg`, `image/png` or `image/gif`), not as a form. JPEG, PNG and GIF only, at most 10 MB and 40 megapixels. The server stores an upright JPEG without metadata and serves it from `/photos/{file}`.\n\n## Errors\n\nEvery error from `/api/…` is JSON: `{\"error\": \"a sentence saying what went wrong\"}`. Request bodies are JSON of at most 256 KB, except photo uploads.\n",
    "version": "1"
  },
  "servers": [{"url":"https://paiban.meerkat.orgabots.com"}],
  "tags": [
    {
      "name": "Lists by link",
      "description": "No passphrase: a list's key in the path decides what's allowed. Create a list, or use the key from a link someone gave you."
    },
    {
      "name": "Passphrase API",
      "description": "Every list, with the creator's rights on each. Needs `Authorization: Bearer <passphrase>`."
    },
    {
      "name": "Pages and files",
      "description": "Pages for people, and the files they load."
    }
  ],
  "paths": {
    "/": {
      "get": {
        "operationId": "homePage",
        "summary": "The home page",
        "tags": [
          "Pages and files"
        ],
        "description": "For people: paste lines to start a list.",
        "security": [],
        "responses": {
          "200": {
            "description": "The page.",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/a/{key}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        }
      ],
      "get": {
        "operationId": "creatorPage",
        "summary": "A list's creator page",
        "tags": [
          "Pages and files"
        ],
        "description": "For people. `{key}` must be the list's creator key; any other key gets the not-found page. Programs use `/api/k/{key}` instead.",
        "security": [],
        "responses": {
          "200": {
            "description": "The list's page.",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "No list has this key as its creator key.",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/l/{key}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        }
      ],
      "get": {
        "operationId": "sharedPage",
        "summary": "A list's shared page",
        "tags": [
          "Pages and files"
        ],
        "description": "For people. `{key}` must be the list's shared key; any other key gets the not-found page. Programs use `/api/k/{key}` instead.",
        "security": [],
        "responses": {
          "200": {
            "description": "The list's page.",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "No list has this key as its shared key.",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v/{key}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        }
      ],
      "get": {
        "operationId": "viewPage",
        "summary": "A list's view-only page",
        "tags": [
          "Pages and files"
        ],
        "description": "For people. `{key}` must be the list's view-only key; any other key gets the not-found page. Programs use `/api/k/{key}` instead.",
        "security": [],
        "responses": {
          "200": {
            "description": "The list's page.",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "No list has this key as its view-only key.",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "operationId": "health",
        "summary": "Health check",
        "tags": [
          "Pages and files"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "`ok`",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "const": "ok"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "openAPI",
        "summary": "This description",
        "tags": [
          "Pages and files"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1, as JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/og.png": {
      "get": {
        "operationId": "previewPicture",
        "summary": "The chat preview picture of lists without photos",
        "tags": [
          "Pages and files"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "A PNG.",
            "content": {
              "image/png": {}
            }
          }
        }
      }
    },
    "/photos/{file}": {
      "parameters": [
        {
          "name": "file",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The file name, `….jpg`."
        }
      ],
      "get": {
        "operationId": "photo",
        "summary": "A photo someone uploaded",
        "tags": [
          "Pages and files"
        ],
        "description": "The address comes from an item's `photo` (or `image`) or a list's `photo`. A replaced or removed photo's address answers `404`.",
        "security": [],
        "responses": {
          "200": {
            "description": "The photo.",
            "content": {
              "image/jpeg": {}
            }
          },
          "404": {
            "description": "No such photo."
          }
        }
      }
    },
    "/api/lists": {
      "post": {
        "operationId": "createList",
        "summary": "Create a list",
        "tags": [
          "Lists by link"
        ],
        "description": "Anyone can create a list; no passphrase. The answer is the creator's view: `ownerUrl` is the creator link (keep it, it's the only way to approve), `shareUrl` the link for people buying with you, `viewUrl` the read-only link. The key for `/api/k/{key}` is the last path segment of a link. No body, or `{}`, makes an empty list. The list gets a random two-word name.",
        "security": [],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TextBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new list, as its creator key sees it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/api/k/{key}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        }
      ],
      "get": {
        "operationId": "getListByKey",
        "summary": "Read a list",
        "tags": [
          "Lists by link"
        ],
        "description": "Any key.",
        "security": [],
        "responses": {
          "200": {
            "description": "The list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListView"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "renameListByKey",
        "summary": "Rename a list",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator key only.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Rename"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The list, renamed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/k/{key}/photo": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        }
      ],
      "post": {
        "operationId": "setCoverByKey",
        "summary": "Set the list's cover photo",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator key only. Kept at up to 1600 px on its longest side; replaces any cover before it.",
        "security": [],
        "requestBody": {
          "required": true,
          "description": "The picture itself as the body, not a form upload: JPEG, PNG or GIF (its first frame), at most 10 MB and 40 megapixels.",
          "content": {
            "image/jpeg": {},
            "image/png": {},
            "image/gif": {}
          }
        },
        "responses": {
          "200": {
            "description": "The list, with `photo`, `photoW` and `photoH`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/PhotoTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/PhotoType"
          }
        }
      },
      "delete": {
        "operationId": "removeCoverByKey",
        "summary": "Remove the list's cover photo",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator key only. `200` also when it had none.",
        "security": [],
        "responses": {
          "200": {
            "description": "The list, without a cover.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListView"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/k/{key}/items": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        }
      ],
      "post": {
        "operationId": "addItemsByKey",
        "summary": "Add items",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator or shared key.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TextBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The list, with the new items at the end.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/k/{key}/items/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        },
        {
          "$ref": "#/components/parameters/ItemKeyed"
        }
      ],
      "patch": {
        "operationId": "changeItemByKey",
        "summary": "Change an item",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator key: anything. Shared key: `note`, `bought`, and a `link` for an item without one, on any item; everything else except `approved` only while the item isn't approved. View-only key: nothing.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Change"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The item.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "operationId": "removeItemByKey",
        "summary": "Remove an item",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator key, or shared key while the item isn't approved. Its photo is deleted.",
        "security": [],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OK"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/k/{key}/items/{id}/photo": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        },
        {
          "$ref": "#/components/parameters/ItemKeyed"
        }
      ],
      "post": {
        "operationId": "setItemPhotoByKey",
        "summary": "Give an item a photo",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator key; shared key for an item with no picture at all, or to replace a picture while the item isn't approved. Kept at up to 1200 px; shown instead of the looked-up picture.",
        "security": [],
        "requestBody": {
          "required": true,
          "description": "The picture itself as the body, not a form upload: JPEG, PNG or GIF (its first frame), at most 10 MB and 40 megapixels.",
          "content": {
            "image/jpeg": {},
            "image/png": {},
            "image/gif": {}
          }
        },
        "responses": {
          "200": {
            "description": "The item, with `photo` and `image` set to the new photo.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/PhotoTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/PhotoType"
          }
        }
      },
      "delete": {
        "operationId": "removeItemPhotoByKey",
        "summary": "Remove an item's photo",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator key, or shared key while the item isn't approved. `200` also when it had none.",
        "security": [],
        "responses": {
          "200": {
            "description": "The item, back to its looked-up picture if it has one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/k/{key}/items/{id}/found": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        },
        {
          "$ref": "#/components/parameters/ItemKeyed"
        }
      ],
      "post": {
        "operationId": "reportFoundByKey",
        "summary": "Report a listing's page read by a browser",
        "tags": [
          "Lists by link"
        ],
        "description": "Used by the page: when the server's lookup of a Taobao or JD item found no picture, a visitor's browser fetches the listing's page itself and sends the part the lookup reads. Any key. The server uses it only if it describes the item's own listing, and only to fill what's missing. At most 30 reports a minute per list.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Found"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The item, filled in.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "204": {
            "description": "The item already has a picture; nothing to do."
          },
          "409": {
            "description": "The server's own lookup of this item is still running.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The snippet is over 64 KB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The snippet isn't this listing's page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over 30 reports a minute for this list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/k/{key}/approve-all": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        }
      ],
      "post": {
        "operationId": "approveAllByKey",
        "summary": "Approve or disapprove every item",
        "tags": [
          "Lists by link"
        ],
        "description": "Creator key only.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApproveAll"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "How many items changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Changed"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/k/{key}/events": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Key"
        }
      ],
      "get": {
        "operationId": "listEventsByKey",
        "summary": "Follow changes to a list",
        "tags": [
          "Lists by link"
        ],
        "description": "Server-sent events, any key: `event: change` on every change to the list (then read it again), `event: ping` every 25 seconds.",
        "security": [],
        "responses": {
          "200": {
            "description": "An open event stream.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/lists": {
      "get": {
        "operationId": "listLists",
        "summary": "All lists, with totals",
        "tags": [
          "Passphrase API"
        ],
        "security": [
          {
            "passphrase": []
          }
        ],
        "responses": {
          "200": {
            "description": "Every list without its `items`, most recently updated first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/APIList"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      },
      "post": {
        "operationId": "createListV1",
        "summary": "Create a list",
        "tags": [
          "Passphrase API"
        ],
        "description": "No body, or `{}`, makes an empty list.",
        "security": [
          {
            "passphrase": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TextBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      }
    },
    "/api/v1/lists/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ListID"
        }
      ],
      "get": {
        "operationId": "getList",
        "summary": "Read a list",
        "tags": [
          "Passphrase API"
        ],
        "security": [
          {
            "passphrase": []
          }
        ],
        "responses": {
          "200": {
            "description": "The list, with its items.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      },
      "patch": {
        "operationId": "renameList",
        "summary": "Rename a list",
        "tags": [
          "Passphrase API"
        ],
        "security": [
          {
            "passphrase": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Rename"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The list, renamed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      },
      "delete": {
        "operationId": "deleteList",
        "summary": "Delete a list",
        "tags": [
          "Passphrase API"
        ],
        "description": "Its three links stop working and its photos are deleted. This can't be undone.",
        "security": [
          {
            "passphrase": []
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OK"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      }
    },
    "/api/v1/lists/{id}/photo": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ListID"
        }
      ],
      "post": {
        "operationId": "setCover",
        "summary": "Set the list's cover photo",
        "tags": [
          "Passphrase API"
        ],
        "description": "Kept at up to 1600 px on its longest side; replaces any cover before it.",
        "security": [
          {
            "passphrase": []
          }
        ],
        "requestBody": {
          "required": true,
          "description": "The picture itself as the body, not a form upload: JPEG, PNG or GIF (its first frame), at most 10 MB and 40 megapixels.",
          "content": {
            "image/jpeg": {},
            "image/png": {},
            "image/gif": {}
          }
        },
        "responses": {
          "200": {
            "description": "The list, with `photo`, `photoW` and `photoH`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/PhotoTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/PhotoType"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      },
      "delete": {
        "operationId": "removeCover",
        "summary": "Remove the list's cover photo",
        "tags": [
          "Passphrase API"
        ],
        "description": "`200` also when it had none.",
        "security": [
          {
            "passphrase": []
          }
        ],
        "responses": {
          "200": {
            "description": "The list, without a cover.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      }
    },
    "/api/v1/lists/{id}/items": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ListID"
        }
      ],
      "post": {
        "operationId": "addItems",
        "summary": "Add items",
        "tags": [
          "Passphrase API"
        ],
        "security": [
          {
            "passphrase": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TextBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The list, with the new items at the end.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      }
    },
    "/api/v1/lists/{id}/items/{itemId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ListID"
        },
        {
          "$ref": "#/components/parameters/ItemID"
        }
      ],
      "patch": {
        "operationId": "changeItem",
        "summary": "Change an item",
        "tags": [
          "Passphrase API"
        ],
        "security": [
          {
            "passphrase": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Change"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The item.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      },
      "delete": {
        "operationId": "removeItem",
        "summary": "Remove an item",
        "tags": [
          "Passphrase API"
        ],
        "description": "Its photo is deleted.",
        "security": [
          {
            "passphrase": []
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OK"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      }
    },
    "/api/v1/lists/{id}/items/{itemId}/photo": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ListID"
        },
        {
          "$ref": "#/components/parameters/ItemID"
        }
      ],
      "post": {
        "operationId": "setItemPhoto",
        "summary": "Give an item a photo",
        "tags": [
          "Passphrase API"
        ],
        "description": "Kept at up to 1200 px; shown instead of the looked-up picture.",
        "security": [
          {
            "passphrase": []
          }
        ],
        "requestBody": {
          "required": true,
          "description": "The picture itself as the body, not a form upload: JPEG, PNG or GIF (its first frame), at most 10 MB and 40 megapixels.",
          "content": {
            "image/jpeg": {},
            "image/png": {},
            "image/gif": {}
          }
        },
        "responses": {
          "200": {
            "description": "The item, with `photo` and `image` set to the new photo.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/PhotoTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/PhotoType"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      },
      "delete": {
        "operationId": "removeItemPhoto",
        "summary": "Remove an item's photo",
        "tags": [
          "Passphrase API"
        ],
        "description": "`200` also when it had none.",
        "security": [
          {
            "passphrase": []
          }
        ],
        "responses": {
          "200": {
            "description": "The item, back to its looked-up picture if it has one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      }
    },
    "/api/v1/lists/{id}/approve-all": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ListID"
        }
      ],
      "post": {
        "operationId": "approveAll",
        "summary": "Approve or disapprove every item",
        "tags": [
          "Passphrase API"
        ],
        "security": [
          {
            "passphrase": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApproveAll"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "How many items changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Changed"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyAttempts"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "passphrase": {
        "type": "http",
        "scheme": "bearer",
        "description": "A passphrase, sent as `Authorization: Bearer <passphrase>`. The site's operator gives it out."
      }
    },
    "parameters": {
      "Key": {
        "name": "key",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "A list's link key: the last path segment of its creator (`/a/…`), shared (`/l/…`) or view-only (`/v/…`) link. What the request may do depends on which one it is."
      },
      "ItemKeyed": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "The item's `id`."
      },
      "ListID": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "The list's `id` (from `GET /api/v1/lists`)."
      },
      "ItemID": {
        "name": "itemId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "The item's `id`."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "What went wrong, in a sentence."
          }
        }
      },
      "LangPair": {
        "type": "object",
        "properties": {
          "en": {
            "type": "string"
          },
          "zh": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "description": "The text in English and/or Chinese. With both, Chinese becomes the field's text and English its `tr`, exactly as sent. With one, that text is the field's text and is machine-translated as usual. An empty string clears the field."
      },
      "I18n": {
        "type": "object",
        "description": "An item's title, option and note in both languages. Describes one item: with `text`, the text must be exactly one item (otherwise `400`). Wins over the plain `title`, `option` or `note`. Only these fields and the languages `en` and `zh` are accepted (otherwise `400`).",
        "properties": {
          "title": {
            "$ref": "#/components/schemas/LangPair"
          },
          "option": {
            "$ref": "#/components/schemas/LangPair"
          },
          "note": {
            "$ref": "#/components/schemas/LangPair"
          }
        },
        "additionalProperties": false,
        "examples": [
          {
            "title": {
              "en": "Aluminium rear footrests",
              "zh": "铝合金后脚蹬"
            },
            "option": {
              "en": "Black, left + right",
              "zh": "黑色 左右一对"
            }
          }
        ]
      },
      "TextBody": {
        "type": "object",
        "description": "What to add: pasted `text` (one item per line), or one described item as `title`, and/or one item's fields in both languages as `i18n`. If both `text` and `title` are sent, `title` is used.",
        "properties": {
          "text": {
            "type": "string",
            "description": "Pasted lines, one item per line: links, share texts, or plain lines like `护眼台灯 ¥89`. At most 200 items are read."
          },
          "title": {
            "type": "string",
            "description": "One item, taken exactly as written: no link or price is picked out of it."
          },
          "i18n": {
            "$ref": "#/components/schemas/I18n"
          }
        },
        "additionalProperties": false,
        "examples": [
          {
            "text": "护眼台灯 ¥89\nhttps://item.taobao.com/item.htm?id=652846283415"
          },
          {
            "title": "A desk lamp, warm light"
          }
        ]
      },
      "Rename": {
        "type": "object",
        "description": "The new name as written (machine-translated), or in both languages as `i18n.name`. Whitespace is collapsed and the name cut to 80 characters; an empty name is refused with `400`.",
        "properties": {
          "name": {
            "type": "string"
          },
          "i18n": {
            "type": "object",
            "properties": {
              "name": {
                "$ref": "#/components/schemas/LangPair"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false,
        "examples": [
          {
            "name": "搬家要买的"
          },
          {
            "i18n": {
              "name": {
                "en": "Moving house",
                "zh": "搬家"
              }
            }
          }
        ]
      },
      "Change": {
        "type": "object",
        "description": "A partial change to an item: send only the fields to change.",
        "properties": {
          "title": {
            "type": "string"
          },
          "option": {
            "type": "string",
            "description": "Colour, size and so on."
          },
          "price": {
            "type": "number",
            "minimum": 0,
            "maximum": 10000000,
            "description": "Per unit, in yuan; rounded to the fen."
          },
          "noPrice": {
            "type": "boolean",
            "description": "`true` clears the price (wins over `price`)."
          },
          "qty": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9999
          },
          "note": {
            "type": "string"
          },
          "bought": {
            "type": "boolean"
          },
          "approved": {
            "type": "boolean",
            "description": "Creator key and passphrase API only."
          },
          "link": {
            "type": "string",
            "description": "A link, or a whole pasted share text, to give the item a link or replace it. The first line with a link is used. The same link as the item's changes nothing; a new one brings the new listing's picture, title and price (looked up, `\"status\": \"fetching\"`), while fields sent in the same request win. Text with no link in it is refused with `400`."
          },
          "i18n": {
            "$ref": "#/components/schemas/I18n"
          }
        },
        "additionalProperties": false,
        "examples": [
          {
            "option": "蓝色 350ml",
            "price": 39.9,
            "qty": 2,
            "approved": true
          }
        ]
      },
      "Item": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "title",
          "option",
          "price",
          "qty",
          "note",
          "status",
          "approved",
          "bought",
          "addedBy",
          "created"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "taobao",
              "xianyu",
              "link",
              "text"
            ],
            "description": "`taobao` (Taobao and Tmall), `xianyu` (闲鱼, second-hand), `link` (any other shop) or `text` (no link)."
          },
          "url": {
            "type": "string",
            "description": "The link as pasted; omitted for text items."
          },
          "itemId": {
            "type": "string",
            "description": "Taobao or Xianyu listing id, when known."
          },
          "skuId": {
            "type": "string",
            "description": "Taobao option id, when the link carries one."
          },
          "title": {
            "type": "string"
          },
          "option": {
            "type": "string"
          },
          "price": {
            "type": [
              "number",
              "null"
            ],
            "description": "Per unit, in yuan; `null` when unknown."
          },
          "priceBy": {
            "type": "string",
            "enum": [
              "lookup",
              "paste",
              "person"
            ],
            "description": "Where the price came from."
          },
          "priceHint": {
            "type": "string",
            "description": "A Taobao listing's price range when its options cost different amounts, e.g. `¥39.00-59.00`."
          },
          "qty": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9999
          },
          "note": {
            "type": "string"
          },
          "image": {
            "type": "string",
            "description": "The picture to show: `photo` if there is one, otherwise the one looked up."
          },
          "photo": {
            "type": "string",
            "description": "The photo someone uploaded, as an absolute URL."
          },
          "status": {
            "type": "string",
            "enum": [
              "fetching",
              "ready"
            ],
            "description": "`fetching` while the link is being looked up."
          },
          "staleTitle": {
            "type": "boolean",
            "description": "After a link change: the title is the old listing's until the new one's arrives."
          },
          "stalePrice": {
            "type": "boolean",
            "description": "After a link change: the price is a typed one waiting for the new listing's."
          },
          "approved": {
            "type": "boolean"
          },
          "bought": {
            "type": "boolean"
          },
          "addedBy": {
            "type": "string",
            "enum": [
              "owner",
              "shared",
              "api"
            ],
            "description": "Who added it: the creator link, the shared link or the passphrase API."
          },
          "created": {
            "type": "integer",
            "description": "Unix seconds."
          },
          "linkAdded": {
            "type": "integer",
            "description": "When an item without a link was given one, Unix seconds."
          },
          "linkAddedBy": {
            "type": "string",
            "enum": [
              "owner",
              "shared",
              "api"
            ]
          },
          "src": {
            "type": "object",
            "description": "For `title`, `option` and `note`: the language each is written in.",
            "additionalProperties": {
              "type": "string",
              "enum": [
                "zh",
                "en"
              ]
            }
          },
          "tr": {
            "type": "object",
            "description": "`title`, `option` and `note` in the other language, where the translation differs.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "supplied": {
            "type": "object",
            "description": "`true` for each field whose `tr` was sent by the caller in `i18n`.",
            "additionalProperties": {
              "type": "boolean"
            }
          }
        }
      },
      "ListView": {
        "type": "object",
        "description": "A list as one of its keys sees it.",
        "required": [
          "role",
          "name",
          "nameSrc",
          "nameTr",
          "viewUrl",
          "items",
          "updated"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "shared",
              "view"
            ],
            "description": "The key's role: `owner` is the creator link."
          },
          "name": {
            "type": "string",
            "description": "The list's name as written."
          },
          "nameSrc": {
            "type": "string",
            "description": "The language `name` is written in, `zh` or `en`; empty until translated."
          },
          "nameTr": {
            "type": "string",
            "description": "The name in the other language; empty until translated, or when it reads the same."
          },
          "photo": {
            "type": "string",
            "description": "The cover photo's URL, if any."
          },
          "photoW": {
            "type": "integer"
          },
          "photoH": {
            "type": "integer"
          },
          "ownerUrl": {
            "type": "string",
            "description": "Creator link; only in the creator key's answers."
          },
          "shareUrl": {
            "type": "string",
            "description": "Shared link; not in the view-only key's answers."
          },
          "viewUrl": {
            "type": "string",
            "description": "View-only link."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Item"
            },
            "description": "In the order added."
          },
          "updated": {
            "type": "integer",
            "description": "Unix seconds."
          }
        }
      },
      "APIList": {
        "type": "object",
        "description": "A list as the passphrase API sees it: all three links, and totals.",
        "required": [
          "id",
          "name",
          "nameSrc",
          "nameTr",
          "ownerUrl",
          "shareUrl",
          "viewUrl",
          "created",
          "updated",
          "total",
          "approved",
          "noPrice"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The list's id in `/api/v1/lists/{id}` paths (not a link key)."
          },
          "name": {
            "type": "string"
          },
          "nameSrc": {
            "type": "string"
          },
          "nameTr": {
            "type": "string"
          },
          "photo": {
            "type": "string"
          },
          "photoW": {
            "type": "integer"
          },
          "photoH": {
            "type": "integer"
          },
          "ownerUrl": {
            "type": "string",
            "description": "Creator link."
          },
          "shareUrl": {
            "type": "string",
            "description": "Shared link."
          },
          "viewUrl": {
            "type": "string",
            "description": "View-only link."
          },
          "created": {
            "type": "integer"
          },
          "updated": {
            "type": "integer"
          },
          "total": {
            "type": "number",
            "description": "Sum of price × quantity over items with a price."
          },
          "approved": {
            "type": "number",
            "description": "The same, approved items only."
          },
          "noPrice": {
            "type": "integer",
            "description": "Items left out of both totals because they have no price."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Item"
            },
            "description": "Omitted in `GET /api/v1/lists`."
          }
        }
      },
      "ApproveAll": {
        "type": "object",
        "required": [
          "approved"
        ],
        "properties": {
          "approved": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "Changed": {
        "type": "object",
        "required": [
          "changed"
        ],
        "properties": {
          "changed": {
            "type": "integer",
            "description": "Items whose state changed."
          }
        }
      },
      "OK": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "const": true
          }
        }
      },
      "Found": {
        "type": "object",
        "required": [
          "source",
          "snippet"
        ],
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "taobao",
              "jd"
            ]
          },
          "snippet": {
            "type": "string",
            "maxLength": 65536,
            "description": "The part of the listing's page the server's own lookup reads."
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The body isn't valid JSON or breaks a rule (a price or quantity out of range, `i18n` with an unknown field, no link in `link`, a list past 500 items…).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "No passphrase, a wrong one, or the passphrase API is turned off on this server.",
        "headers": {
          "WWW-Authenticate": {
            "schema": {
              "type": "string"
            },
            "description": "`Bearer realm=\"paiban\"`"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyAttempts": {
        "description": "Too many wrong passphrases from this address: wait `Retry-After` seconds.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds to wait."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "This key may not do that (see the rights in the description).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "No list has this key or id, or it has no such item.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PhotoTooLarge": {
        "description": "A photo over 10 MB or 40 megapixels.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PhotoType": {
        "description": "A photo that isn't JPEG, PNG or GIF, or sent as a form instead of as the body.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
