# TikTok Scraper (`xtdata/tiktok-scraper`) Actor

Get TikTok data fast! Real-time, authentic data. No pre-built databases! Track trending content, popular music videos, top users videos.

- **URL**: https://apify.com/xtdata/tiktok-scraper.md
- **Developed by:** [xtdata](https://apify.com/xtdata) (community)
- **Categories:** Social media, Videos, Lead generation
- **Features:** Limited permissions
- **Stats:** 257 total users, 9 monthly users, 82.5% runs succeeded, 11 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.30 / 1,000 video scrapeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### TikTok Scraper (Pay per result)

[Apify Actor](about:sanitized)(https://apify.com/xtdata/tiktok-scraper)

Real-time, authentic data. No pre-built databases. Scrape TikTok videos quickly and efficiently based on your specific needs. This actor supports scraping by search
keywords, trending videos, hashtags, user profiles, and music. **You only pay for the results you get!**

### Features

- **Versatile Scraping Types:** Choose from `SEARCH`, `TREND`, `HASHTAG`, `USER`, and `MUSIC` to target the exact TikTok
  content you need.
- **Region Targeting:** For `TREND` and `SEARCH` scraping, specify a target country to get localized results.
- **Keyword-Based Search:** Find relevant videos using specific keywords for `SEARCH` scraping.
- **URL-Based Scraping:** Easily scrape videos by providing the URL for hashtags, users, or music.
- **Result Limiting:** Set a `maxItems` limit to control the number of videos scraped per run, helping you manage costs.
- **Unlimited Scraping (with caution):** Opt for `isUnlimited` to attempt to scrape all available videos, but be aware
  this might be slower and could involve captcha challenges.
- **Search Result Filtering:** For `SEARCH` scraping, sort results by relevance, most liked, or most recent, and filter
  by publish time.
- **Pay Per Result Pricing:** Only pay for the valid video data extracted, offering a cost-effective solution for your
  TikTok data needs.

### Input

You can configure the actor with the following input parameters:

```json
{
  "type": "SEARCH",
  "region": "GB",
  "url": "",
  "keywords": [
    "baby",
    "fyp",
    "trend",
    "hot"
  ],
  "maxItems": 20,
  "isUnlimited": false,
  "sortType": 0,
  "publishTime": "ALL_TIME"
}
```

Here's a detailed explanation of each field:

- **`type` (String, Required):** The type of scraping to perform. Available options are:
  - `SEARCH`: Scrape videos based on keywords.
  - `TREND`: Scrape trending videos in a specific region.
  - `HASHTAG`: Scrape videos associated with a specific hashtag URL.
  - `USER`: Scrape videos from a specific user profile URL.
  - `MUSIC`: Scrape videos using a specific music track URL.
- **`region` (String, Optional):** The 2-character region code for the target country. This is applicable for `TREND`
  and `SEARCH` scraping. See the full list of available region codes in the actor's input schema. Default value is `GB`.
- **`url` (String, Optional):** The TikTok URL to scrape from. This is used when `type` is set to `HASHTAG`, `USER`,
  or `MUSIC`.
- **`keywords` (Array of Strings, Optional):** An array of keywords to use for `SEARCH` scraping.
- **`maxItems` (Number, Optional):** A soft limit on the maximum number of videos to scrape. The actor will stop when
  this limit is reached or exceeded. Default value is `20`.
- **`isUnlimited` (Boolean, Optional):** If set to `true`, the actor will attempt to scrape all possible results. This
  might be slower and could require bypassing captchas. Default value is `false`.
- **`sortType` (Number, Optional):** The sorting order for `SEARCH` results. Available options are:
  - `0`: Relevance (default)
  - `1`: Most liked
  - `2`: Most recent
- **`publishTime` (String, Optional):** Filter `SEARCH` results by their publish time. Available options
  are: `ALL_TIME` (default), `YESTERDAY`, `WEEK`, `MONTH`, `THREE_MONTH`, `SIX_MONTH`.

### Output

The actor outputs a dataset of TikTok video objects. Each object is a JSON dictionary containing a wealth of information
about the scraped video. Here's an example of the structure (note that this is a partial view and the full output can be
quite extensive):

```json
[
  {
    "added_sound_music_info": {
      "album": "",
      "artists":,
      "audition_duration": 54,
      "author": "VTV Giai Tri Official",
      "author_deleted": false,
      "author_position": null,
      "avatar_medium": {
        "height": 720,
        "uri": "tos-alisg-avt-0068/e58bf19abf1c1badb25233ebb772283d",
        "url_list": [
          "[https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/e58bf19abf1c1badb25233ebb772283d.webp?x-expires=1683439200&x-signature=Nq4qV8EaKGCuXuy1BNauD7klTH0%3D](https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/e58bf19abf1c1badb25233ebb772283d.webp?x-expires=1683439200&x-signature=Nq4qV8EaKGCuXuy1BNauD7klTH0%3D)",
          "[https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/e58bf19abf1c1badb25233ebb772283d.jpeg?x-expires=1683439200&x-signature=x8tIQWWiY3wzNiefIUjhh8g9q9o%3D](https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/e58bf19abf1c1badb25233ebb772283d.jpeg?x-expires=1683439200&x-signature=x8tIQWWiY3wzNiefIUjhh8g9q9o%3D)"
        ],
        "width": 720
      },
      // ... more fields related to the music
      "id": 7229168247013182210,
      "id_str": "7229168247013182210",
      "title": "original sound - vtvgiaitriofficial",
      // ... more music-related fields
      "video_duration": 54
    },
    "anchors": null,
    "anchors_extras": "",
    "author": {
      "accept_private_policy": false,
      "account_labels": null,
      // ... many fields related to the author's profile
      "uid": "6812490744957256705",
      "unique_id": "vtvgiaitriofficial",
      "signature": "Mời các bạn tải ứng dụng VTV GiảiTrí để xem trọn bộ phim hay độc quyền",
      // ... more author-related fields
      "youtube_channel_id": "UCuJ5k3GndbHnXLYyiIR6Z8Q",
      "youtube_channel_title": "VTV Giải Trí Official"
    },
    "author_user_id": 6812490744957256705,
    "aweme_acl": {
      "download_general": {
        "code": 1,
        "extra": "101",
        "mute": false,
        "show_type": 0,
        "transcode": 1
      }
      // ... more access control list fields
    },
    "aweme_id": "7229167805625847041",
    "aweme_type": 0,
    "behind_the_song_music_ids": null,
    "behind_the_song_video_music_ids": null,
    "bodydance_score": 0,
    "branded_content_accounts": null,
    "cc_template_info": {
      "author_name": "",
      "clip_count": 0,
      "desc": "",
      "duration_milliseconds": 0,
      "related_music_id": "",
      "template_id": ""
    },
    "cha_list": [
      {
        "author": {
          // ... author info for the challenge
        },
        "banner_list": null,
        "cha_attrs": null,
        "cha_name": "cuocdoivandepsao",
        "cid": "1670903934915585",
        // ... more challenge-related fields
        "view_count": 0
      }
    ],
    "challenge_position": null,
    "cmt_swt": false,
    "collect_stat": 0,
    "commerce_config_data": null,
    "commerce_info": {
      "adv_promotable": false,
      "auction_ad_invited": false,
      "with_comment_filter_words": false
    },
    "content_desc": "",
    "content_desc_extra":,
    "cover_labels": null,
    "create_time": 1683171893,
    "desc": "Cô chủ trọ cho thuê căn phòng hết nước chấm thật #Cuocdoivandepsao",
    "desc_language": "vi",
    "disable_search_trending_bar": false,
    "distance": "",
    "distribute_type": 1,
    "follow_up_publish_from_id": 0,
    "geofencing": null,
    "geofencing_regions": null,
    "green_screen_materials": null,
    "group_id": "7228596161530039558",
    "group_id_list": {
      "GroupdIdList0": null,
      "GroupdIdList1": null
    },
    "has_vs_entry": false,
    "have_dashboard": false,
    "hybrid_label": null,
    "image_infos": null,
    "interact_permission": {
      "allow_adding_to_story": 1,
      "allow_create_sticker": {
        "status": 0
      },
      "duet": 0,
      "duet_privacy_setting": 0,
      "stitch": 0,
      "stitch_privacy_setting": 0,
      "upvote": 0
    },
    "interaction_stickers": null,
    "is_ads": false,
    "is_description_translatable": true,
    "is_hash_tag": 1,
    "is_on_this_day": 0,
    "is_pgcshow": false,
    "is_preview": 0,
    "is_relieve": false,
    "is_text_sticker_translatable": false,
    "is_top": 0,
    "is_vr": false,
    "item_comment_settings": 0,
    "item_duet": 0,
    "item_react": 0,
    "item_stitch": 0,
    "label_top": {
      "height": 720,
      "uri": "tiktok-obj/1598708589477025.PNG",
      "url_list": [
        "[https://p16-sg.tiktokcdn.com/obj/tiktok-obj/1598708589477025.PNG](https://p16-sg.tiktokcdn.com/obj/tiktok-obj/1598708589477025.PNG)"
      ],
      "width": 720
    },
    "label_top_text": null,
    "long_video": null,
    "mask_infos":,
    "misc_info": "{}",
    "muf_comment_info_v2": null,
    "music": {
      "album": "",
      "artists":
      // ... (same structure as added_sound_music_info)
    },
    "music_begin_time_in_ms": 0,
    "music_selected_from": "",
    "music_title_style": 1,
    "need_trim_step": false,
    "need_vs_entry": false,
    "nickname_position": null,
    "no_selected_music": false,
    "origin_comment_ids": null,
    "playlist_blocked": false,
    "playlist_info": {
      "index": 6,
      "item_total": 43,
      "mix_id": "7220755092813777691",
      "name": "Cuộc đời vẫn đẹp sao"
    },
    "poi_re_tag_signal": 0,
    "position": null,
    "prevent_download": false,
    "products_info": null,
    "question_list": null,
    "rate": 12,
    "reference_tts_voice_ids": null,
    "reference_voice_filter_ids": null,
    "region": "VN",
    "risk_infos": {
      "content": "",
      "risk_sink": false,
      "type": 0,
      "vote": false,
      "warn": false
    },
    "search_highlight": null,
    "share_info": {
      "bool_persist": 0,
      "now_invitation_card_image_urls": null,
      "share_desc": "Check out VTV Giai Tri Official's video! #TikTok",
      "share_desc_info": "TikTok: Make Every Second CountCheck out VTV Giai Tri Official’s video! #TikTok > ",
      "share_link_desc": "",
      "share_quote": "",
      "share_signature_desc": "",
      "share_signature_url": "",
      "share_title": "Check out VTV Giai Tri Official’s video! #TikTok > ",
      "share_title_myself": "",
      "share_title_other": "",
      "share_url": "[https://www.tiktok.com/@vtvgiaitriofficial/video/7229167805625847041?_r=1&u_code=0&preview_pb=0&sharer_language=en&_d=e7km4e8ee8j7d2&share_item_id=7229167805625847041&source=h5_m](https://www.tiktok.com/@vtvgiaitriofficial/video/7229167805625847041?_r=1&u_code=0&preview_pb=0&sharer_language=en&_d=e7km4e8ee8j7d2&share_item_id=7229167805625847041&source=h5_m)",
      "whatsapp_desc": "Download TikTok and watch more fun videos:"
    },
    "share_url": "[https://www.tiktok.com/@vtvgiaitriofficial/video/7229167805625847041?_r=1&u_code=0&preview_pb=0&sharer_language=en&_d=e7km4e8ee8j7d2&share_item_id=7229167805625847041&source=h5_m](https://www.tiktok.com/@vtvgiaitriofficial/video/7229167805625847041?_r=1&u_code=0&preview_pb=0&sharer_language=en&_d=e7km4e8ee8j7d2&share_item_id=7229167805625847041&source=h5_m)",
    "sort_label": "",
    "statistics": {
      "aweme_id": "7229167805625847041",
      "collect_count": 743,
      "comment_count": 183,
      "digg_count": 25006,
      "download_count": 0,
      "forward_count": 0,
      "lose_comment_count": 0,
      "lose_count": 0,
      "play_count": 585709,
      "share_count": 492,
      "whatsapp_share_count": 0
    },
    "status": {
      "allow_comment": true,
      "allow_share": true,
      "aweme_id": "7229167805625847041",
      "download_status": 0,
      "in_reviewing": false,
      "is_delete": false,
      "is_prohibited": false,
      "private_status": 0,
      "review_result": {
        "review_status": 0
      },
      "reviewed": 1,
      "self_see": false
    },
    "text_extra": [
      {
        "end": 66,
        "hashtag_id": "1670903934915585",
        "hashtag_name": "cuocdoivandepsao",
        "is_commerce": false,
        "sec_uid": "",
        "start": 49,
        "type": 1,
        "user_id": ""
      }
    ],
    "text_sticker_major_lang": "un",
    "tts_voice_ids": null,
    "uniqid_position": null,
    "user_digged": 0,
    "video": {
      "CoverTsp": 47,
      "ai_dynamic_cover": {
        "uri": "tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895",
        "url_list": [
          "[https://p16-sign-sg.tiktokcdn.com/obj/tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895?x-expires=1683439200&x-signature=8Dfb9ZLKsy0h2BMmAKuEOpwyl7w%3D&s=CHALLENGE_AWEME&se=false&sh=&sc=dynamic_cover&l=20230506060531760EDB96FF74C50AB8A9](https://p16-sign-sg.tiktokcdn.com/obj/tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895?x-expires=1683439200&x-signature=8Dfb9ZLKsy0h2BMmAKuEOpwyl7w%3D&s=CHALLENGE_AWEME&se=false&sh=&sc=dynamic_cover&l=20230506060531760EDB96FF74C50AB8A9)"
        ]
      },
      "ai_dynamic_cover_bak": {
        "uri": "tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895",
        "url_list": [
          "[https://p16-sign-sg.tiktokcdn.com/obj/tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895?x-expires=1683439200&x-signature=8Dfb9ZLKsy0h2BMmAKuEOpwyl7w%3D&s=CHALLENGE_AWEME&se=false&sh=&sc=dynamic_cover&l=20230506060531760EDB96FF74C50AB8A9](https://p16-sign-sg.tiktokcdn.com/obj/tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895?x-expires=1683439200&x-signature=8Dfb9ZLKsy0h2BMmAKuEOpwyl7w%3D&s=CHALLENGE_AWEME&se=false&sh=&sc=dynamic_cover&l=20230506060531760EDB96FF74C50AB8A9)"
        ]
      },
      "animated_cover": {
        "uri": "tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895",
        "url_list": [
          "[https://p16-sign-sg.tiktokcdn.com/obj/tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895?x-expires=1683439200&x-signature=8Dfb9ZLKsy0h2BMmAKuEOpwyl7w%3D&s=CHALLENGE_AWEME&se=false&sh=&sc=dynamic_cover&l=20230506060531760EDB96FF74C50AB8A9](https://p16-sign-sg.tiktokcdn.com/obj/tos-alisg-p-0037/ad27d3bd0b00480d860c9e22f87b3ac5_1683171895?x-expires=1683439200&x-signature=8Dfb9ZLKsy0h2BMmAKuEOpwyl7w%3D&s=CHALLENGE_AWEME&se=false&sh=&sc=dynamic_cover&l=20230506060531760EDB96FF74C50AB8A9)"
        ]
      },
      "big_thumbs":,
      "bit_rate": [
        {
          "HDR_bit": "",
          "HDR_type": "",
          "bit_rate": 720348,
          "dub_infos": null,
          "gear_name": "adapt_540_1",
          "is_bytevc1": 1,
          "play_addr": {
            "data_size": 4919529,
            "file_cs": "c:0-46577-c445",
            "file_hash": "9728438cd1b5d434a4f2406088dfcb11",
            "height": 1024,
            "uri": "v10025g50000ch9ik0jc77ub16qqnnjg",
            "url_key": "v10025g50000ch9ik0jc77ub16qqnnjg_bytevc1_540p_720348",
            "url_list": [
              "[https://v19.tiktokcdn-us.com/422f47cb49d0e1ec92bc607815c11cfb/645642c1/video/tos/alisg/tos-alisg-pve-0037/oQRhWKrsICLBo5KA3TBzNAnKUBAfQsZwEpxyEb/?a=1233&ch=0&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=1406&bt=703&cs=2&ds=6&ft=kLx3-yygZGf0PD1.cYyXg9wa5FdavEeC~&mime_type=video_mp4&qs=11&rc=O2k5PGc2NWk7O2g0Zzc7M0BpanF0OWU6ZjNsazMzODgzNEBeLmIyLTQ2NmAxMy40Xl40YSNna24ucjRnaDZgLS1kLy1zcw%3D%3D&l=20230506060531760EDB96FF74C50AB8A9](https://v19.tiktokcdn-us.com/422f47cb49d0e1ec92bc607815c11cfb/645642c1/video/tos/alisg/tos-alisg-pve-0037/oQRhWKrsICLBo5KA3TBzNAnKUBAfQsZwEpxyEb/?a=1233&ch=0&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=1406&bt=703&cs=2&ds=6&ft=kLx3-yygZGf0PD1.cYyXg9wa5FdavEeC~&mime_type=video_mp4&qs=11&rc=O2k5PGc2NWk7O2g0Zzc7M0BpanF0OWU6ZjNsazMzODgzNEBeLmIyLTQ2NmAxMy40Xl40YSNna24ucjRnaDZgLS1kLy1zcw%3D%3D&l=20230506060531760EDB96FF74C50AB8A9)",
              "[https://v16m.tiktokcdn-us.com/ea4a3ce313ed5bc55ba0850bad2aa0af/645642c1/video/tos/alisg/tos-alisg-pve-0037/oQRhWKrsICLBo5KA3TBzNAnKUBAfQsZwEpxyEb/?a=1233&ch=0&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=1406&bt=703&cs=2&ds=6&ft=kLx3-yygZGf0PD1.cYyXg9wa5FdavEeC~&mime_type=video_mp4&qs=11&rc=O2k5PGc2NWk7O2g0Zzc7M0BpanF0OWU6ZjNsazMzODgzNEBeLmIyLTQ2NmAxMy40Xl40YSNna24ucjRnaDZgLS1kLy1zcw%3D%3D&l=20230506060531760EDB96FF74C50AB8A9](https://v16m.tiktokcdn-us.com/ea4a3ce313ed5bc55ba0850bad2aa0af/645642c1/video/tos/alisg/tos-alisg-pve-0037/oQRhWKrsICLBo5KA3TBzNAnKUBAfQsZwEpxyEb/?a=1233&ch=0&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=1406&bt=703&cs=2&ds=6&ft=kLx3-yygZGf0PD1.cYyXg9wa5FdavEeC~&mime_type=video_mp4&qs=11&rc=O2k5PGc2NWk7O2g0Zzc7M0BpanF0OWU6ZjNsazMzODgzNEBeLmIyLTQ2NmAxMy40Xl40YSNna24ucjRnaDZgLS1kLy1zcw%3D%3D&l=20230506060531760EDB96FF74C50AB8A9)",
              "[https://api16-normal-useast5.us.tiktokv.com/aweme/v1/play/?video_id=v10025g50000ch9ik0jc77ub16qqnnjg&line=0&is_play_url=1&source=PackSourceEnum_CHALLENGE_AWEME&file_id=70a8a47d116e48c89f92730d59e61fa8](https://api16-normal-useast5.us.tiktokv.com/aweme/v1/play/?video_id=v10025g50000ch9ik0jc77ub16qqnnjg&line=0&is_play_url=1&source=PackSourceEnum_CHALLENGE_AWEME&file_id=70a8a47d116e48c89f92730d59e61fa8)"
            ],
            "width": 576
          },
          "quality_type": 28
        }
        // ... more bit rate information
      ],
      "cdn_url_expired": 0,
      "cla_info": {
        "caption_infos": [
          {
// ... caption information
```

**Key takeaways from the example output:**

- The output is a list of dictionaries (JSON objects).
- Each video object contains a wide array of nested information.
- You'll find details about the music used (`added_sound_music_info` and `music`).
- Comprehensive information about the video author is available under the `author` key.
- The `aweme_id` uniquely identifies the video.
- Information about challenges associated with the video is in the `cha_list`.
- The main video description is in the `desc` field.
- The `statistics` field provides counts for likes, comments, shares, plays, etc.
- The actual video URLs in different resolutions and formats are within the nested `video` field, specifically
  under `bit_rate` and `play_addr`.
- Hashtags used in the description are available in the `text_extra` array.

**Pricing:** You will be charged based on the number of video results successfully extracted. Please refer to
the [Apify pricing page](https://apify.com/pricing) for detailed information on the cost per result for this actor.

### How to Use This Actor

1. Go to the [TikTok Scraper](https://apify.com/xtdata/tiktok-scraper) page on the Apify platform.
2. Click the **"Try for free"** button.
3. Configure the input parameters according to your scraping needs. For example, to scrape trending videos in the US,
   set `type` to `TREND` and `region` to `US`.
4. Click the **"Start"** button to run the actor.
5. Once the actor has finished running, navigate to the **"Dataset"** tab to view and download your results in various
   formats (JSON, CSV, etc.).

### Example Usage

To scrape the top 50 most recent videos with the keyword "cat":

```json
{
  "type": "SEARCH",
  "keywords": [
    "cat"
  ],
  "sortType": 2,
  "maxItems": 50
}
```

To scrape all videos from the user "@tiktok":

```json
{
  "type": "USER",
  "url": "[https://www.tiktok.com/@tiktok](https://www.tiktok.com/@tiktok)",
  "isUnlimited": true
}
```

### Support and Contact

If you have any questions or need assistance, please don't hesitate to contact the developer or the Apify support team.

| [🎹️ Fast TikTok API](https://apify.com/novi/fast-tiktok-api)      | [📹️ TikTok Trend API](https://apify.com/novi/tiktok-trend-api)         | [🔍️ TikTok Search API](https://apify.com/novi/tiktok-search-api)             |
|:-------------------------------------------------------------------|:------------------------------------------------------------------------|:------------------------------------------------------------------------------|
| [🧛️ TikTok User API](https://apify.com/novi/tiktok-user-api)      | [🧛️ TikTok User Info API](https://apify.com/novi/tiktok-user-info-api) | [#️ TikTok Hashtag API](https://apify.com/novi/tiktok-hashtag-api)            |
| [🛍️ TikTok Shop API](https://apify.com/novi/tiktok-shop-scraper)  | [👤️ TikTok Followers API](https://apify.com/novi/tiktok-followers-api) | [⚡️ TikTok Scraper (pay-per-result)](https://apify.com/xtdata/tiktok-scraper) |
| [💬 TikTok Comment API](https://apify.com/novi/tiktok-comment-api) | [🎶 TikTok Music API](https://apify.com/novi/tiktok-sound-api)          | [🎶 TikTok Music Trend API](https://apify.com/novi/tiktok-music-trend-api)    |

# Changelog

This Actor's version history is a separate document: https://apify.com/xtdata/tiktok-scraper/changelog.md

# Actor input Schema

## `type` (type: `string`):

Scrapping Type: SEARCH, TREND, HASHTAG, USER, MUSIC

## `region` (type: `string`):

Please fill 2 characters region code. Ex: US

## `url` (type: `string`):

URL correspond to type. Use when Type is HASHTAG, USER, MUSIC

## `keywords` (type: `array`):

Keyword (can contain space). For SEARCH

## `maxItems` (type: `integer`):

Soft limit of result. If actual result size >= limit. The scraper will stop.

## `isUnlimited` (type: `boolean`):

Get all if possible. This feature will slowdown your actor because it need to bypass TikTok's captcha

## `sortType` (type: `integer`):

Sort Type. Use when Type is SEARCH. 0: Relevance. 1: Most liked. 2: Most recent

## `publishTime` (type: `string`):

Sort Type. Use when Type is SEARCH.

## Actor input object example

```json
{
  "type": "SEARCH",
  "region": "GB",
  "url": "",
  "keywords": [
    "baby",
    "fyp",
    "trend",
    "hot"
  ],
  "maxItems": 20,
  "isUnlimited": false,
  "sortType": 0,
  "publishTime": "ALL_TIME"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "region": "GB",
    "keywords": [
        "baby",
        "fyp",
        "trend",
        "hot"
    ],
    "maxItems": 20,
    "sortType": 0,
    "publishTime": "ALL_TIME"
};

// Run the Actor and wait for it to finish
const run = await client.actor("xtdata/tiktok-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "region": "GB",
    "keywords": [
        "baby",
        "fyp",
        "trend",
        "hot",
    ],
    "maxItems": 20,
    "sortType": 0,
    "publishTime": "ALL_TIME",
}

# Run the Actor and wait for it to finish
run = client.actor("xtdata/tiktok-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "region": "GB",
  "keywords": [
    "baby",
    "fyp",
    "trend",
    "hot"
  ],
  "maxItems": 20,
  "sortType": 0,
  "publishTime": "ALL_TIME"
}' |
apify call xtdata/tiktok-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,xtdata/tiktok-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/WygojpfDR7ReF1Xh4/builds/qfREJWVjggiBSciQ4/openapi.json
