openapi: 3.0.0
info:
  title: Goodreads Search API
  description: |
    Search Goodreads for books by title, author or ISBN.

    Each result carries the Goodreads book id, work id, author ids and series ids, with the title, link, cover, publication date and number of editions. The average rating and the rating and review counts belong to the work, so they count every edition of the book.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Goodreads Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `goodreads_search`'
          schema:
            type: string
            enum: ["goodreads_search"]
        - name: q
          in: query
          required: true
          description: The title, author or ISBN to search for.
          schema:
            type: string
            maxLength: 512
        - name: search_type
          in: query
          required: false
          description: The book field the search matches. `all` matches titles, authors and ISBNs.
          schema:
            type: string
            enum: ["all", "title", "author"]
            default: "all"
        - name: page
          in: query
          required: false
          description: Page of results, 20 results a page.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 1
      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'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        organic_results:
          type: array
          description: Books Goodreads lists for the search, in Goodreads' order.
          items:
            $ref: '#/components/schemas/OrganicResult'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Why the search returned no books.
    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 search page for this search"
        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
        q:
          type: string
          description: The title, author or ISBN searched for
        search_type:
          type: string
          description: The book field the search matches
        page:
          type: integer
          description: Page of results
    SearchInformation:
      type: object
      required: [total_results]
      properties:
        total_results:
          type: integer
          description: Number of books Goodreads reports for the search.
    OrganicResult:
      type: object
      required: [position, book_id, title, link, work_id, authors, ratings, reviews, editions]
      properties:
        position:
          type: integer
          description: Position of the book on the page.
        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: Price of the Kindle edition as a number.
    Author:
      type: object
      required: [name, author_id, link, role]
      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, series_id, link]
      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".
    Pagination:
      type: object
      required: [current, total_pages]
      properties:
        current:
          type: integer
          description: Current page.
        total_pages:
          type: integer
          description: Number of pages Goodreads lists for the search, at most 100.
        next:
          type: string
          description: Goodreads page with the next 20 results.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
