TikTok Quick Start Guide

TikTok Quick Start Guide

Introduction

Our TikTok Premium Data Product offers clients comprehensive access to targeted TikTok content through a combination of full feeds, filtered feeds, and a Premium API for custom data collection. This document provides an overview of how the product works and how to get started.

Product Components

  1. Full Feed: Provides comprehensive TikTok data from all indexed sources via an HTTP connection.

  2. Filtered Feed: Allows users to create Rules in the Rules API to receive data from specific author/hashtag pages via an HTTP connection stream.

  3. TikTok Premium API: Enables users to add specific user/hashtag pages for crawling, even if they're not in the current index.

Data Types

The product provides access to the following data types:

For a comprehensive list of available fields and their descriptions, please refer to the TikTok Data Dictionary.

How It Works

1. Data Collection

  • We employ a targeted approach, focusing on user and hashtag pages.

  • Data is collected every 12 hours for user and hashtag pages, including updates to video metadata stats.

  • Hashtag stats are collected every 6 hours.

  • Comments are collected periodically for 30 days after initial video discovery (initial crawl, 1, 5, 10, 30 days).

2. Data Availability

  • For user pages: When adding new pages, the 30 most recent videos are captured with the initial crawl, and new videos are captured moving forward.

  • For hashtag pages: The 30 videos captured with each crawl are a mix of trending and recent videos, as determined by TikTok's sorting algorithm.

3. Premium API

The TikTok Premium API includes the following endpoints:

  1. List TikTok Urls: Retrieves a list of all TikTok URLs currently being tracked for the client.

  2. Add TikTok urls (author, tag): Allows clients to submit new TikTok URLs for tracking. This is the most important endpoint for expanding data collection.

  3. Delete TikTok Urls: Enables clients to remove specific URLs from their tracking list.

For more information on the TikTok Premium API endpoints, please refer to the TikTok Premium API documentation.

URL Format for Submission

When submitting URLs via the Add TikTok urls endpoint, use the following format:

  • For user profiles: https://www.tiktok.com/@username

  • For hashtags: https://www.tiktok.com/tag/hashtagname

Example: https://www.tiktok.com/tag/unocardgame

Getting Started

  1. Set Up Premium API Access

    • Use the provided credentials:

      • Username: datauser

      • Password: Jo$B=[N1pN

  2. Submit Pages for Crawling

    • Use the "Add TikTok URLs" endpoint in the Premium API.

    • Example: POST <https://apis.socialgist.com/tiktok_premium_api/{customer}/tiktok/{apipath}/seedurls>

    • Body:

      { "content": { "url": "https://www.tiktok.com/tag/unocardgame" } }
  3. Set Up Filtered Feed (if applicable)

    • Create Rules using the Rules API to specify which data you want to receive.

  4. Connect to the Stream

    • Use the following code snippet to connect to the stream:

      import requests url = "https://streaming.socialgist.com/stream/tiktok_filtered/subscription/main/part/1/data.json?keepalivestream=true" username = "your_username" password = "your_password" response = requests.get(url, auth=(username, password), stream=True) for line in response.iter_lines(): if line: print(line)
    • Note: Always set the keepalivestream parameter to true to prevent disconnections during periods of inactivity.

  5. Wait for Data

    • Allow up to 24 hours for content to start appearing in your stream.

  6. (Optional) Create Rules for Specific Tracking

    • After data starts flowing, you can create specific rules to track particular hashtags or users.

    • Use the Rules API to create these rules. Here's an example of creating a rule to track the "unocardgame" hashtag:

      Copy POST https://apis.socialgist.com/tiktok/pq Headers: Content-Type: application/json Authorization: Basic [Your Base64 encoded credentials] Body: { "queries": [ { "querystring": "query=@hashtag unocardgame&filter_json=json.type='video'", "tag": "unocardgame_videos" } ] }
    • This rule will filter for videos tagged with "unocardgame".

    • The "tag" field allows you to label this rule for easy reference.

    • Adjust the filter_json parameter to refine your results (e.g., json.type='comment' for comments, or additional filters as needed).

    Note: Ensure that you've already added the corresponding TikTok URL (https://www.tiktok.com/tag/unocardgame) using the Premium API before creating this rule.

 

FAQ

  1. What is the keepalivestream parameter?

    • This parameter keeps the connection alive by sending a carriage return character every 30 seconds. It's crucial for maintaining the connection during periods of low data volume.

    • The keepalivestream parameter will return the newline character ‘\n’ to ensure maintained connection.

  2. How does buffering work?

    • Messages are stored in a buffer for 24 hours while not being consumed.

    • To retrieve all messages from the buffer, use the usebuffer=true parameter.

    • The stream automatically restarts at the last consumed message in case of disconnection.

  3. What is the rollback parameter?

    • This parameter allows you to re-read previously consumed messages within a 24-hour window.

    • Example: Setting rollback=1000 will re-read the last 1000 data messages.

  4. How often should I reconnect if disconnected?

    • Wait at least 60 seconds before attempting to reconnect after a disconnect.

  5. What happens if there's no activity for an extended period?

    • If there's no activity for 5 minutes, the connection will be broken. This is why using keepalivestream=true is important.

  6. Is there a maximum number of URLs I can submit?

    • For trial accounts, you can submit up to 500 URLs.

    • For production accounts, the limit is based on your pricing tier.

    • Please contact our sales team for more information about pricing and volume limits.

  7. How often is the data updated?

    • User and hashtag pages are crawled every 12 hours.

    • Hashtag stats are updated every 6 hours.

    • Comments are collected periodically for 30 days after initial video discovery (initial crawl, 1, 5, 10, 30 days).

  8. Can I get historical data?

    • When adding new user pages, we capture the 30 most recent videos.

    • For hashtag pages, we capture the 30 "top" videos as determined by TikTok's algorithm.

    • We do not provide extensive historical data beyond these initial captures.

  9. What types of TikTok content can I track?

    • You can track videos, hashtag stats, and top-level comments.

    • We do not currently support tracking of live streams or direct messages.

  10. How do I know if a URL I've submitted is being tracked?

    • You can use the "List TikTok Urls" endpoint in the Premium API to see all URLs currently being tracked for your account.

  11. Can I track private TikTok accounts?

    • No, our system can only track public TikTok accounts and hashtags.

  12. How long does it take for new content to appear in my feed after I've submitted a URL?

    • Generally, allow up to 24 hours for new content to start appearing in your stream.

    • This can vary depending on the activity level of the account or hashtag you're tracking.

  13. Can I track specific users' comments across multiple videos?

    • Yes, you can create a rule in the Rules API to filter for comments from specific users across all tracked videos.

  14. What happens if a TikTok video I'm tracking gets deleted?

    • If a video is deleted from TikTok, it will no longer appear in future data pulls.

    • However, any data you've already received about that video will remain in your historical data.

  15. Can I get notifications when new content is available?

    • Our streaming API provides real-time updates as new content becomes available.

    • You can implement your own notification system based on the incoming data from the stream.

  16. Can I get engagement metrics (likes, shares, etc.) for videos?

    • Yes, we provide engagement metrics such as like counts, share counts, and comment counts for videos.

    • These metrics are updated with each crawl of the video.

  17. How do I troubleshoot if I'm not receiving data?

    • Ensure your API credentials are correct.

    • Check that you've properly set up your stream connection with the keepalivestream=true parameter.

    • Verify that the URLs you've submitted are valid and for public TikTok accounts or hashtags.

    • If issues persist, contact our support team for assistance.