openapi: 3.0.0
info:
  title: TikTok Short Drama API
  description: |
    Retrieve the series listed on TikTok's Short Drama page: the full catalog, the latest releases, or the
    Trending and New rankings, for a country's catalog with titles in the language you choose. The full catalog
    can be filtered by setting, plot, story and release date.

    Each drama includes its title, synopsis, themes, episode count, total running time, total views, its labels
    (hot, new, free for a limited time), its first episode with that episode's engagement counts, and the creator
    who publishes it. Covers and video streams are not included.

    **Pagination**: pass a response's pagination.next_page_token as next_page_token to get the next page; the
    token carries the list it was issued for, so it can be sent on its own.

    **Cross-linking**: pass first_episode.link as url to the TikTok Video and TikTok Comments APIs, and
    author.username to the TikTok Profile API.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: TikTok Short Drama
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["tiktok_short_drama"]
            default: "tiktok_short_drama"
        - name: tab
          in: query
          required: false
          description: List to return. `all` is the full catalog, `latest` the newest releases, `trending_ranking` and `new_ranking` the two Rankings lists.
          schema:
            type: string
            enum: ["all", "latest", "trending_ranking", "new_ranking"]
            default: "all"
        - name: setting
          in: query
          required: false
          description: Only dramas with this setting. Works only with tab `all`.
          schema:
            type: string
            enum: ["fantasy", "cultivation", "celebrity", "workplace", "werewolf", "martial_arts", "survival", "vampire", "high_society", "urban_life", "royal_court", "rural_life", "aristocracy", "system_quests", "rags_to_riches", "post_apocalyptic", "infinite_worlds"]
        - name: plot
          in: query
          required: false
          description: Only dramas with this plot. Works only with tab `all`.
          schema:
            type: string
            enum: ["tangled_romance", "revenge", "betrayal", "married_life", "adventure", "mystery", "sudden_wealth", "action", "crime", "sports", "mansion_intrigue", "spy", "courtroom", "medical", "business_war", "slice_of_life", "political_intrigue", "body_swap", "possessive_love", "family_and_ethics", "regretful_chase", "substitute_lover", "birth_swap", "anti_hustle", "everyday_romance", "family_dispute", "skill_competition"]
        - name: story
          in: query
          required: false
          description: Only dramas with this story type. Works only with tab `all`.
          schema:
            type: string
            enum: ["second_chance", "body_double", "lucky_baby", "group_favorite", "elite", "power_couple", "boss_lady", "secret_identity", "transmigration", "mind_reading", "glorious_return", "hidden_master", "master_descends", "female_growth", "sarcastic_and_shrewd", "always_lucky", "legacy_awakened", "infinite_worlds", "aloof"]
        - name: released_within
          in: query
          required: false
          description: Only dramas released in the last 7 or 30 days. Works only with tab `all`.
          schema:
            type: string
            enum: ["last_7_days", "last_30_days"]
        - name: country
          in: query
          required: false
          description: Two-letter country code of the catalog to return
          schema:
            type: string
            enum: ["US", "GB", "CA", "AU", "NZ", "IE", "DE", "FR", "ES", "IT", "PT", "NL", "BE", "AT", "CH", "SE", "NO", "DK", "FI", "PL", "CZ", "RO", "HU", "GR", "TR", "IL", "AE", "SA", "EG", "MA", "BR", "MX", "AR", "CO", "CL", "PE", "JP", "KR", "TW", "PH", "ID", "TH", "VN", "MY", "SG", "PK", "BD", "NG", "ZA", "KE", "UA", "KZ"]
            default: "US"
        - name: language
          in: query
          required: false
          description: Language of the drama titles and synopses
          schema:
            type: string
            enum: ["en", "sq", "ar", "az", "bn", "bg", "my", "ca", "ceb", "zh-cn", "zh-tw", "hr", "cs", "da", "nl", "et", "fil", "fi", "fr", "de", "el", "he", "hi", "hu", "is", "id", "ga", "it", "ja", "jv", "kk", "km", "ko", "lv", "lt", "ms", "nb", "pl", "pt", "ro", "ru", "sk", "sl", "es", "sw", "sv", "th", "tr", "uk", "ur", "uz", "vi"]
            default: "en"
        - name: num
          in: query
          required: false
          description: Number of dramas per page
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 20
        - name: next_page_token
          in: query
          required: false
          description: Token for the next page, from a previous response's pagination.next_page_token. It carries the list it was issued for, so the other parameters can be left out.
          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 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
      required: [search_metadata, search_parameters]
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        dramas:
          type: array
          description: Dramas in the list, in the order TikTok returns them
          items:
            $ref: '#/components/schemas/Drama'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Message returned instead of dramas when the list is empty, such as for filters no drama matches

    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 URL for this search
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results

    SearchParameters:
      type: object
      required: [engine, tab, country, language]
      properties:
        engine:
          type: string
          description: Search engine identifier
        tab:
          type: string
          description: List returned
        setting:
          type: string
          description: Setting filter applied
        plot:
          type: string
          description: Plot filter applied
        story:
          type: string
          description: Story filter applied
        released_within:
          type: string
          description: Release date filter applied
        country:
          type: string
          description: Country code of the catalog returned
        language:
          type: string
          description: Language of the titles returned
        num:
          type: integer
          description: Number of dramas requested per page
        next_page_token:
          type: string
          description: Page token sent

    SearchInformation:
      type: object
      properties:
        ranking_updated_at:
          type: string
          format: date-time
          description: Time TikTok last updated the ranking, for the two Rankings tabs

    Drama:
      type: object
      required: [position, id, title, description, episodes, duration, views, first_episode, author]
      properties:
        position:
          type: integer
          description: Position of the drama on the page, starting at 1; in the Rankings tabs, its rank, continuing across pages
        id:
          type: string
          description: TikTok's identifier of the drama
        title:
          type: string
          description: Title of the drama, in the requested language when TikTok has a translation
        description:
          type: string
          description: Synopsis of the drama
        themes:
          type: array
          items:
            type: string
          description: Themes TikTok tags the drama with
        episodes:
          type: integer
          description: Number of episodes
        duration:
          type: integer
          description: Total running time of all episodes, in seconds
        views:
          type: integer
          description: Total views across all episodes
        is_hot:
          type: boolean
          description: Whether TikTok labels the drama as hot
        is_new:
          type: boolean
          description: Whether TikTok labels the drama as new
        is_limited_free:
          type: boolean
          description: Whether the drama is free to watch for a limited time
        first_episode:
          $ref: '#/components/schemas/FirstEpisode'
        author:
          $ref: '#/components/schemas/Author'

    FirstEpisode:
      type: object
      required: [id, link, iso_date, duration, views, likes, comments, shares, saves]
      properties:
        id:
          type: string
          description: TikTok's identifier of the episode video
        link:
          type: string
          description: URL of the episode on TikTok
        iso_date:
          type: string
          format: date-time
          description: Time the episode was published
        duration:
          type: integer
          description: Length of the episode in seconds
        views:
          type: integer
          description: Number of views of the episode
        likes:
          type: integer
          description: Number of likes of the episode
        comments:
          type: integer
          description: Number of comments on the episode
        shares:
          type: integer
          description: Number of shares of the episode
        saves:
          type: integer
          description: Number of times the episode was saved

    Author:
      type: object
      required: [id, sec_uid, username, link, name, avatar, avatar_hd, followers, likes]
      properties:
        id:
          type: string
          description: TikTok's identifier of the creator
        sec_uid:
          type: string
          description: TikTok's secure identifier of the creator
        username:
          type: string
          description: Username of the creator
        link:
          type: string
          description: URL of the creator's TikTok profile
        name:
          type: string
          description: Display name of the creator
        bio:
          type: string
          description: Bio on the creator's profile
        avatar:
          type: string
          description: URL of the creator's profile picture
        avatar_hd:
          type: string
          description: URL of the creator's profile picture in high resolution
        followers:
          type: integer
          description: Number of followers of the creator
        likes:
          type: integer
          description: Total likes across the creator's videos

    Pagination:
      type: object
      required: [has_more, next_page_token]
      properties:
        has_more:
          type: boolean
          description: Whether another page is available
        next_page_token:
          type: string
          description: Token to pass as next_page_token for the next page

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