TikTok Research API
TikTok provides a Research API that allows authorized researchers to access public data on the platform. This API is designed for academic and research purposes to study trends, content, and user behavior on TikTok.
The Research API endpoint for user information is https://open.tiktokapis.com/v2/research/user/info/. This endpoint allows researchers to retrieve public information about TikTok users, including their profile details, follower counts, and content statistics.
GET https://open.tiktokapis.com/v2/research/user/info/
Request Headers:
Authorization: Bearer {YOUR_ACCESS_TOKEN}
Content-Type: application/json
Request Body:
{
"username": "username"
}
Response:
{
"data": {
"user": {
"display_name": "Display Name",
"bio_description": "User bio",
"avatar_url": "https://...",
"username": "username",
"follower_count": 1000,
"following_count": 500,
"likes_count": 10000,
"video_count": 100
}
}
}TikTok Video ID Timestamp Calculation
TikTok assigns a unique numeric ID to each video uploaded to the platform. These IDs are visible in the URL of any TikTok video, following the pattern: https://www.tiktok.com/@username/video/7234567890123456789
Similar to other social media platforms, TikTok video IDs contain encoded information, including a timestamp that indicates when the video was created.
How Timestamp Extraction Works
TikTok uses a 64-bit integer for video IDs, with the first 32 bits containing a Unix timestamp (seconds since January 1, 1970). To extract this timestamp, you need to convert the ID to binary and extract the first 31 bits.
import datetime
def extract_tiktok_timestamp(video_id):
"""
Extract the creation timestamp from a TikTok video ID.
Args:
video_id (str): The TikTok video ID (numeric part of the URL)
Returns:
datetime: The creation date of the video
"""
# TikTok uses a custom algorithm to encode timestamps
# The first 32 bits of the ID contain the timestamp in seconds
# since the Unix epoch, shifted right by 32 bits
binary = "{0:b}".format(video_id_int) # Convert to binary
bits = binary[:31] # Get the first 31 bits
timestamp_seconds = int(bits, 2) # Convert to integer
# Convert to datetime object
creation_date = datetime.datetime.fromtimestamp(timestamp_seconds)
return creation_date
# Example usage
video_id = "7234567890123456789"
try:
creation_date = extract_tiktok_timestamp(video_id)
print(f"Video was created on: {creation_date.strftime('%Y-%m-%d %H:%M:%S')}")
except ValueError as e:
print(f"Error: {e}")