openapi: 3.0.0
info:
  title: Amazon Stock API
  description: |
    Get how many units of an Amazon offer the seller has in stock, for the buy box offer or any offer by its offer listing ID, with the offer's price, condition and seller.

    **Cross-linking**: Use an `offer_listing_id` from the Amazon Offers API or the Amazon Product API as the `offer_id` parameter to get the stock of that offer.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Amazon Stock Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to use
          schema:
            type: string
            enum: ["amazon_stock"]
        - name: asin
          in: query
          required: true
          description: Amazon Standard Identification Number (10-character alphanumeric identifier)
          schema:
            type: string
            pattern: '^[A-Z0-9]{10}$'
        - name: offer_id
          in: query
          required: false
          description: Offer to check, as the `offer_listing_id` the Amazon Offers API or the Amazon Product API returns. Defaults to the buy box offer, or to the first new offer when no offer holds the buy box. Offer listing IDs expire, so fetch them shortly before.
          schema:
            type: string
        - name: amazon_domain
          in: query
          required: false
          description: Amazon domain of the offer
          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: postal_code
          in: query
          required: false
          description: "Postal/ZIP code for the delivery address, used by postal-code marketplaces (e.g. 10001 for US, SW1A 0AA for UK, 10115 for DE). Max 20 characters. Mutually exclusive with delivery_city; see the Amazon delivery location reference for which parameter applies per country."
          schema:
            type: string
            maxLength: 20
        - name: delivery_city
          in: query
          required: false
          description: "City for the delivery address in snake_case (e.g. riyadh, abu_dhabi, cairo), used only by city-based marketplaces (Saudi Arabia, UAE, Egypt). Max 100 characters. Mutually exclusive with postal_code; for other countries use postal_code."
          schema:
            type: string
            maxLength: 100
        - name: delivery_area
          in: query
          required: false
          description: "Area/district within the city for city-based marketplaces that support it (e.g. business_bay on amazon.ae). Max 100 characters. Optional refinement; must be sent together with delivery_city."
          schema:
            type: string
            maxLength: 100
      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'
        offer:
          $ref: '#/components/schemas/Offer'
        stock:
          $ref: '#/components/schemas/Stock'
        error:
          type: string
          description: Error message when Amazon has no such product

    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: Amazon product URL for this search
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
        delivery_location:
          type: string
          enum: [applied, not_applied, unverified]
          description: "Outcome of the requested delivery location, present only when postal_code/delivery_city/delivery_area was sent. `applied` means the served page reflects the location, `not_applied` means it shows another location, `unverified` means the page has no verifiable location."

    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        asin:
          type: string
          description: Amazon Standard Identification Number
        offer_id:
          type: string
          description: Offer listing ID that was checked
        amazon_domain:
          type: string
          description: Amazon domain used for the search
        delivery_country:
          type: string
          description: Delivery country code
        postal_code:
          type: string
          description: Postal code of the delivery location
        delivery_city:
          type: string
          description: City of the delivery location
        delivery_area:
          type: string
          description: Area of the delivery location

    Product:
      type: object
      required: [asin, title, 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

    Stock:
      type: object
      required: [is_in_stock]
      properties:
        stock_level:
          type: integer
          description: Units of the offer the seller has available for the delivery location, 0 when the offer can't be bought.
        is_in_stock:
          type: boolean
          description: Whether the offer can be bought
        is_lower_bound:
          type: boolean
          description: Whether Amazon accepted the whole quantity, so the seller has at least `stock_level` units.
        has_purchase_limit:
          type: boolean
          description: Whether the seller limits how many units one customer can buy, so `purchase_limit` is returned instead of `stock_level`.
        purchase_limit:
          type: integer
          description: Most units of the offer one customer can buy.
        message:
          type: string
          description: Amazon's message about the quantity, in the marketplace's language.

    Offer:
      type: object
      required: [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/OriginalPrice'
        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

    OriginalPrice:
      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
        label:
          type: string
          description: Label Amazon shows before the price, in the page's language, such as List Price, Was or De

    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: [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

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