openapi: 3.0.0
info:
  title: Amazon Offers API
  description: |
    Search for product offers and pricing information on Amazon by ASIN.

    **Cross-linking**: Use product ASINs from Amazon Search API results as the `asin` parameter to get detailed offer information.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Amazon Offers Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to use
          schema:
            type: string
            enum: ["amazon_offers"]
        - name: asin
          in: query
          required: true
          description: Amazon Standard Identification Number (10-character alphanumeric identifier)
          schema:
            type: string
            pattern: '^[A-Z0-9]{10}$'
        - name: amazon_domain
          in: query
          required: false
          description: Amazon domain to search on
          schema:
            type: string
            enum: ["amazon.ae", "amazon.ca", "amazon.co.jp", "amazon.co.uk", "amazon.com", "amazon.com.au", "amazon.com.be", "amazon.com.br", "amazon.com.tr", "amazon.com.mx", "amazon.de", "amazon.es", "amazon.eg", "amazon.fr", "amazon.in", "amazon.ie", "amazon.it", "amazon.nl", "amazon.pl", "amazon.sa", "amazon.se", "amazon.sg", "amazon.co.za"]
            default: "amazon.com"
        - name: delivery_country
          in: query
          required: false
          description: Country code for delivery options
          schema:
            type: string
            enum: ["dz", "ao", "bh", "bw", "cm", "eg", "gh", "il", "jo", "ke", "kw", "kg", "mu", "yt", "ma", "na", "ng", "om", "ps", "qa", "re", "sa", "sn", "za", "tz", "tn", "ug", "ae", "zw", "ar", "aw", "bb", "bz", "bm", "bo", "br", "ca", "ky", "cl", "co", "cr", "do", "ec", "sv", "gf", "gp", "gt", "hn", "jm", "mq", "mx", "pa", "py", "pe", "kn", "mf", "tt", "uy", "ve", "au", "bd", "kh", "cn", "fj", "hk", "in", "id", "jp", "kz", "mo", "my", "mh", "fm", "nc", "nz", "pk", "pw", "ph", "sg", "kr", "lk", "tw", "th", "vn", "al", "ad", "am", "at", "by", "be", "ba", "bg", "hr", "cy", "cz", "dk", "ee", "fo", "fi", "fr", "ge", "de", "gi", "gr", "hu", "is", "ie", "it", "lv", "li", "lt", "lu", "mt", "md", "mc", "me", "nl", "mk", "no", "pl", "pt", "ro", "ru", "sm", "rs", "sk", "si", "es", "se", "ch", "tr", "ua", "gb", "us", "va"]
        - name: filters
          in: query
          required: false
          description: 'Comma-separated list of filters to apply'
          schema:
            type: string
            pattern: '^(prime|free_shipping|new|used_like_new|used_very_good|used_good|used_acceptable|collectible)(,(prime|free_shipping|new|used_like_new|used_very_good|used_good|used_acceptable|collectible))*$'
        - name: page
          in: query
          required: false
          description: Page number for pagination
          schema:
            type: integer
            minimum: 1
            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'
        product:
          $ref: '#/components/schemas/Product'
        offers:
          type: array
          items:
            $ref: '#/components/schemas/Offer'
        has_no_offers:
          type: boolean
          description: Indicates when no offers are available for the product
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Error message when Amazon returns no results

    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: "Amazon Offers 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
        asin:
          type: string
          description: Amazon Standard Identification Number
        amazon_domain:
          type: string
          description: Amazon domain used for the search
        delivery_country:
          type: string
          description: Delivery country code
        filters:
          type: string
          description: Applied filters

    SearchInformation:
      type: object
      properties:
        filters_applied:
          type: array
          items:
            type: string
          description: List of currently applied filters

    Product:
      type: object
      required: [asin, title, rating, reviews, link]
      properties:
        asin:
          type: string
          description: Amazon Standard Identification Number
        title:
          type: string
          description: Product title
        rating:
          type: number
          description: Average customer rating
        reviews:
          type: integer
          description: Number of customer reviews
        main_image:
          type: string
          description: URL of the product's main image
        link:
          type: string
          description: Link to the product page

    Offer:
      type: object
      required: [position, price, condition, fulfillment, offer_listing_id]
      properties:
        position:
          type: integer
          description: Position of this offer in the list
        is_buybox_winner:
          type: boolean
          description: Whether this offer won the buy box
        price:
          $ref: '#/components/schemas/Price'
        original_price:
          $ref: '#/components/schemas/Price'
        price_per:
          $ref: '#/components/schemas/PricePer'
        save:
          $ref: '#/components/schemas/Save'
        is_prime:
          type: boolean
          description: Whether the offer is Prime eligible
        minimum_order_quantity:
          type: integer
          description: Minimum quantity that can be ordered
        maximum_order_quantity:
          type: integer
          description: Maximum quantity that can be ordered
        condition:
          $ref: '#/components/schemas/Condition'
        fulfillment:
          $ref: '#/components/schemas/Fulfillment'
        offer_listing_id:
          type: string
          description: Unique identifier for this offer listing

    Price:
      type: object
      required: [raw, value, symbol, currency]
      properties:
        raw:
          type: string
          description: Raw price text as displayed
        value:
          type: number
          description: Numeric price value
        symbol:
          type: string
          description: Currency symbol
        currency:
          type: string
          description: Currency code

    PricePer:
      type: object
      required: [raw, value, symbol, currency, unit]
      properties:
        raw:
          type: string
          description: Raw price per unit text
        value:
          type: number
          description: Numeric price per unit value
        symbol:
          type: string
          description: Currency symbol
        currency:
          type: string
          description: Currency code
        unit:
          type: string
          description: Unit of measurement

    Save:
      type: object
      required: [percentage]
      properties:
        percentage:
          type: number
          description: Percentage saved compared to original price

    Condition:
      type: object
      required: [text, is_new]
      properties:
        text:
          type: string
          description: Condition description text
        is_new:
          type: boolean
          description: Whether the item is new
        description:
          type: string
          description: Detailed condition description
        images:
          type: array
          items:
            type: string
          description: URLs of condition-related images

    Fulfillment:
      type: object
      required: [standard_delivery, ships_from, sold_by]
      properties:
        is_unavailable:
          type: boolean
          description: Whether the offer is currently unavailable
        standard_delivery:
          $ref: '#/components/schemas/Delivery'
        fastest_delivery:
          $ref: '#/components/schemas/Delivery'
        third_party_seller:
          $ref: '#/components/schemas/ThirdPartySeller'
        ships_from:
          type: string
          description: Location the item ships from
        ships_from_country:
          type: string
          description: Country the item ships from
        sold_by:
          type: string
          description: Name of the seller
        is_sold_by_amazon:
          type: boolean
          description: Whether the item is sold by Amazon
        is_international:
          type: boolean
          description: Whether this is an international offer

    Delivery:
      type: object
      required: [text]
      properties:
        text:
          type: string
          description: Delivery description text
        type:
          type: string
          description: Delivery type identifier
        value:
          type: number
          description: Delivery cost value
        date:
          type: string
          description: Expected delivery date

    ThirdPartySeller:
      type: object
      properties:
        id:
          type: string
          description: Seller's unique identifier
        name:
          type: string
          description: Seller's name
        link:
          type: string
          description: Link to seller's page
        rating:
          type: number
          description: Seller's rating
        reviews:
          type: integer
          description: Number of seller reviews
        positive_feedback_percent:
          type: number
          description: Percentage of positive feedback

    Pagination:
      type: object
      properties:
        current:
          type: integer
          description: Current page number
        previous:
          type: integer
          description: Previous page number
        next:
          type: integer
          description: Next page number
        total_pages:
          type: integer
          description: Total number of pages

    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong