{
  "openapi": "3.1.0",
  "info": {
    "title": "Boo Cue API",
    "version": "1",
    "summary": "The three requests the Boo Cue app makes, and nothing else.",
    "description": "Everything the Boo Cue app knows about a film comes from three `GET` requests. Serve\nthese and the app will use your server — set its address in **Settings → Advanced →\nCatalog server**.\n\nThe contract is deliberately small enough to serve from a folder of static files.\nSearch, conditional requests and deltas make a server better, but none of them are\nrequired: an app pointed at a server that ignores every query parameter still works.\n\n**Times** are ISO 8601 instants in UTC, with or without fractional seconds\n(`2026-09-19T12:00:00Z` or `2026-09-19T12:00:00.000Z`).\n\n**The `boocue-app` header** gates `api.boocue.com`. The app sends it only to\n`boocue.com` addresses, so your server never sees it and needs no authentication.\n"
  },
  "tags": [
    {
      "name": "App",
      "description": "Everything the app requests. Implement these to run your own server."
    }
  ],
  "servers": [
    {
      "url": "https://api.boocue.com",
      "description": "The hosted Boo Cue server"
    }
  ],
  "paths": {
    "/v1/movies": {
      "get": {
        "operationId": "getCatalog",
        "tags": [
          "App"
        ],
        "summary": "The catalog — every film the server can supply",
        "description": "Fetched on every launch. The app replaces its whole local catalog with\n`movies` unless the response is a delta (see `updatedAt`).\n\n**Only list a film here once `GET /v1/movies/{movie_id}` and its fingerprint\ndownload both work.** The catalog is what the app offers people; a film listed\nhere that fails to open is a broken promise rather than a missing one.\n\nWith `search`, returns the films matching the term instead. The app only searches\nthe server after finding nothing in its own copy of the catalog, so results it\nalready knows are discarded — a server that ignores `search` and returns the whole\ncatalog simply never finds anything new.\n",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "A title as typed. Match every whitespace-separated token, ignoring case,\ndiacritics and typographic quotes, against \"title year\" — so `conjuring the`\nand `conjuring 2013` both find *The Conjuring (2013)*. Optional to implement.\n",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "example": "the conjuring"
          },
          {
            "name": "updatedAt",
            "in": "query",
            "required": false,
            "description": "Return only films changed strictly after this instant, plus `removed`\ntombstones, and echo it back as `updated_since`. Optional to implement; the\napp itself syncs with `If-None-Match` and never sends this. Not combinable\nwith `search` (400).\n",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "description": "The `ETag` of the catalog the app already holds. Answer `304` if unchanged.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AppHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "The catalog, a delta of it, or search results.",
            "headers": {
              "ETag": {
                "description": "Optional. If sent, the app returns it as `If-None-Match` next launch.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogResponse"
                },
                "examples": {
                  "example": {
                    "summary": "A one-film catalog",
                    "value": {
                      "built_at": "2026-11-01T00:00:00Z",
                      "movies": [
                        {
                          "movie_id": "example_film_2026",
                          "movie_title": "Example Film",
                          "release_year": 2026,
                          "scare_count": 2,
                          "updated_at": "2026-11-01T00:00:00Z"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "The catalog matching `If-None-Match` is still current. No body."
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "description": "The server has no catalog yet. The app reports \"the catalog isn't ready yet\".",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/movies/{movie_id}": {
      "get": {
        "operationId": "getMovie",
        "tags": [
          "App"
        ],
        "summary": "One film — its scares and where to download its fingerprint",
        "description": "Fetched when someone opens a film, and cached on the device afterwards.",
        "parameters": [
          {
            "name": "movie_id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MovieID"
            }
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AppHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "The film.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Movie"
                },
                "examples": {
                  "example": {
                    "summary": "A film with two scares",
                    "value": {
                      "movie_id": "example_film_2026",
                      "movie_title": "Example Film",
                      "release_year": 2026,
                      "runtime_seconds": 5400,
                      "updated_at": "2026-11-01T00:00:00Z",
                      "timings_verified": true,
                      "fingerprints": [
                        {
                          "sha256": "0000000000000000000000000000000000000000000000000000000000000000",
                          "bytes": 1238477,
                          "path": "/v1/catalogs/example_film_2026.shazamcatalog",
                          "audio": {
                            "language": "en"
                          }
                        }
                      ],
                      "scares": [
                        {
                          "id": "scare_001",
                          "timestamp_seconds": 412,
                          "severity": "high",
                          "category": "jump_scare",
                          "description": "Something drops from the ceiling."
                        },
                        {
                          "id": "scare_002",
                          "timestamp_seconds": 2950.5,
                          "severity": "low",
                          "category": "gore",
                          "description": "The kitchen, again."
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Unchanged since the `ETag` the app sent."
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/catalogs/{file}": {
      "get": {
        "operationId": "getFingerprint",
        "tags": [
          "App"
        ],
        "summary": "A fingerprint file",
        "description": "The app does not build this URL: it downloads whatever `fingerprints[].path` says,\nresolved against your server's address. This path is only the hosted server's\nconvention, and any path you choose works.\n\nThe bytes must hash to `fingerprints[].sha256` and should total\n`fingerprints[].bytes`; a mismatch is rejected as an incomplete download. Serve it\nwith a long cache lifetime — a changed fingerprint has a new hash and so a new path.\n",
        "parameters": [
          {
            "name": "file",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "example_film_2026.shazamcatalog"
          },
          {
            "$ref": "#/components/parameters/AppHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "A ShazamKit custom catalog. See the self-hosting guide for how one is made.",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "No such file."
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "AppHeader": {
        "name": "boocue-app",
        "in": "header",
        "required": false,
        "description": "Required by api.boocue.com. The app sends it only to boocue.com hosts, so your server never receives it.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Something the app shows as a failure.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "MovieID": {
        "type": "string",
        "description": "Lowercase letters, digits and underscores, 2–80 characters, starting and ending with\na letter or digit. Conventionally `<title>_<year>`. It is a URL segment, a file\nname and the film's identity on every device that has seen it, so never reuse one\nfor a different film.\n",
        "pattern": "^[a-z0-9][a-z0-9_]{0,78}[a-z0-9]$",
        "example": "example_film_2026"
      },
      "CatalogResponse": {
        "type": "object",
        "required": [
          "built_at",
          "movies"
        ],
        "properties": {
          "built_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the catalog's content last changed."
          },
          "updated_since": {
            "type": "string",
            "format": "date-time",
            "description": "Present only on a delta — the `updatedAt` cursor, echoed back."
          },
          "movies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CatalogEntry"
            }
          },
          "removed": {
            "type": "array",
            "description": "Films deleted since `updated_since`. Only meaningful on a delta; may be omitted otherwise.",
            "items": {
              "$ref": "#/components/schemas/Tombstone"
            }
          },
          "full_replace": {
            "type": "boolean",
            "description": "On a delta request, `true` means \"this is the whole catalog after all — replace, don't merge\"."
          }
        }
      },
      "CatalogEntry": {
        "type": "object",
        "required": [
          "movie_id",
          "movie_title",
          "release_year",
          "scare_count",
          "updated_at"
        ],
        "properties": {
          "movie_id": {
            "$ref": "#/components/schemas/MovieID"
          },
          "movie_title": {
            "type": "string",
            "example": "Example Film"
          },
          "release_year": {
            "type": "integer",
            "example": 2026
          },
          "scare_count": {
            "type": "integer",
            "minimum": 0,
            "description": "Shown in the film's row before it is opened."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When this film's document last changed. Move it whenever the scares or\nfingerprints do — the app re-fetches a film it has cached when this is newer.\n"
          }
        }
      },
      "Tombstone": {
        "type": "object",
        "required": [
          "movie_id",
          "removed_at"
        ],
        "properties": {
          "movie_id": {
            "$ref": "#/components/schemas/MovieID"
          },
          "removed_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Movie": {
        "type": "object",
        "required": [
          "movie_id",
          "movie_title",
          "release_year",
          "fingerprints",
          "scares"
        ],
        "properties": {
          "movie_id": {
            "$ref": "#/components/schemas/MovieID"
          },
          "movie_title": {
            "type": "string"
          },
          "release_year": {
            "type": "integer"
          },
          "runtime_seconds": {
            "type": "number",
            "description": "Length of the fingerprinted audio. Draws the timeline; without it the timeline is estimated."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "timings_verified": {
            "type": "boolean",
            "default": true,
            "description": "`false` when the scare times were not measured against the same audio the\nfingerprint was made from. The app says so on screen rather than implying\nprecision it does not have.\n"
          },
          "timing_source": {
            "type": "string",
            "description": "Free text recording where the timings came from. Not shown."
          },
          "fingerprints": {
            "type": "array",
            "minItems": 1,
            "description": "One per audio track. The app picks the device's language, then English, then\nthe first entry. A French fingerprint never matches an English screening.\n",
            "items": {
              "$ref": "#/components/schemas/Fingerprint"
            }
          },
          "scares": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Scare"
            }
          }
        }
      },
      "Fingerprint": {
        "type": "object",
        "required": [
          "sha256",
          "bytes",
          "path"
        ],
        "properties": {
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "SHA-256 of the file, lowercase hex. Checked after download."
          },
          "bytes": {
            "type": "integer",
            "minimum": 1,
            "description": "File size. Drives the download progress bar."
          },
          "path": {
            "type": "string",
            "description": "Where to download it — an absolute path on your server, or a full URL."
          },
          "audio": {
            "type": "object",
            "description": "Which audio track this was made from. All fields optional.",
            "properties": {
              "language": {
                "type": "string",
                "description": "ISO 639 code, e.g. `en`."
              },
              "channels": {
                "type": "string",
                "example": "5.1"
              },
              "title": {
                "type": "string",
                "example": "Original Theatrical"
              }
            }
          }
        }
      },
      "Scare": {
        "type": "object",
        "required": [
          "id",
          "timestamp_seconds"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique within the film."
          },
          "timestamp_seconds": {
            "type": "number",
            "minimum": 0,
            "description": "Seconds from the start of the audio the fingerprint was made from — not from\nthe start of some other release of the film. Get this wrong and every warning\nis early or late by the difference.\n"
          },
          "severity": {
            "type": "string",
            "enum": [
              "low",
              "high"
            ],
            "default": "low",
            "description": "High is underlined on screen. api.boocue.com always sends it, since it is a\nhuman judgment; any value other than these two fails the whole film.\n"
          },
          "category": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,31}$",
            "default": "jump_scare",
            "description": "`jump_scare`, `gore`, `other`, or any new lowercase identifier — the app warns\nfor categories it has never heard of. Jump scares are shown in red, everything\nelse in purple.\n"
          },
          "description": {
            "type": "string",
            "default": "",
            "description": "Shown with the warning when the viewer allows spoilers."
          },
          "loudness_lu": {
            "type": "number",
            "description": "Measured loudness jump, in LU. Informational."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}