openapi: 3.0.0
info:
  title: Myntra Search API
  description: |
    The Myntra Search API returns the products Myntra shows for a search on myntra.com, India's fashion marketplace, in the order Myntra lays them out, sponsored ones included. Each result includes the product ID, title, brand, link, price in Indian rupees and images, and when Myntra shows them, the MRP and discount, the best price with Myntra's coupon or offers, rating and rating count, sizes, other colours, gender and category, merchandising badges and a delivery promise for a postal code. The response also includes the filters Myntra offers with their product counts, the total number of results and a token for the next page.

    Myntra pages its results with a cursor, so later pages come from `next_page_token` rather than a page number. A search that matches no products returns an `error` message in place of the results.

    **Cross-linking**: The `filters` parameter accepts the `filter_value` of the values in `filters`, and the price, discount and rating values carry the `price_min`, `price_max`, `discount_min` or `rating_min` that apply them. The `next_page_token` parameter accepts `pagination.next_page_token`. The `product_id` of a result identifies the product on Myntra, and its `link` opens the product page.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Myntra Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Engine to use for the search
          schema:
            type: string
            enum: ["myntra_search"]
            default: "myntra_search"
        - name: q
          in: query
          required: false
          description: Search query, such as `shirts` or `kurta set women`, in English or Hindi (maximum 200 characters, with at least one letter or number). Myntra leaves out symbols such as emoji and refuses some scripts, such as Cyrillic. Required unless `next_page_token` is given, which carries it.
          schema:
            type: string
            maxLength: 200
        - name: sort_by
          in: query
          required: false
          description: Sort order of the results. Myntra shows sponsored products only in `recommended` order.
          schema:
            type: string
            enum: ["recommended", "most_popular", "new_arrivals", "best_discount", "price_low_to_high", "price_high_to_low", "top_rated"]
            default: "recommended"
        - name: filters
          in: query
          required: false
          description: Filters to apply, as `filter_value` strings from the response's `filters` joined by commas, such as `Brand:Roadster,Brand:HIGHLANDER,Gender:men`. Each is a filter `id` and a value, `id:value`. Two values of one filter return products that match either, and values of different filters must all match. Send each `filter_value` as returned, since Myntra matches some filters case by case. Sponsored products are not filtered. Use `price_min`, `price_max`, `discount_min` and `rating_min` for prices, discounts and ratings.
          schema:
            type: string
        - name: price_min
          in: query
          required: false
          description: Minimum price in Indian rupees.
          schema:
            type: integer
            minimum: 0
            maximum: 10000000
        - name: price_max
          in: query
          required: false
          description: Maximum price in Indian rupees, at least `price_min`.
          schema:
            type: integer
            minimum: 0
            maximum: 10000000
        - name: discount_min
          in: query
          required: false
          description: Minimum discount off the MRP, as a whole percentage, such as `50` for 50% and above.
          schema:
            type: integer
            minimum: 1
            maximum: 99
        - name: rating_min
          in: query
          required: false
          description: Minimum customer rating in stars, such as `4` for 4 stars and above.
          schema:
            type: integer
            minimum: 1
            maximum: 4
        - name: postal_code
          in: query
          required: false
          description: Indian PIN code to deliver to, such as `560001`. Myntra then shows a delivery promise on the products it can deliver there.
          schema:
            type: string
            pattern: '^[1-9]\d{5}$'
        - name: next_page_token
          in: query
          required: false
          description: Token for the next page of results, from `pagination.next_page_token`. It carries the search's other parameters, so they can be omitted, and a conflicting value is rejected. Request the first page again for a new token once it has expired.
          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, invalid values, a query in a script Myntra refuses or an expired next_page_token.
          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
          items:
            $ref: '#/components/schemas/OrganicResult'
          description: Products on the results page, sponsored ones included, in the order Myntra lays them out
        filters:
          type: array
          items:
            $ref: '#/components/schemas/Filter'
          description: Filters Myntra offers for the results
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Error message for a search Myntra answers with no products
    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: Myntra URL of the results page
        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: Engine used for the search
        q:
          type: string
          description: Search query
        sort_by:
          type: string
          description: Sort order applied
        filters:
          type: string
          description: Filters applied
        price_min:
          type: string
          description: Minimum price applied, in Indian rupees
        price_max:
          type: string
          description: Maximum price applied, in Indian rupees
        discount_min:
          type: string
          description: Minimum discount applied, as a percentage
        rating_min:
          type: string
          description: Minimum rating applied, in stars
        postal_code:
          type: string
          description: PIN code delivered to
        next_page_token:
          type: string
          description: Token of the page requested
    SearchInformation:
      type: object
      required: [total_results]
      properties:
        total_results:
          type: integer
          description: Number of products Myntra reports for the search
    OrganicResult:
      type: object
      required: [position, product_id, title, brand, link, price, extracted_price, thumbnail, images]
      properties:
        position:
          type: integer
          description: Position of the product in the results, counted across pages
        product_id:
          type: string
          description: Myntra product ID
        title:
          type: string
          description: Product title
        subtitle:
          type: string
          description: Short description Myntra prints under the brand on the card
        brand:
          type: string
          description: Brand name
        brand_logo:
          type: string
          description: URL of the brand's logo
        link:
          type: string
          description: URL of the product page on Myntra
        price:
          type: string
          description: Selling price as displayed, in Indian rupees
        extracted_price:
          type: integer
          description: Selling price in Indian rupees
        original_price:
          type: string
          description: MRP as displayed, in Indian rupees
        extracted_original_price:
          type: number
          description: MRP in Indian rupees, with paise when Myntra lists them
        discount:
          type: integer
          description: Discount off the MRP in Indian rupees
        discount_percentage:
          type: integer
          description: Discount off the MRP as a whole percentage, as Myntra shows it
        coupon:
          $ref: '#/components/schemas/Coupon'
        rating:
          type: number
          description: Average customer rating out of 5
        reviews:
          type: integer
          description: Number of customer ratings
        sizes:
          type: array
          items:
            type: string
          description: Sizes the product comes in
        color:
          type: string
          description: Primary colour of the product
        variants:
          type: array
          items:
            $ref: '#/components/schemas/Variant'
          description: Other colours of the product that Myntra lists on the card
        variants_count:
          type: integer
          description: Number of other colours the product comes in
        gender:
          type: string
          description: Gender the product is made for
        category:
          type: string
          description: Product category, such as Shirts
        sub_category:
          type: string
          description: Broader category, such as Topwear
        master_category:
          type: string
          description: Broadest category, such as Apparel
        badges:
          type: array
          items:
            $ref: '#/components/schemas/Badge'
          description: Tags Myntra attaches to the product, such as a bestseller rank or a count of reviews with photos
        seller_id:
          type: string
          description: ID of the seller whose offer the buy button takes
        catalog_date:
          type: string
          format: date
          description: Date the product was listed on Myntra
        season:
          type: string
          description: Season and year of the product's collection
        delivery:
          type: string
          description: Delivery promise for the requested postal code
        is_sponsored:
          type: boolean
          description: Whether the product is a sponsored placement
        thumbnail:
          type: string
          description: URL of the product image on the card
        images:
          type: array
          items:
            type: string
          description: URLs of the product's images, starting with the card's image
        videos:
          type: array
          items:
            type: string
          description: URLs of the product's videos
    Coupon:
      type: object
      required: [best_price, extracted_best_price]
      properties:
        code:
          type: string
          description: Coupon code the best price needs
        discount:
          type: integer
          description: Discount the coupon takes off the selling price, in Indian rupees
        best_price:
          type: string
          description: Best price Myntra shows with its coupon or offers, as displayed, in Indian rupees
        extracted_best_price:
          type: integer
          description: Best price Myntra shows with its coupon or offers, in Indian rupees
        expires_at:
          type: string
          format: date-time
          description: Time the coupon expires, in UTC
    Variant:
      type: object
      required: [product_id, link]
      properties:
        product_id:
          type: string
          description: Myntra product ID of the colour
        color_hex:
          type: string
          description: Hex code of the colour
        link:
          type: string
          description: URL of the colour's product page on Myntra
        thumbnail:
          type: string
          description: URL of the colour's image
    Badge:
      type: object
      required: [text]
      properties:
        key:
          type: string
          description: Badge identifier
        text:
          type: string
          description: Badge text as displayed
    Filter:
      type: object
      required: [id, name, values]
      properties:
        id:
          type: string
          description: Filter identifier, the part of a `filter_value` before the colon
        name:
          type: string
          description: Filter name as displayed
        values:
          type: array
          items:
            $ref: '#/components/schemas/FilterValue'
          description: Values of the filter, at most the 30 with the most products, largest first, plus applied ones
    FilterValue:
      type: object
      required: [name, items_count]
      properties:
        name:
          type: string
          description: Value name as displayed
        items_count:
          type: integer
          description: Number of products with this value
        color_hex:
          type: string
          description: Hex code of a colour value
        is_selected:
          type: boolean
          description: Whether the value is applied to the results
        filter_value:
          type: string
          description: Value for the `filters` parameter that applies this value
        price_min:
          type: integer
          description: Value for the `price_min` parameter that applies this price range
        price_max:
          type: integer
          description: Value for the `price_max` parameter that applies this price range
        discount_min:
          type: integer
          description: Value for the `discount_min` parameter that applies this discount
        rating_min:
          type: integer
          description: Value for the `rating_min` parameter that applies this rating
    Pagination:
      type: object
      required: [current]
      properties:
        current:
          type: integer
          description: Current page number
        next_page_token:
          type: string
          description: Token to pass as `next_page_token` for the next page of results
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
