openapi: 3.0.0
info:
  title: Rakuten Search API
  description: |
    Search Rakuten Ichiba, Japan's online marketplace, for products.

    Results include product, item and shop ids, title, link, image, tax-included yen price and seller, plus the price range, shipping cost, delivery estimate, points, rating and review count where Rakuten shows them. Sponsored rows stay in Rakuten's order and are marked with `is_sponsored`.

    The response lists the categories and filters Rakuten offers for the search. Send a category's `id` in `category_id`, or a filter option's `value` in `attribute_ids`, to narrow the next search.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Rakuten Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `rakuten_search`'
          schema:
            type: string
            enum: ["rakuten_search"]
        - name: q
          in: query
          required: true
          description: Search text, up to 500 characters, such as a product name, a brand or a JAN code. It needs a letter, number or symbol, not only punctuation, and cannot hold a script tag.
          schema:
            type: string
        - name: category_id
          in: query
          required: false
          description: Category to search in, an `id` from the `categories` of an earlier response, such as `560271`. A category Rakuten does not have returns an error.
          schema:
            type: string
            pattern: '^[1-9]\d{0,19}$'
        - name: store_id
          in: query
          required: false
          description: Shop to search in, a `seller.id` from an earlier response, such as `297400`.
          schema:
            type: string
            pattern: '^[1-9]\d{0,19}$'
        - name: price_min
          in: query
          required: false
          description: Lowest price in yen, tax included.
          schema:
            type: integer
            minimum: 0
            maximum: 999999999
        - name: price_max
          in: query
          required: false
          description: Highest price in yen, tax included. It must not be lower than `price_min`.
          schema:
            type: integer
            minimum: 0
            maximum: 999999999
        - name: rating
          in: query
          required: false
          description: Lowest average review score, in stars.
          schema:
            type: string
            enum: ["3.5", "4", "4.5"]
        - name: is_free_shipping
          in: query
          required: false
          description: Only products that ship for free.
          schema:
            type: boolean
            default: false
        - name: is_next_day_delivery
          in: query
          required: false
          description: Only products Rakuten marks for next-day delivery. It cannot be combined with the price with shipping sorts.
          schema:
            type: boolean
            default: false
        - name: condition
          in: query
          required: false
          description: Only used products.
          schema:
            type: string
            enum: ["used"]
        - name: excluded_keywords
          in: query
          required: false
          description: Words the results must not contain, separated by spaces, up to 200 characters, without a script tag.
          schema:
            type: string
        - name: attribute_ids
          in: query
          required: false
          description: One filter option to apply, a `value` from the `filters` of an earlier response, such as `1000886`.
          schema:
            type: string
            pattern: '^[1-9]\d{0,19}$'
        - name: sort_by
          in: query
          required: false
          description: Sorts the results. The price with shipping sorts add the shipping cost to the price.
          schema:
            type: string
            enum: ["best_match", "price_low_to_high", "price_high_to_low", "price_with_shipping_low_to_high", "price_with_shipping_high_to_low", "newest", "most_reviews", "highest_rating"]
            default: "best_match"
        - name: page
          in: query
          required: false
          description: Page of results, 45 products each. Rakuten serves 150 pages for `best_match` and `newest`, and 9 pages for the other sorts. The last page is the one whose `pagination` has no `next`.
          schema:
            type: integer
            minimum: 1
            maximum: 150
            default: 1
        - name: zero_retention
          in: query
          required: false
          description: Disable persistent request and response storage for Enterprise accounts.
          schema:
            type: boolean
      responses:
        '200':
          description: Search completed. The response may contain an error explaining an empty result.
          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'
        '403':
          description: Account cannot use the requested feature.
          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
          description: Products Rakuten lists for the search, sponsored rows included, in Rakuten's order.
          items:
            $ref: '#/components/schemas/OrganicResult'
        categories:
          type: array
          description: Categories Rakuten offers to narrow the search.
          items:
            $ref: '#/components/schemas/Category'
        filters:
          type: array
          description: Filters Rakuten offers for the search.
          items:
            $ref: '#/components/schemas/Filter'
        related_searches:
          type: array
          description: Searches Rakuten suggests.
          items:
            $ref: '#/components/schemas/RelatedSearch'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Why the search returned no products, or the error Rakuten answered with.
    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: "Rakuten search page for this search"
        html_url:
          type: string
          description: "URL to view the raw results"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        q:
          type: string
          description: The text searched for
        category_id:
          type: string
          description: Category searched in
        store_id:
          type: string
          description: Shop searched in
        price_min:
          type: string
          description: Lowest price
        price_max:
          type: string
          description: Highest price
        rating:
          type: string
          description: Lowest average review score
        is_free_shipping:
          type: string
          description: Free shipping filter
        is_next_day_delivery:
          type: string
          description: Next-day delivery filter
        condition:
          type: string
          description: Condition filter
        excluded_keywords:
          type: string
          description: Words left out
        attribute_ids:
          type: string
          description: Filter option applied
        sort_by:
          type: string
          description: Sort order
        page:
          type: integer
          description: Page of results
    SearchInformation:
      type: object
      properties:
        query_displayed:
          type: string
          description: Search text as Rakuten read it.
        total_results:
          type: integer
          description: Number of products Rakuten reports for the search.
        reachable_results:
          type: integer
          description: Number of those products Rakuten serves across its pages.
    OrganicResult:
      type: object
      required: [position, product_id, item_id, title, link, extracted_price, currency, seller, is_sponsored, is_used, has_variants, is_hometown_tax]
      properties:
        position:
          type: integer
          description: Position of the row on this page of results.
        product_id:
          type: string
          description: Shop code and item code from the product link, such as `qrshoji/3c-cs0013`.
        item_id:
          type: string
          description: Rakuten item number, unique within its shop.
        variant_id:
          type: string
          description: Id of the product variant the row shows.
        title:
          type: string
          description: Product title.
        link:
          type: string
          description: Product page on Rakuten.
        extracted_price:
          type: integer
          description: Price in yen, tax included.
        currency:
          type: string
          description: ISO 4217 code of the price currency.
        price_range:
          type: object
          description: Lowest and highest price across the product's variants.
          properties:
            min:
              type: integer
              description: Lowest price in yen.
            max:
              type: integer
              description: Highest price in yen.
        unit_price:
          type: string
          description: Price per unit as Rakuten shows it.
        shipping_cost:
          type: integer
          description: Shipping cost in yen, 0 when shipping is free.
        is_free_shipping:
          type: boolean
          description: Whether the product ships for free.
        delivery:
          type: string
          description: Delivery estimate as Rakuten shows it.
        points:
          type: integer
          description: Rakuten points the purchase earns.
        rating:
          type: number
          description: Average review score out of 5.
        reviews:
          type: integer
          description: Number of reviews.
        seller:
          type: object
          description: Shop selling the product.
          properties:
            id:
              type: string
              description: Rakuten shop id, the value `store_id` takes.
            code:
              type: string
              description: Shop code from the shop's link.
            name:
              type: string
              description: Shop name.
            link:
              type: string
              description: Shop page on Rakuten.
        category_ids:
          type: array
          description: Ids of the product's categories, from the top category down.
          items:
            type: string
        sale:
          type: object
          description: Sale period Rakuten lists for the product, which may not have started yet.
          properties:
            start:
              type: string
              format: date-time
              description: When the sale starts.
            end:
              type: string
              format: date-time
              description: When the sale ends.
            is_ongoing:
              type: boolean
              description: Whether the sale is on now rather than not started yet.
        thumbnail:
          type: string
          description: Product image.
        is_sponsored:
          type: boolean
          description: Whether the row is a sponsored listing.
        is_used:
          type: boolean
          description: Whether the product is used.
        has_variants:
          type: boolean
          description: Whether the product comes in several variants.
        is_hometown_tax:
          type: boolean
          description: Whether the product is a hometown tax donation gift.
    Category:
      type: object
      required: [id, name]
      properties:
        id:
          type: string
          description: Category id to send in `category_id`.
        name:
          type: string
          description: Category name.
        count:
          type: integer
          description: Number of products in the category for the search.
    Filter:
      type: object
      required: [name, parameter, options]
      properties:
        id:
          type: string
          description: Rakuten id of the filter.
        name:
          type: string
          description: Filter name.
        parameter:
          type: string
          description: Parameter that takes the filter's option values.
        options:
          type: array
          description: Choices the filter offers.
          items:
            $ref: '#/components/schemas/FilterOption'
    FilterOption:
      type: object
      required: [name, value, is_selected]
      properties:
        name:
          type: string
          description: Choice as Rakuten shows it.
        value:
          type: string
          description: Value to send in `attribute_ids` to apply the choice.
        count:
          type: integer
          description: Number of products with the choice.
        color:
          type: string
          description: Hex color of a color choice.
        is_selected:
          type: boolean
          description: Whether the search applies the choice.
    RelatedSearch:
      type: object
      required: [query, link]
      properties:
        query:
          type: string
          description: Suggested search text.
        link:
          type: string
          description: Rakuten search page for the suggestion.
    Pagination:
      type: object
      required: [current]
      properties:
        current:
          type: integer
          description: Current page.
        next:
          type: string
          description: Rakuten search page with the next products.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
