@xbibzlibrary/tiktokscrap
Version:
Powerful TikTok Scraper and Downloader Library
218 lines (206 loc) • 4.06 kB
text/typescript
export interface TikTokUser {
id: string;
uniqueId: string;
nickname: string;
avatarUrl: string;
signature: string;
verified: boolean;
following: number;
fans: number;
heart: number;
video: number;
digg: number;
privateAccount: boolean;
isSecret: boolean;
secUid: string;
}
export interface TikTokVideo {
id: string;
text: string;
createTime: number;
author: TikTokUser;
music: {
id: string;
title: string;
author: string;
album: string;
playUrl: string;
coverLarge: string;
coverMedium: string;
coverThumb: string;
duration: number;
};
stats: {
digg: number;
share: number;
comment: number;
play: number;
};
videoMeta: {
width: number;
height: number;
duration: number;
cover: string;
dynamicCover: string;
originCover: string;
};
downloadAddr: string;
webVideoUrl: string;
hashtags: Array<{
id: string;
name: string;
title: string;
cover: string;
}>;
mentions: Array<{
id: string;
uniqueId: string;
nickname: string;
}>;
effects: Array<{
id: string;
name: string;
icon: string;
}>;
isAd: boolean;
commentsDisabled: boolean;
duetEnabled: boolean;
stitchEnabled: boolean;
secret: boolean;
forFriend: boolean;
digged: boolean;
itemCommentStatus: number;
}
export interface TikTokPhoto {
id: string;
text: string;
createTime: number;
author: TikTokUser;
music: {
id: string;
title: string;
author: string;
album: string;
playUrl: string;
coverLarge: string;
coverMedium: string;
coverThumb: string;
duration: number;
};
stats: {
digg: number;
share: number;
comment: number;
play: number;
};
covers: Array<{
url: string;
width: number;
height: number;
}>;
webVideoUrl: string;
hashtags: Array<{
id: string;
name: string;
title: string;
cover: string;
}>;
mentions: Array<{
id: string;
uniqueId: string;
nickname: string;
}>;
effects: Array<{
id: string;
name: string;
icon: string;
}>;
isAd: boolean;
commentsDisabled: boolean;
duetEnabled: boolean;
stitchEnabled: boolean;
secret: boolean;
forFriend: boolean;
digged: boolean;
itemCommentStatus: number;
}
export interface TikTokHashtag {
id: string;
name: string;
title: string;
description: string;
cover: string;
icon: string;
viewCount: number;
isCommerce: boolean;
isAd: boolean;
challengeType: number;
videos: TikTokVideo[];
}
export interface TikTokTrend {
id: string;
name: string;
title: string;
desc: string;
cover: string;
viewCount: number;
isCommerce: boolean;
isAd: boolean;
challengeType: number;
videos: TikTokVideo[];
}
export interface TikTokComment {
id: string;
text: string;
createTime: number;
user: TikTokUser;
digg: number;
reply: number;
isPinned: boolean;
isAuthorDigged: boolean;
replies: TikTokComment[];
}
export interface TikTokSearchOptions {
keyword: string;
cursor?: number;
count?: number;
sortType?: 0 | 1 | 2; // 0: Relevant, 1: Latest, 2: Most liked
publishTime?: 0 | 1 | 2 | 3; // 0: All time, 1: Within 1 day, 2: Within 7 days, 3: Within 30 days
duration?: 0 | 1 | 2; // 0: All, 1: Under 15s, 2: Over 15s
}
export interface TikTokUserFeedOptions {
username: string;
cursor?: number;
count?: number;
type?: 'post' | 'like';
}
export interface TikTokHashtagFeedOptions {
hashtag: string;
cursor?: number;
count?: number;
}
export interface TikTokDownloadOptions {
outputDir?: string;
filename?: string;
progressCallback?: (progress: number) => void;
}
export interface TikTokScrapOptions {
timeout?: number;
retries?: number;
userAgent?: string;
proxy?: {
host: string;
port: number;
auth?: {
username: string;
password: string;
};
};
headers?: Record<string, string>;
}
export interface TikTokScrapResult<T> {
success: boolean;
data?: T;
error?: string;
message?: string;
}