openapi: 3.0.0
info:
  title: Goodreads Book API
  description: |
    Look up a Goodreads edition by book ID, book URL or ISBN.

    The edition carries contributors, series, genres, format, publication details and identifiers. The average rating, rating and review counts, star distribution and original publication details describe the work across editions.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Goodreads Book lookup
      description: Pass exactly one of book_id, url or isbn.
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine used for this lookup.
          schema:
            type: string
            enum: [goodreads_book]
        - name: book_id
          in: query
          description: Goodreads edition ID from 1 to 2147483647.
          schema:
            type: string
            pattern: '^[0-9]{1,10}$'
          example: '44767458'
        - name: url
          in: query
          description: HTTPS URL of a Goodreads book page on www.goodreads.com.
          schema:
            type: string
            format: uri
            maxLength: 2048
          example: https://www.goodreads.com/book/show/44767458-dune
        - name: isbn
          in: query
          description: ISBN-10 or ISBN-13 with a valid checksum. Spaces and hyphens are accepted.
          schema:
            type: string
          example: '9780547928227'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        book:
          $ref: '#/components/schemas/Book'
        error:
          type: string
          description: Why the lookup returned no edition.
      oneOf:
        - required: [book]
        - required: [error]
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: "Unique identifier for the search request"
        status:
          type: string
          description: "Status of the search request"
        created_at:
          type: string
          format: date-time
          description: "Timestamp when the search was created"
        request_time_taken:
          type: number
          description: "Time taken to make the request in seconds"
        parsing_time_taken:
          type: number
          description: "Time taken to parse the results in seconds"
        total_time_taken:
          type: number
          description: "Total time taken for the search in seconds"
        request_url:
          type: string
          description: "Goodreads page for the lookup"
        html_url:
          type: string
          description: "URL to view HTML results"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used.
        book_id:
          type: string
          description: Goodreads edition ID supplied for the lookup.
        url:
          type: string
          description: Goodreads book URL supplied for the lookup.
        isbn:
          type: string
          description: ISBN supplied for the lookup, with spaces and hyphens removed.
        zero_retention:
          type: boolean
          description: Whether Zero Data Retention was enabled.
    Book:
      type: object
      required: [book_id, title, link, work_id]
      additionalProperties: false
      properties:
        book_id:
          type: integer
          description: Goodreads id of the edition.
        title:
          type: string
          description: Title of the edition.
        link:
          type: string
          description: Goodreads page of the edition.
        thumbnail:
          type: string
          description: Cover image of the edition.
        work_id:
          type: integer
          description: Goodreads id of the work, shared by every edition of the book.
        authors:
          type: array
          description: Authors and other contributors, the primary one first.
          items:
            $ref: '#/components/schemas/Author'
        series:
          type: array
          description: Series the book belongs to.
          items:
            $ref: '#/components/schemas/Series'
        rating:
          type: number
          description: Average rating of the work, from 0 to 5.
        ratings:
          type: integer
          description: Number of ratings of the work.
        reviews:
          type: integer
          description: Number of written reviews of the work.
        publication_date:
          type: string
          format: date
          description: Publication date of the edition.
        editions:
          type: integer
          description: Number of editions of the work.
        kindle_price:
          type: string
          description: Price of the Kindle edition in US dollars, as Goodreads lists it.
        extracted_kindle_price:
          type: number
          description: Numeric price of the Kindle edition in US dollars.
        description:
          type: string
          description: Description of the edition.
        genres:
          type: array
          description: Genres Goodreads lists for the book.
          items:
            type: string
        format:
          type: string
          description: Format of the edition.
        pages:
          type: integer
          description: Page count of the edition.
        publisher:
          type: string
          description: Publisher of the edition.
        language:
          type: string
          description: Language of the edition.
        isbn:
          type: string
          description: ISBN-10 of the edition.
        isbn13:
          type: string
          description: ISBN-13 of the edition.
        asin:
          type: string
          description: Amazon Standard Identification Number of the edition.
        best_book_id:
          type: integer
          description: Goodreads edition ID of the work's representative book.
        original_title:
          type: string
          description: Original title of the work.
        original_publication_date:
          type: string
          format: date
          description: Original publication date of the work.
        ratings_histogram:
          $ref: '#/components/schemas/RatingsHistogram'
        awards:
          type: array
          description: Awards and nominations Goodreads lists for the work.
          items:
            $ref: '#/components/schemas/Award'
        characters:
          type: array
          description: Names of characters in the work.
          items:
            type: string
        places:
          type: array
          description: Settings Goodreads lists for the work.
          items:
            $ref: '#/components/schemas/Place'
    RatingsHistogram:
      type: object
      description: Number of ratings of the work at each star level.
      additionalProperties: false
      required: ['1', '2', '3', '4', '5']
      properties:
        '1':
          type: integer
          minimum: 0
        '2':
          type: integer
          minimum: 0
        '3':
          type: integer
          minimum: 0
        '4':
          type: integer
          minimum: 0
        '5':
          type: integer
          minimum: 0
    Award:
      type: object
      required: [name]
      additionalProperties: false
      properties:
        name:
          type: string
          description: Name of the award.
        link:
          type: string
          description: Goodreads page of the award.
        year:
          type: integer
          description: Year of the award or nomination.
        category:
          type: string
          description: Category of the award or nomination.
        designation:
          type: string
          description: Designation Goodreads lists for the work, such as WINNER or NOMINEE.
    Place:
      type: object
      required: [name]
      additionalProperties: false
      properties:
        name:
          type: string
          description: Name of the setting.
        country:
          type: string
          description: Country of the setting.
        year:
          type: integer
          description: Year in which the work takes place at this setting.
        link:
          type: string
          description: Goodreads page of the setting.
    Author:
      type: object
      required: [name]
      properties:
        name:
          type: string
          description: Name of the author or contributor.
        author_id:
          type: integer
          description: Goodreads id of the author.
        link:
          type: string
          description: Goodreads page of the author.
        role:
          type: string
          description: Role Goodreads gives the contributor, such as "Author", "Editor" or "Illustrator".
    Series:
      type: object
      required: [title]
      properties:
        title:
          type: string
          description: Title of the series.
        series_id:
          type: integer
          description: Goodreads id of the series.
        link:
          type: string
          description: Goodreads page of the series.
        position:
          type: string
          description: Place of the book in the series, such as "1", "3.5", "1-4" or "1 of 2".
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
