openapi: 3.0.0
info:
  title: Google Product Reviews API
  description: |
    Fetch detailed product reviews from Google Shopping, including ratings, review text, sources, and filtering capabilities.

    **Cross-linking**: 
    - Use the **Google Product API** to search for products and get their `product_id` values
    - Use the **Google Product Offers API** to get pricing information for the same product
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Google Product Reviews Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to use
          schema:
            type: string
            enum: ["google_product_reviews"]
        - name: product_token
          in: query
          required: true
          description: Product token to fetch reviews for
          schema:
            type: string
        - name: location
          in: query
          required: false
          description: Geographic location for localized results
          schema:
            type: string
        - name: uule
          in: query
          required: false
          description: Google's encoded location parameter
          schema:
            type: string
        - name: hl
          in: query
          required: false
          description: Language for the search results
          schema:
            type: string
            default: "en"
            enum: ["af", "ak", "sq", "am", "ar", "hy", "az", "eu", "be", "bem", "bn", "bh", "xx-bork", "bs", "br", "bg", "km", "ca", "chr", "ny", "zh-cn", "zh-tw", "co", "hr", "cs", "da", "nl", "xx-elmer", "en", "eo", "et", "ee", "fo", "tl", "fi", "fr", "fy", "gaa", "gl", "ka", "de", "el", "kl", "gn", "gu", "xx-hacker", "ht", "ha", "haw", "iw", "hi", "hu", "is", "ig", "id", "ia", "ga", "it", "ja", "jw", "kn", "kk", "rw", "rn", "xx-klingon", "kg", "ko", "kri", "ku", "ckb", "ky", "lo", "la", "lv", "ln", "lt", "loz", "lg", "ach", "mk", "mg", "my", "ms", "ml", "mt", "mv", "mi", "mr", "mfe", "mo", "mn", "sr-me", "ne", "pcm", "nso", "no", "nn", "oc", "or", "om", "ps", "fa", "xx-pirate", "pl", "pt", "pt-br", "pt-pt", "pa", "qu", "ro", "rm", "nyn", "ru", "gd", "sr", "sh", "st", "tn", "crs", "sn", "sd", "si", "sk", "sl", "so", "es", "es-419", "su", "sw", "sv", "tg", "ta", "tt", "te", "th", "ti", "to", "lua", "tum", "tr", "tk", "tw", "ug", "uk", "ur", "uz", "vu", "vi", "cy", "wo", "xh", "yi", "yo", "zu"]
        - name: gl
          in: query
          required: false
          description: Country for the search results
          schema:
            type: string
            default: "us"
            enum: ["ae", "ai", "ar", "au", "bm", "br", "ca", "cc", "ch", "cl", "co", "cx", "fk", "gb", "gs", "hk", "hm", "id", "il", "in", "io", "jp", "kr", "ky", "ms", "mx", "my", "nf", "nz", "ph", "ru", "sa", "sg", "tc", "th", "tk", "tr", "tw", "ua", "uk", "us", "vg", "vn", "za", "at", "aw", "be", "cz", "de", "dk", "es", "fi", "fr", "gf", "gp", "gr", "hu", "ie", "it", "mq", "nc", "nl", "no", "pf", "pl", "pm", "pt", "re", "ro", "se", "sk", "tf", "wf", "yt"]
        - name: sort_by
          in: query
          required: false
          description: Sort order for reviews
          schema:
            type: string
            enum: ["most_relevant", "most_recent"]
        - name: rating
          in: query
          required: false
          description: Filter reviews by rating
          schema:
            type: string
            enum: ["all", "1", "2", "3", "4", "5"]
        - name: next_page_token
          in: query
          required: false
          description: Token for pagination to get the next page of results
          schema:
            type: string
      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'
        product:
          $ref: '#/components/schemas/Product'
        review_results:
          type: array
          description: List of reviews
          items:
            $ref: '#/components/schemas/Review'
        pagination:
          $ref: '#/components/schemas/Pagination'
    SearchMetadata:
      type: object
      required: [id, 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: Google Product Reviews URL 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
        product_token:
          type: string
          description: Product token searched for
        uule:
          type: string
          description: Google's encoded location parameter
        hl:
          type: string
          description: Language code used
        gl:
          type: string
          description: Country code used
        sort_by:
          type: string
          description: Sort order used for reviews
        rating:
          type: string
          description: Rating filter applied
        next_page_token:
          type: string
          description: Pagination token used
    Product:
      type: object
      properties:
        rating:
          type: number
          description: Average rating
        reviews:
          type: integer
          description: Total number of reviews
        reviews_histogram:
          type: object
          description: Distribution of reviews by rating
          properties:
            "1":
              type: integer
              description: Number of 1-star reviews
            "2":
              type: integer
              description: Number of 2-star reviews
            "3":
              type: integer
              description: Number of 3-star reviews
            "4":
              type: integer
              description: Number of 4-star reviews
            "5":
              type: integer
              description: Number of 5-star reviews
    Review:
      type: object
      properties:
        username:
          type: string
          description: Reviewer's username
        source:
          type: string
          description: Source of the review
        title:
          type: string
          description: Review title
        date:
          type: string
          description: Review date
        rating:
          type: integer
          description: Rating given
        text:
          type: string
          description: Review text content
    Pagination:
      type: object
      properties:
        next_page_token:
          type: string
          description: Token for next page
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong