openapi: 3.0.0
info:
  title: Mercari Japan Search API
  description: |
    Search the listings on Mercari Japan, from individual sellers and from Mercari Shops.

    Each result carries its Mercari item id, title, link, price in yen, sale status, condition, category id and photos. Listings from individual sellers also carry the seller id and the shipping terms, and listings from Mercari Shops carry the shop. Brand, size, discount and auction details are returned where Mercari shows them.

    Titles, conditions, shipping methods, brands and sizes are text in Japanese, as Mercari prints them. Search by keyword, or leave `q` out and list a category, a brand, a seller or a shop. Mercari lists up to 120 listings a page and up to 100 pages a search.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Mercari Japan Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `mercari_jp_search`'
          schema:
            type: string
            enum: ["mercari_jp_search"]
        - name: q
          in: query
          required: false
          description: Search text, up to 500 characters. Required unless `category_id`, `brand_id`, `seller_id` or `shop_id` is set.
          schema:
            type: string
            maxLength: 500
        - name: sort_by
          in: query
          required: false
          description: Sorts the results. `newest` puts the latest listings first and `most_liked` the listings with the most likes. The order is Mercari's own, so a few listings can sit out of order, as they do on its page.
          schema:
            type: string
            enum: ["relevance", "newest", "price_low_to_high", "price_high_to_low", "most_liked"]
            default: "relevance"
        - name: item_status
          in: query
          required: false
          description: Keeps listings by sale status. `on_sale` keeps listings that can be bought, and `sold_out` keeps listings that are sold or in a transaction, as Mercari's own sold-out filter does. Without it both are returned.
          schema:
            type: string
            enum: ["on_sale", "sold_out"]
        - name: condition
          in: query
          required: false
          description: Item conditions to keep, comma-separated. Several conditions widen the results. Supported values are `new`, `like_new`, `good`, `fair`, `poor` and `bad`, Mercari's six conditions from best to worst.
          schema:
            type: string
            pattern: '^(new|like_new|good|fair|poor|bad)(,(new|like_new|good|fair|poor|bad))*$'
        - name: price_min
          in: query
          required: false
          description: Lowest price, in yen.
          schema:
            type: integer
            minimum: 1
            maximum: 9999999
        - name: price_max
          in: query
          required: false
          description: Highest price, in yen. It must not be lower than `price_min`.
          schema:
            type: integer
            minimum: 1
            maximum: 9999999
        - name: category_id
          in: query
          required: false
          description: Mercari category ids to search in, comma-separated, such as `701` or `701,702`. Several categories widen the results. Results carry their `category_id`. Up to 20 ids, each from 1 to 2147483647.
          schema:
            type: string
            pattern: '^[1-9]\d{0,9}(,[1-9]\d{0,9}){0,19}$'
        - name: brand_id
          in: query
          required: false
          description: Mercari brand id to keep, such as `7572` for Nintendo Switch. Results carry their `brand_id`. One id, from 1 to 2147483647.
          schema:
            type: integer
            minimum: 1
            maximum: 2147483647
        - name: seller_id
          in: query
          required: false
          description: Mercari seller id, to list one individual seller's listings. It is the `seller.id` of a result.
          schema:
            type: string
            pattern: '^[1-9]\d{0,18}$'
        - name: shop_id
          in: query
          required: false
          description: Mercari Shops id, to list one shop's listings. It is the `shop.id` of a result.
          schema:
            type: string
            pattern: '^[1-9A-HJ-NP-Za-km-z]{21,22}$'
        - name: seller_type
          in: query
          required: false
          description: Keeps listings from one kind of seller, `individual` for members or `shop` for Mercari Shops. Without it both are returned.
          schema:
            type: string
            enum: ["individual", "shop"]
        - name: is_free_shipping
          in: query
          required: false
          description: Set to `true` to keep listings whose price includes shipping. `false` applies no shipping filter.
          schema:
            type: boolean
        - name: page
          in: query
          required: false
          description: Page of results. Mercari lists up to 120 listings a page and stops at page 100. The last page is the one whose `pagination` has no `next`.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            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'
        organic_results:
          type: array
          description: Listings Mercari returns for the search, in Mercari's order.
          items:
            $ref: '#/components/schemas/OrganicResult'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Why the search returned no listings.
    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: "Mercari 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
        sort_by:
          type: string
          description: Sort order
        item_status:
          type: string
          description: Sale status kept
        condition:
          type: string
          description: Item conditions kept
        price_min:
          type: integer
          description: Lowest price
        price_max:
          type: integer
          description: Highest price
        category_id:
          type: string
          description: Categories searched in
        brand_id:
          type: string
          description: Brand kept
        seller_id:
          type: string
          description: Seller listed
        shop_id:
          type: string
          description: Shop listed
        seller_type:
          type: string
          description: Kind of seller kept
        is_free_shipping:
          type: boolean
          description: Whether only listings with shipping included were kept
        page:
          type: integer
          description: Page of results
    SearchInformation:
      type: object
      properties:
        total_results:
          type: integer
          description: Number of listings Mercari counts for the search, which it caps at 15000.
    OrganicResult:
      type: object
      required: [position, item_id, link]
      properties:
        position:
          type: integer
          description: Position of the listing on this page of results.
        item_id:
          type: string
          description: Mercari item id, the last part of the listing link.
        title:
          type: string
          description: Listing title, as the seller wrote it.
        link:
          type: string
          description: Listing page on Mercari.
        seller_type:
          type: string
          enum: ["individual", "shop"]
          description: Kind of seller, `individual` for a member or `shop` for Mercari Shops.
        status:
          type: string
          enum: ["on_sale", "trading", "sold_out"]
          description: Sale status, where `trading` is a sale still in progress.
        price:
          type: string
          description: Price as text, the yen sign and the amount with thousands separators (e.g., `¥3,399`).
        extracted_price:
          type: integer
          description: Numeric price in yen, which for an auction is the current price.
        currency:
          type: string
          description: ISO 4217 code of the price's currency.
        discount_percentage:
          type: integer
          description: Percentage off that Mercari advertises on the listing.
        condition:
          type: string
          description: Condition as Mercari prints it, in Japanese.
        condition_id:
          type: integer
          description: Mercari condition id, from 1 for new to 6 for bad.
        brand:
          type: string
          description: Brand as Mercari prints it.
        brand_id:
          type: integer
          description: Mercari brand id, which the `brand_id` parameter takes.
        category_id:
          type: integer
          description: Mercari category id, which the `category_id` parameter takes.
        size:
          type: string
          description: Size as Mercari prints it.
        is_free_shipping:
          type: boolean
          description: Whether the price includes shipping.
        shipping_method:
          type: string
          description: Shipping method as Mercari prints it, in Japanese.
        seller:
          $ref: '#/components/schemas/Seller'
        shop:
          $ref: '#/components/schemas/Shop'
        is_auction:
          type: boolean
          description: Whether the listing is sold by auction.
        auction:
          $ref: '#/components/schemas/Auction'
        thumbnail:
          type: string
          description: Listing photo.
        image:
          type: string
          description: Listing photo at full size.
        created_at:
          type: string
          format: date-time
          description: When the listing was created, in UTC.
        updated_at:
          type: string
          format: date-time
          description: When the listing was last updated, in UTC.
    Seller:
      type: object
      description: Member who sells the listing.
      required: [id]
      properties:
        id:
          type: string
          description: Mercari seller id, which the `seller_id` parameter takes.
        link:
          type: string
          description: Seller's profile on Mercari.
    Shop:
      type: object
      description: Mercari Shops store that sells the listing.
      required: [id]
      properties:
        id:
          type: string
          description: Mercari Shops id, which the `shop_id` parameter takes.
        name:
          type: string
          description: Shop name.
        link:
          type: string
          description: Shop's page on Mercari.
    Auction:
      type: object
      description: State of the auction when the search ran.
      properties:
        bids:
          type: integer
          description: Number of bids placed.
        extracted_highest_bid:
          type: integer
          description: Highest bid in yen.
        extracted_starting_price:
          type: integer
          description: Starting price in yen.
        ends_at:
          type: string
          format: date-time
          description: When the auction ends, in UTC.
    Pagination:
      type: object
      required: [current]
      properties:
        current:
          type: integer
          description: Current page.
        next:
          type: integer
          description: Next page, which is absent on the last page.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
