A lightweight TikTok SDK for Node.js that makes it easier to fetch videos, users, comments, playlists, hashtags, and other TikTok data in a clean, structured way.
Caution
This project is not affiliated with, endorsed by, or officially connected to TikTok or ByteDance. TikTok and related names, marks, logos, and images are trademarks of their respective owners.
This SDK is provided for legitimate development use only. Use it at your own discretion and in accordance with TikTok's terms and applicable laws.
- This SDK talks to TikTok through web endpoints and structured responses.
- Playwright is optional and only helps when a browser-backed session makes sense.
- That keeps the setup lighter for normal use and avoids needing a full browser just to start.
- It supports videos, users, comments, hashtags, playlists, sounds, and search data.
Important
This project is an unofficial TikTok SDK and depends on public endpoints and scraping behavior that may change at any time. Some features may require proxies, Playwright, or additional setup depending on your environment. Use responsibly and make sure your usage follows TikTok's terms and applicable laws.
Important
Some endpoints (searchUsers, getSound, getSoundVideos) are blocked by Akamai WAF from datacenter IPs. Pass --session to use a Playwright browser session that bypasses WAF.
npm install playwright
node docs/examples/getComments.cjs --sessionImportant
For deployment, use a VPS or another long-running server. This project runs into IP restrictions and blocks on most serverless hosts, so only a few platforms will work reliably. Vercel is a bad fit here, and Render only makes sense if you're using a service that stays up as a real web process.
npm install @traceryn/tiktok-sdkyarn add @traceryn/tiktok-sdknpm install git+https://github.com/traceryn/tiktok-sdk.gityarn add git+https://github.com/traceryn/tiktok-sdk.gitnpm install playwright
# or
yarn add playwrightNote: Only needed for
--session(browser-backed) requests. After installing Playwright, you must also download a browser binary withnpx playwright install chromium. Theplaywrightpackage is a thin wrapper — it does not ship a browser by default.
import { TikTokClient } from '@traceryn/tiktok-sdk';
const client = new TikTokClient();or
const { TikTokClient } = require('@traceryn/tiktok-sdk');
const client = new TikTokClient();Note
Check the examples directory for runnable example scripts with the session pattern.
getVideo(url)// get video data from a TikTok linkgetUser(usernameOrUrl)// get user profile datagetComments(videoUrl)// get comments from a video or postsearchUsers(query)// search for usersgetHashtag(name)// get hashtag statsgetSound(musicId)// get sound infogetSoundVideos(musicId)// get videos using a soundgetTrendingVideos()// get trending videosgetUserLikedVideos(username)// get videos a user likedgetUserPlaylists(username)// get playlists for a usergetPlaylist(mixId)// get one playlistgetPlaylistVideos(mixId)// get videos inside a playlistaddProxies(proxies)// add your own proxiesgetProxyStats()// check proxy usageinvalidateCache(url)// clear one cached videoclearCache()// clear all cached video data
import { TikTokClient } from '@traceryn/tiktok-sdk';
const client = new TikTokClient();
const video = await client.getVideo('https://www.tiktok.com/@user/video/1234567890');
console.log(video.title);Gets one video and prints its title.
const user = await client.getUser('tiktok');
console.log(user.nickname);Gets a user profile from a username or profile link.
const comments = await client.getComments('https://www.tiktok.com/@user/video/1234567890');
console.log(comments.comments.length);Gets the comments for a video or post.
const hashtag = await client.getHashtag('fyp');
console.log(hashtag.stats.videoCount);Gets hashtag info and the number of videos tied to it.
const search = await client.searchUsers('tiktok');
console.log(search.users.length);Searches for TikTok users by keyword.
const trending = await client.getTrendingVideos();
console.log(trending.videos.length);Gets the current trending videos.
const { TikTokClient, PlaywrightSession } = require('@traceryn/tiktok-sdk');
async function main() {
const useSession = process.argv.includes('--session');
let session;
if (useSession) {
session = new PlaywrightSession({ headless: true });
await session.init();
}
const client = new TikTokClient({ session });
const trending = await client.getTrendingVideos();
console.log(trending.videos.length);
if (session) await session.close();
}
main().catch((err) => {
console.error('Error:', err.message);
process.exit(1);
});import { TikTokClient } from '@traceryn/tiktok-sdk';
const client = new TikTokClient({
timeout: 15000, // keep requests from hanging too long
maxRetries: 2, // retry a couple times if TikTok flakes out
rateLimit: 3, // slow it down a bit
concurrency: 1, // keep it simple and steady
cacheTTL: 60_000, // cache results for a minute
});| Option | What you can change it to |
|---|---|
timeout |
Any number in milliseconds, like 5000, 15000, or 30000 |
maxRetries |
Any whole number, like 0, 2, or 5 |
rateLimit |
Any whole number, like 1, 3, or 10 |
concurrency |
Any whole number, like 1, 2, or 4 |
cacheTTL |
Any number in milliseconds, like 30000, 60000, or 300000 |
proxy |
A single proxy URL or array, like "http://user:pass@host:port" |
proxyRotation |
"round-robin", "random", or "lowest-failures" |
You can also pass session if you want the Playwright path, or proxy / proxyRotation if you want to manage proxies a bit more directly.
TikTok rate-limits endpoints based on IP. If a request returns an empty response or gets throttled after heavy use, the fix is to switch IP via a proxy.
node docs/examples/searchUsers.cjs --session --proxy=http://user:pass@host:portYou can also add proxies at runtime:
client.addProxies(['http://user:pass@host:port', 'http://proxy2:port']);
console.log(client.getProxyStats());Free public proxies are often blocked by TikTok — residential or paid proxies are the most reliable for high-volume use. The SDK auto-rotates to the next healthy proxy when one fails.
Note
You can also check HERE to see example response data for the main methods.
npm testThat runs the Vitest suite for this repo. Most of the tests are local, but some checks still depend on TikTok behavior and can shift when the site changes.
If you want a slightly wider check while you're working on the SDK, you can also run:
npm run typechecknpm run lintIf you're only testing one area, keep the focus tight and run the smallest check that covers your change.
If you'd like to financially support this project, sponsorship by the current maintainer is coming soon.
See CONTRIBUTING.md for how to contribute, and SECURITY.md for how to report security issues.
Copyright (c) 2026 Corex Anthony
Licensed under the MIT License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
