{
  "openapi": "3.1.0",
  "info": {
    "title": "The Books API",
    "version": "1.0.0",
    "summary": "Book metadata and ISBN lookups, with covers.",
    "description": "The public REST API of The Books API: search the catalogue, fetch an edition by ISBN, look up many ISBNs at once, follow an on-demand ISBN lookup, report a catalogue error and load cover images.\n\nEvery `/v1` route except `/v1/covers` needs an API key, sent as `X-API-Key: <key>` or `Authorization: Bearer <key>`. Keys are created from your account at https://thebooksapi.com/account/. Errors share one body, `{\"error\": \"<code>\", \"message\": \"<text>\"}`, where `error` is one of `invalid_request`, `invalid_api_key`, `payment_required`, `not_found`, `rate_limited` or `service_unavailable`.\n\nLimits per key are reported on every keyed response in the `RateLimit-*` (and legacy `X-RateLimit-*`) headers, with daily and monthly remaining quota in `X-Quota-Daily-Remaining` and `X-Quota-Monthly-Remaining`.\n\nThe per-second limit counts calls. The daily and monthly quotas count records: a book lookup is one, a batch is one per ISBN sent (refused with 429 when the key has fewer left), and a search is one per result returned, at least one per call. Cover images are free.",
    "termsOfService": "https://thebooksapi.com/terms/",
    "contact": {
      "name": "The Books API",
      "url": "https://thebooksapi.com/contact/"
    },
    "license": {
      "name": "Record data: see the data licences page",
      "url": "https://thebooksapi.com/data-licences/"
    }
  },
  "externalDocs": {
    "description": "API reference",
    "url": "https://thebooksapi.com/docs/"
  },
  "servers": [
    {
      "url": "https://api.thebooksapi.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Search",
      "description": "Full-text and ISBN search over the catalogue."
    },
    {
      "name": "Books",
      "description": "Editions by ISBN, one at a time or in batches."
    },
    {
      "name": "Lookups",
      "description": "On-demand ISBN lookups started by a 202 response."
    },
    {
      "name": "Reports",
      "description": "Corrections and removal requests for a catalogue record."
    },
    {
      "name": "Covers",
      "description": "Cover images. No API key needed."
    },
    {
      "name": "Reserved",
      "description": "Registered routes that answer with a placeholder today."
    }
  ],
  "paths": {
    "/v1/search": {
      "get": {
        "operationId": "search",
        "tags": [
          "Search"
        ],
        "summary": "Search the catalogue",
        "description": "Searches titles, authors, publishers and ISBNs. An ISBN query with no hits may carry an `isbn_lookup` document describing an on-demand lookup.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Free-text query or an ISBN-10/13.",
            "schema": {
              "type": "string"
            },
            "example": "fría hortensia"
          },
          {
            "name": "title",
            "in": "query",
            "description": "Restrict to a title.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "author",
            "in": "query",
            "description": "Restrict to an author name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "description": "MARC 21 language code of the edition, e.g. `spa`, `eng`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "publisher",
            "in": "query",
            "description": "Restrict to a publisher name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "has_cover",
            "in": "query",
            "description": "Only editions with a cover.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "include_no_isbn",
            "in": "query",
            "description": "Also return editions without an ISBN (their id is `bk_…`).",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "match",
            "in": "query",
            "description": "`fuzzy` (default) or `exact`.",
            "schema": {
              "type": "string",
              "enum": [
                "fuzzy",
                "exact"
              ]
            }
          },
          {
            "name": "accents",
            "in": "query",
            "description": "Accent handling: `ignore` (default) or `strict`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Order of the results. `relevance` (default, also when absent) is the ranked order. `date_desc` puts the most recent editions first and `date_asc` the oldest first, by publication year and then full publication date; editions without a known date come last in both. Same matched set and `total` as relevance, which breaks ties. Any other value is a 400 `invalid_request`.",
            "schema": {
              "type": "string",
              "enum": [
                "relevance",
                "date_desc",
                "date_asc"
              ],
              "default": "relevance"
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/offset"
          },
          {
            "$ref": "#/components/parameters/locale"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of results.",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                },
                "example": {
                  "results": [
                    {
                      "id": "9788420634487",
                      "has_isbn": true,
                      "isbn13": "9788420634487",
                      "title": "Fría Hortensia y otros cuentos",
                      "subtitle": null,
                      "authors": [
                        "X.L. Méndez Ferrín"
                      ],
                      "publisher": "Alianza Editorial",
                      "publication_year": 1999,
                      "language": "spa",
                      "cover_url": "https://api.thebooksapi.com/v1/covers/8231856-M.jpg",
                      "license_notice": "Portions licensed under CC BY 4.0 – see https://thebooksapi.com/data-licences/",
                      "position": 1,
                      "popularity": 97,
                      "searchability": 14
                    }
                  ],
                  "total": 37,
                  "search_id": "9f14c0a3b7d24e6f",
                  "total_is_approximate": true,
                  "page": 1,
                  "limit": 1,
                  "offset": 0,
                  "query": "fría hortensia",
                  "query_type": "text",
                  "match": "fuzzy",
                  "include_no_isbn": false,
                  "sort": "relevance"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/books/{isbn}": {
      "get": {
        "operationId": "getBook",
        "tags": [
          "Books"
        ],
        "summary": "Get an edition by ISBN",
        "description": "Returns one edition by ISBN-10 or ISBN-13 (or its `bk_…` id with `include_no_isbn=true`). When the ISBN is not in the catalogue yet and an on-demand lookup starts, the answer is `202` with a lookup document to poll on `GET /v1/lookups/{id}`.",
        "parameters": [
          {
            "name": "isbn",
            "in": "path",
            "required": true,
            "description": "ISBN-10 or ISBN-13, hyphens allowed.",
            "schema": {
              "type": "string"
            },
            "example": "9788420634487"
          },
          {
            "name": "search_id",
            "in": "query",
            "description": "The `search_id` of the search this edition was picked from, so the click counts towards ranking.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_no_isbn",
            "in": "query",
            "description": "Accept a `bk_…` id for an edition without an ISBN.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "$ref": "#/components/parameters/locale"
          }
        ],
        "responses": {
          "200": {
            "description": "The edition.",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Edition"
                },
                "example": {
                  "id": "9788420634487",
                  "has_isbn": true,
                  "isbn13": "9788420634487",
                  "isbn10": "8420634484",
                  "work_id": "01a1651b-caea-711b-b361-a9916b294a59",
                  "title": "Fría Hortensia y otros cuentos",
                  "subtitle": null,
                  "language": "spa",
                  "publication_year": 1999,
                  "pages": 263,
                  "created_at": "2026-09-12T08:41:03.117Z",
                  "updated_at": "2026-10-24T19:05:44.802Z",
                  "contributors": [
                    {
                      "id": "01a164fa-c55e-7192-80f1-5c690b6cfd62",
                      "name": "X.L. Méndez Ferrín",
                      "role": "author",
                      "position": 1
                    }
                  ],
                  "cover_urls": {
                    "small": "https://api.thebooksapi.com/v1/covers/8231856-S.jpg",
                    "medium": "https://api.thebooksapi.com/v1/covers/8231856-M.jpg",
                    "large": "https://api.thebooksapi.com/v1/covers/8231856-L.jpg"
                  },
                  "license": {
                    "data": "CC-BY-4.0",
                    "attribution_required": true
                  },
                  "license_notice": "Portions licensed under CC BY 4.0 – see https://thebooksapi.com/data-licences/",
                  "ratings": {
                    "count": 1842,
                    "average": 4.1,
                    "bayesian": 4.07,
                    "distribution": [
                      31,
                      74,
                      322,
                      611,
                      804
                    ]
                  },
                  "reading": {
                    "want_to_read": 903,
                    "currently_reading": 41,
                    "already_read": 268
                  },
                  "popularity": 97,
                  "searchability": 14
                }
              }
            }
          },
          "202": {
            "$ref": "#/components/responses/LookupAccepted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/books/batch": {
      "post": {
        "operationId": "getBooksBatch",
        "tags": [
          "Books"
        ],
        "summary": "Get up to 100 editions by ISBN",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchRequest"
              },
              "example": {
                "isbns": [
                  "9788420634487",
                  "9788411328241",
                  "9780000000000"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One entry per requested ISBN: an edition, a lookup document, or an error entry.",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResponse"
                },
                "example": {
                  "results": {
                    "9788420634487": {
                      "id": "880e8400-e29b-41d4-a716-446655440001",
                      "isbn13": "9788420634487",
                      "title": "Fría Hortensia y otros cuentos",
                      "language": "spa"
                    },
                    "9788411328241": {
                      "status": "processing",
                      "lookup_id": "lu_7Hq2mXa9KpR4",
                      "isbn13": "9788411328241",
                      "retry_after": 5,
                      "partial": null
                    },
                    "9780000000000": {
                      "error": "not_found",
                      "message": "This book is not in our database yet. We've queued it for enrichment. Please try again later."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/lookups/{id}": {
      "get": {
        "operationId": "getLookup",
        "tags": [
          "Lookups"
        ],
        "summary": "Poll an ISBN lookup",
        "description": "`202` while the lookup runs (with `Retry-After`); `200` once it has an answer: `found` with the edition, or `not_found`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The `lookup_id` from a 202 response.",
            "schema": {
              "type": "string",
              "pattern": "^lu_[A-Za-z0-9]+$"
            },
            "example": "lu_7Hq2mXa9KpR4"
          }
        ],
        "responses": {
          "200": {
            "description": "The lookup has an answer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lookup"
                },
                "example": {
                  "status": "found",
                  "lookup_id": "lu_7Hq2mXa9KpR4",
                  "isbn13": "9788411328241",
                  "edition": {
                    "id": "9788420634487",
                    "has_isbn": true,
                    "isbn13": "9788420634487",
                    "isbn10": "8420634484",
                    "work_id": "01a1651b-caea-711b-b361-a9916b294a59",
                    "title": "Fría Hortensia y otros cuentos",
                    "subtitle": null,
                    "language": "spa",
                    "publication_year": 1999,
                    "pages": 263,
                    "created_at": "2026-09-12T08:41:03.117Z",
                    "updated_at": "2026-10-24T19:05:44.802Z",
                    "contributors": [
                      {
                        "id": "01a164fa-c55e-7192-80f1-5c690b6cfd62",
                        "name": "X.L. Méndez Ferrín",
                        "role": "author",
                        "position": 1
                      }
                    ],
                    "cover_urls": {
                      "small": "https://api.thebooksapi.com/v1/covers/8231856-S.jpg",
                      "medium": "https://api.thebooksapi.com/v1/covers/8231856-M.jpg",
                      "large": "https://api.thebooksapi.com/v1/covers/8231856-L.jpg"
                    },
                    "license": {
                      "data": "CC-BY-4.0",
                      "attribution_required": true
                    },
                    "license_notice": "Portions licensed under CC BY 4.0 – see https://thebooksapi.com/data-licences/",
                    "ratings": {
                      "count": 1842,
                      "average": 4.1,
                      "bayesian": 4.07,
                      "distribution": [
                        31,
                        74,
                        322,
                        611,
                        804
                      ]
                    },
                    "reading": {
                      "want_to_read": 903,
                      "currently_reading": 41,
                      "already_read": 268
                    },
                    "popularity": 97,
                    "searchability": 14
                  }
                }
              }
            }
          },
          "202": {
            "$ref": "#/components/responses/LookupAccepted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/reports": {
      "post": {
        "operationId": "createReport",
        "tags": [
          "Reports"
        ],
        "summary": "Report an error or request a removal",
        "description": "Stores a report in the review queue. The reporter confirms it from an email; confirmed reports are reviewed within 48 hours.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportRequest"
              },
              "example": {
                "type": "error",
                "isbn": "9788420634487",
                "details": "The page count is 263 on this printing, not 236.",
                "email": "you@example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Report received.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportReceipt"
                },
                "example": {
                  "message": "Report received. Confirm it from the email we sent; confirmed reports are reviewed within 48 hours.",
                  "reference": "REQ-7KQ2M9XA4T",
                  "status": "unconfirmed"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/covers/{file}": {
      "get": {
        "operationId": "getCover",
        "tags": [
          "Covers"
        ],
        "summary": "Get a cover image",
        "security": [],
        "description": "Cover images, public and cacheable. Forms: `{cover_id}-{S|M|L|O}.jpg` (the `cover_urls` of a record), `edition/{edition_id}-{S|M|L|O}.jpg`, `c/{cover_candidate_id}-{S|M|L}.jpg`, and `{isbn}`. `O` is the original scan where one exists, otherwise the same as `L`. A missing cover is a neutral placeholder with status 200 unless `default=false`, which answers 404. The `file` value may contain `/`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/coverFile"
          },
          {
            "name": "default",
            "in": "query",
            "description": "`false` answers 404 instead of the placeholder image.",
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The image.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "example": "public, max-age=31536000, immutable"
              },
              "ETag": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/jpeg"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/webp"
                }
              },
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "302": {
            "description": "Short-lived redirect to the stored object (only when the server runs in redirect mode)."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      },
      "head": {
        "operationId": "headCover",
        "tags": [
          "Covers"
        ],
        "summary": "Check a cover image",
        "security": [],
        "description": "Same status and headers as GET, no body.",
        "parameters": [
          {
            "$ref": "#/components/parameters/coverFile"
          },
          {
            "name": "default",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The image exists (or the placeholder would be served)."
          },
          "404": {
            "description": "No cover and `default=false`."
          },
          "429": {
            "description": "Too many requests from this address."
          }
        }
      }
    },
    "/v1/works/{id}": {
      "get": {
        "operationId": "getWork",
        "tags": [
          "Reserved"
        ],
        "summary": "Work (reserved)",
        "description": "Reserved route. It is registered and authenticated like every /v1 route, but today it answers with a placeholder document rather than catalogue data. Do not build on it yet.",
        "x-reserved": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Work id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Placeholder document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "example": {
                  "work_id": "01a1651b-caea-711b-b361-a9916b294a59",
                  "message": "Work details endpoint"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/works/{id}/editions": {
      "get": {
        "operationId": "getWorkEditions",
        "tags": [
          "Reserved"
        ],
        "summary": "Editions of a work (reserved)",
        "description": "Reserved route. It is registered and authenticated like every /v1 route, but today it answers with a placeholder document rather than catalogue data. Do not build on it yet.",
        "x-reserved": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Work id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Placeholder document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "example": {
                  "work_id": "01a1651b-caea-711b-b361-a9916b294a59",
                  "editions": [],
                  "message": "Work editions endpoint"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/authors/{id}": {
      "get": {
        "operationId": "getAuthor",
        "tags": [
          "Reserved"
        ],
        "summary": "Author (reserved)",
        "description": "Reserved route. It is registered and authenticated like every /v1 route, but today it answers with a placeholder document rather than catalogue data. Do not build on it yet.",
        "x-reserved": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Author id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Placeholder document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "example": {
                  "author_id": "01a164fa-c55e-7192-80f1-5c690b6cfd62",
                  "message": "Author details endpoint"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/authors/{id}/works": {
      "get": {
        "operationId": "getAuthorWorks",
        "tags": [
          "Reserved"
        ],
        "summary": "Works of an author (reserved)",
        "description": "Reserved route. It is registered and authenticated like every /v1 route, but today it answers with a placeholder document rather than catalogue data. Do not build on it yet.",
        "x-reserved": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Author id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Placeholder document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "example": {
                  "author_id": "01a164fa-c55e-7192-80f1-5c690b6cfd62",
                  "works": [],
                  "message": "Author works endpoint"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/publishers/{id}": {
      "get": {
        "operationId": "getPublisher",
        "tags": [
          "Reserved"
        ],
        "summary": "Publisher (reserved)",
        "description": "Reserved route. It is registered and authenticated like every /v1 route, but today it answers with a placeholder document rather than catalogue data. Do not build on it yet.",
        "x-reserved": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Publisher id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Placeholder document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "example": {
                  "publisher_id": "pub_1",
                  "message": "Publisher details endpoint"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Your API key."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "The same API key as a bearer token."
      }
    },
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "description": "Results per page. The maximum depends on the plan.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 20
        }
      },
      "offset": {
        "name": "offset",
        "in": "query",
        "description": "Results to skip.",
        "schema": {
          "type": "integer",
          "minimum": 0,
          "default": 0
        }
      },
      "locale": {
        "name": "locale",
        "in": "query",
        "description": "Reader language for popularity signals: en, es, fr, pt, ja, zh or ar.",
        "schema": {
          "type": "string"
        }
      },
      "coverFile": {
        "name": "file",
        "in": "path",
        "required": true,
        "description": "Cover file, e.g. `8231856-M.jpg`, `edition/{edition_id}-L.jpg` or an ISBN.",
        "schema": {
          "type": "string"
        },
        "example": "8231856-M.jpg"
      }
    },
    "headers": {
      "RateLimitLimit": {
        "description": "Requests allowed in the current window.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimitRemaining": {
        "description": "Requests left in the current window.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimitReset": {
        "description": "Seconds until the window resets.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimitPolicy": {
        "description": "Per-second, daily and monthly limits of the key.",
        "schema": {
          "type": "string"
        },
        "example": "10;w=1, 5000;w=86400, 100000;w=2592000"
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request is not valid: check the parameters.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "invalid_request",
              "message": "The request is not valid: check the parameters."
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Send your API key in the X-API-Key header or as an Authorization: Bearer token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "invalid_api_key",
              "message": "Send your API key in the X-API-Key header or as an Authorization: Bearer token."
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "Your subscription is not active. Update billing at https://thebooksapi.com/account to restore access.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "payment_required",
              "message": "Your subscription is not active. Update billing at https://thebooksapi.com/account to restore access."
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found. With the on-demand review queue on, a miss waiting for review also carries `status: pending_review` and `isbn13`; no lookup is running and none is promised.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "not_found": {
                "summary": "Not in the catalogue",
                "value": {
                  "error": "not_found",
                  "message": "This book is not in our database yet."
                }
              },
              "pending_review": {
                "summary": "Recorded for review (ON_DEMAND_REVIEW_ENABLED); nothing is running",
                "value": {
                  "error": "not_found",
                  "message": "This book is not in our catalogue. The request is recorded for review; no lookup is running.",
                  "status": "pending_review",
                  "isbn13": "9788411328241"
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests per second for this API key. Retry after 1 seconds.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "rate_limited",
              "message": "Too many requests per second for this API key. Retry after 1 seconds."
            }
          }
        },
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          },
          "RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimitLimit"
          },
          "RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          },
          "RateLimit-Policy": {
            "$ref": "#/components/headers/RateLimitPolicy"
          }
        }
      },
      "ServiceUnavailable": {
        "description": "The request could not be completed. Please try again shortly.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "service_unavailable",
              "message": "The request could not be completed. Please try again shortly."
            }
          }
        }
      },
      "LookupAccepted": {
        "description": "An on-demand lookup is running. Poll `GET /v1/lookups/{lookup_id}` after `Retry-After` seconds.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Lookup"
            },
            "example": {
              "status": "processing",
              "lookup_id": "lu_7Hq2mXa9KpR4",
              "isbn13": "9788411328241",
              "retry_after": 5,
              "partial": null
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "invalid_request",
              "invalid_api_key",
              "payment_required",
              "not_found",
              "rate_limited",
              "service_unavailable"
            ]
          },
          "message": {
            "type": "string",
            "description": "Human-readable; may change."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_review"
            ],
            "description": "Only on a `not_found` for a miss waiting in the on-demand review queue (`ON_DEMAND_REVIEW_ENABLED`): the request is recorded for staff review and no lookup is running. Not a promise that the book will be found. No `Retry-After`, no lookup id."
          },
          "isbn13": {
            "type": "string",
            "description": "With `status: pending_review`: the ISBN-13 that was recorded."
          }
        }
      },
      "Contributor": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "position": {
            "type": "integer"
          }
        }
      },
      "CoverURLs": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "small": {
            "type": "string",
            "format": "uri"
          },
          "medium": {
            "type": "string",
            "format": "uri"
          },
          "large": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "License": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string"
          },
          "attribution_required": {
            "type": "boolean"
          }
        }
      },
      "Ratings": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "average": {
            "type": "number"
          },
          "bayesian": {
            "type": "number"
          },
          "distribution": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "minItems": 5,
            "maxItems": 5
          }
        }
      },
      "Reading": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "want_to_read": {
            "type": "integer"
          },
          "currently_reading": {
            "type": "integer"
          },
          "already_read": {
            "type": "integer"
          }
        }
      },
      "Edition": {
        "type": "object",
        "description": "One edition. A field with no value is present and null.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Public id: the ISBN-13, or `bk_…` for an edition without an ISBN."
          },
          "has_isbn": {
            "type": "boolean"
          },
          "isbn13": {
            "type": [
              "string",
              "null"
            ]
          },
          "isbn10": {
            "type": [
              "string",
              "null"
            ]
          },
          "work_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "subtitle": {
            "type": [
              "string",
              "null"
            ]
          },
          "language": {
            "type": [
              "string",
              "null"
            ]
          },
          "publication_year": {
            "type": [
              "integer",
              "null"
            ]
          },
          "pages": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "contributors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Contributor"
            }
          },
          "cover_urls": {
            "$ref": "#/components/schemas/CoverURLs"
          },
          "license": {
            "$ref": "#/components/schemas/License"
          },
          "license_notice": {
            "type": "string",
            "description": "Present only when a licence requires a credit; display it verbatim."
          },
          "ratings": {
            "$ref": "#/components/schemas/Ratings"
          },
          "reading": {
            "$ref": "#/components/schemas/Reading"
          },
          "popularity": {
            "type": [
              "integer",
              "null"
            ]
          },
          "searchability": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "SearchHit": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "has_isbn": {
            "type": "boolean"
          },
          "isbn13": {
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "subtitle": {
            "type": [
              "string",
              "null"
            ]
          },
          "authors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "publisher": {
            "type": [
              "string",
              "null"
            ]
          },
          "publication_year": {
            "type": [
              "integer",
              "null"
            ]
          },
          "language": {
            "type": [
              "string",
              "null"
            ]
          },
          "cover_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "license_notice": {
            "type": "string"
          },
          "position": {
            "type": "integer"
          },
          "popularity": {
            "type": [
              "integer",
              "null"
            ]
          },
          "searchability": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": [
          "results",
          "total"
        ],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchHit"
            }
          },
          "total": {
            "type": "integer"
          },
          "total_is_approximate": {
            "type": "boolean"
          },
          "search_id": {
            "type": "string"
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "query": {
            "type": "string"
          },
          "query_type": {
            "type": "string",
            "enum": [
              "text",
              "isbn"
            ]
          },
          "match": {
            "type": "string"
          },
          "include_no_isbn": {
            "type": "boolean"
          },
          "sort": {
            "type": "string",
            "enum": [
              "relevance",
              "date_desc",
              "date_asc"
            ]
          },
          "isbn_lookup": {
            "$ref": "#/components/schemas/Lookup"
          },
          "lookup": {
            "type": "string",
            "enum": [
              "found",
              "queued",
              "not_found",
              "none",
              "pending_review"
            ],
            "description": "Only when the query found nothing locally (or an on-demand lookup found it just now): what the lookup said. `pending_review` with the review queue on (`ON_DEMAND_REVIEW_ENABLED`): the miss, ISBN or text, is recorded for staff review and nothing is running."
          }
        }
      },
      "BatchRequest": {
        "type": "object",
        "required": [
          "isbns"
        ],
        "properties": {
          "isbns": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "maxItems": 100
          }
        }
      },
      "BatchResponse": {
        "type": "object",
        "required": [
          "results"
        ],
        "properties": {
          "results": {
            "type": "object",
            "description": "Keyed by the ISBN as sent.",
            "additionalProperties": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/Edition"
                },
                {
                  "$ref": "#/components/schemas/Lookup"
                },
                {
                  "$ref": "#/components/schemas/Error"
                }
              ]
            }
          }
        }
      },
      "Lookup": {
        "type": "object",
        "required": [
          "status",
          "lookup_id"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "processing",
              "found",
              "not_found",
              "partial",
              "pending_review"
            ],
            "description": "`pending_review` only in a search's `isbn_lookup` while the review queue is on (`ON_DEMAND_REVIEW_ENABLED`): the ISBN waits for staff review, nothing is running, `lookup_id` and `retry_after` are null. `GET /v1/lookups/{id}` never answers it."
          },
          "lookup_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`lu_` + 12 base62 characters. `null` only with `status: pending_review` (no lookup to poll)."
          },
          "isbn13": {
            "type": "string"
          },
          "retry_after": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Seconds to wait before polling; only while processing."
          },
          "partial": {
            "type": [
              "object",
              "null"
            ],
            "description": "What is known so far, when anything is."
          },
          "edition": {
            "$ref": "#/components/schemas/Edition"
          }
        }
      },
      "ReportRequest": {
        "type": "object",
        "required": [
          "type",
          "isbn",
          "details",
          "email"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "error",
              "removal",
              "copyright"
            ]
          },
          "isbn": {
            "type": "string"
          },
          "details": {
            "type": "string",
            "description": "What is wrong, or the proof for a removal."
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          },
          "locale": {
            "type": "string"
          }
        }
      },
      "ReportReceipt": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        }
      }
    }
  }
}
