openapi: 3.0.0
info:
  title: TikTok Shop Product API
  description: |
    The TikTok Shop Product API returns one product from TikTok Shop's US store, or with `country` its UK, Indonesian, Japanese, Mexican, Malaysian, Philippine, Singaporean, Thai or Vietnamese store:
    its title, images and description, prices in the store's currency with any discount, rating, review count and units sold, the selling shop, specifications,
    badges, and every variant with its own price and stock.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: TikTok Shop Product
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["tiktok_shop_product"]
            default: "tiktok_shop_product"
        - name: product_id
          in: query
          required: true
          description: TikTok Shop product ID (e.g., "1732503089769320788"), as returned in organic_results[].product_id by the TikTok Shop Search API. The product page URL is also accepted.
          schema:
            type: string
        - name: country
          in: query
          required: false
          description: Two-letter code of the country of the TikTok Shop store the product is sold in. When omitted, a product page URL of a supported store sets it, and a product ID alone defaults to US.
          schema:
            type: string
            enum: ["US", "GB", "ID", "JP", "MX", "MY", "PH", "SG", "TH", "VN"]
      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, or TikTok Shop answered but returned nothing usable. The body is a bare
            {"error": ...} rather than a search response, and the search is not billed.
          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'
        error:
          type: string
          description: Error message when TikTok Shop has no product with this ID
    Product:
      type: object
      required: [product_id, title, link, price, extracted_price, currency, reviews, items_sold, seller, images, variants]
      properties:
        product_id:
          type: string
          description: TikTok Shop's identifier of the product
        title:
          type: string
          description: Product title
        link:
          type: string
          description: URL of the product page on TikTok Shop
        price:
          type: string
          description: Price as displayed, with a "From" prefix when variants differ in price (e.g., "$23.40", "From $7.99")
        extracted_price:
          type: number
          description: Price as a number, the lowest variant price when price has a "From" prefix
        original_price:
          type: string
          description: Crossed-out price as displayed
        extracted_original_price:
          type: number
          description: Crossed-out price as a number
        discount_percentage:
          type: integer
          description: Discount off the crossed-out price, in percent
        currency:
          type: string
          description: Currency code of the prices (e.g., "USD", "GBP")
        rating:
          type: number
          description: Average star rating out of 5
        reviews:
          type: integer
          description: Number of reviews
        items_sold:
          type: integer
          description: Number of units sold
        is_out_of_stock:
          type: boolean
          description: Whether TikTok Shop shows the product as out of stock or removed
        seller:
          $ref: '#/components/schemas/Seller'
        badges:
          type: array
          items:
            type: string
          description: Labels shown on the product page (e.g., "Free shipping")
        description:
          type: string
          description: Product description as text, one paragraph or bullet point per line
        description_images:
          type: array
          items:
            type: string
          description: URLs of the images in the product description
        images:
          type: array
          items:
            type: string
          description: URLs of the product images
        specifications:
          type: array
          items:
            $ref: '#/components/schemas/Specification'
        variants:
          type: array
          items:
            $ref: '#/components/schemas/Variant'
    Seller:
      type: object
      required: [id, name]
      properties:
        id:
          type: string
          description: TikTok Shop's identifier of the shop
        name:
          type: string
          description: Shop name
        thumbnail:
          type: string
          description: URL of the shop logo
        business_name:
          type: string
          description: Legal name of the business behind the shop
        business_address:
          type: string
          description: Address of the business behind the shop
    Specification:
      type: object
      required: [name, value]
      properties:
        name:
          type: string
          description: Name of the specification (e.g., "Material")
        value:
          type: string
          description: Value of the specification, several values separated by commas
    Variant:
      type: object
      required: [sku_id, options, price, extracted_price, currency]
      properties:
        sku_id:
          type: string
          description: TikTok Shop's identifier of the variant
        options:
          type: array
          items:
            $ref: '#/components/schemas/VariantOption'
        price:
          type: string
          description: Price of the variant as displayed
        extracted_price:
          type: number
          description: Price of the variant as a number
        original_price:
          type: string
          description: Crossed-out price of the variant as displayed
        extracted_original_price:
          type: number
          description: Crossed-out price of the variant as a number
        discount_percentage:
          type: integer
          description: Discount off the variant's crossed-out price, in percent
        currency:
          type: string
          description: Currency code of the variant prices (e.g., "USD", "GBP")
        stock:
          type: integer
          description: Number of units available, 0 when the variant is sold out
        thumbnail:
          type: string
          description: URL of the image of the variant's option value
    VariantOption:
      type: object
      required: [name, value]
      properties:
        name:
          type: string
          description: Name of the option (e.g., "Color")
        value:
          type: string
          description: Value of the option for this variant (e.g., "Black")
    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: TikTok Shop URL of the product 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: Search engine identifier
        product_id:
          type: string
          description: ID of the product requested
        country:
          type: string
          description: Country code of the store the product was read from
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
