openapi: 3.0.0
info:
  title: Apple Product Reviews API
  description: |
    Fetch user reviews for apps on the Apple App Store. This API allows you to retrieve detailed reviews for any app by product ID, with options to filter by country and sort by different criteria (most recent or most helpful).

    **Cross-linking**: Use the `product_id` from the Apple App Store API to fetch reviews for that app.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Apple Product Reviews Search
      description: Fetch user reviews for an Apple App Store product
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to use
          schema:
            type: string
            enum: ["apple_product_reviews"]
            default: "apple_product_reviews"
        - name: product_id
          in: query
          required: true
          description: Apple App Store product ID (can be found in app URLs or obtained from Apple App Store API results)
          schema:
            type: string
        - name: country
          in: query
          required: false
          description: 'Two-letter country code (ISO 3166-1 alpha-2). Default: "us"'
          schema:
            type: string
            enum: ["al", "dz", "ao", "ai", "ag", "ar", "am", "au", "at", "az", "bs", "bh", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bw", "br", "vg", "bn", "bg", "bf", "kh", "ca", "cv", "ky", "cl", "td", "cn", "co", "cd", "cr", "hr", "cy", "cz", "dk", "dm", "do", "ec", "eg", "sv", "ee", "fj", "fi", "fr", "de", "gm", "gb", "gh", "gr", "gd", "gt", "gw", "gy", "hn", "hk", "hu", "is", "in", "id", "ie", "il", "it", "jm", "jp", "jo", "kz", "ke", "kw", "kg", "la", "lv", "lb", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "ml", "mt", "mr", "mu", "mx", "fm", "md", "mn", "ms", "mz", "na", "np", "nl", "nz", "ni", "ne", "ng", "no", "om", "pk", "pw", "pa", "pg", "py", "pe", "ph", "pl", "pt", "qa", "ro", "ru", "st", "sa", "sn", "sc", "sl", "sg", "sk", "si", "sb", "za", "kr", "es", "lk", "kn", "lc", "vc", "sr", "sz", "se", "ch", "tw", "tj", "tz", "th", "tt", "tn", "tr", "tm", "tc", "ug", "ua", "ae", "us", "uy", "uz", "ve", "vn", "ye", "zw"]
            default: "us"
        - name: page
          in: query
          required: false
          description: 'Page number for pagination (1-10). Default: 1'
          schema:
            type: integer
            minimum: 1
            maximum: 10
            default: 1
        - name: sort_by
          in: query
          required: false
          description: 'Sort order for reviews. Default: "most_recent"'
          schema:
            type: string
            enum: ["most_recent", "most_helpful"]
            default: "most_recent"
      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'
        reviews:
          type: array
          description: List of user reviews for the app
          items:
            $ref: '#/components/schemas/Review'
        error:
          type: string
          description: Error message if no reviews were found
    SearchMetadata:
      type: object
      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: Apple App Store URL for this product reviews
        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_id:
          type: string
          description: Product ID queried
        country:
          type: string
          description: Country filter applied
        page:
          type: integer
          description: Page number of results
        sort_by:
          type: string
          description: Sort order applied to results
    Review:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the review
        title:
          type: string
          description: Title/headline of the review
        text:
          type: string
          description: Full text content of the review
        rating:
          type: integer
          description: Star rating given in the review (typically 1-5)
        review_date:
          type: string
          description: Date when the review was posted (ISO 8601 format)
        version:
          type: string
          description: Version of the app that was reviewed
        author:
          $ref: '#/components/schemas/ReviewAuthor'
    ReviewAuthor:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier of the review author
        name:
          type: string
          description: Display name of the review author
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
