npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@prevter/tiktok-scraper

v1.0.1

Published

Library for downloading videos from TikTok (without watermark)

Downloads

1,829

Readme

TikTok Video Downloader

npm npm type definitions GitHub

Simple library to download TikTok videos without watermark in TypeScript.

Installation

npm install @prevter/tiktok-scraper

Usage

// Typescript:
import { fetchVideo } from '@prevter/tiktok-scraper';
import { writeFileSync } from 'fs';

// Javascript:
// const { fetchVideo } = require('@prevter/tiktok-scraper');
// const { writeFileSync } = require('fs');

const url = 'https://www.tiktok.com/@username/video/1234567891234567891';

// Using promise
fetchVideo(url)
  .then(async (video) => {
    const buffer = await video.download();
    writeFileSync('video.mp4', buffer);
  })
  .catch((err) => {
    console.error(err);
  });

// Using await
const video = await fetchVideo(url);
const buffer = await video.download();
writeFileSync('video.mp4', buffer);

Supports full URLs (www.tiktok.com) and short URLs (vm.tiktok.com).
fetchVideo parameter can be a URL or a video ID. It will automatically detect how to handle the parameter. If it fails to detect, it will throw an error, so you can handle it.
This method return a Promise<Buffer>, so you can either save it to a file or just send it to anywhere you want.

You can also download video with watermark or even download music from the video:

const video = await fetchVideo(url);

// add `true` argument to download video with watermark
const watermarkBuffer = await video.download({ watermark: true });
const noWatermarkBuffer = await video.download();
const musicBuffer = await video.music.download();

You can add a progress callback to track download progress:

const video = await fetchVideo(url);

const buffer = await video.download({
  progress: (p) => {
    console.log(`Downloaded ${p.progress}% (${p.downloaded}/${p.total} bytes)`);
  },
});

In addition, you can get some information about the video:

const video = await fetchVideo(url);

console.log('Video description:', video.description);
console.log('🔗 URL:', video.url);
console.log('👤 Author:', video.author);
console.log('❤️ Likes:', video.likes);
console.log('💬 Comments:', video.comments);
console.log('🔁 Shares:', video.shares);
console.log('▶️ Plays:', video.playCount);
console.log('🎵 Music:', video.music.name, '-', video.music.author);
console.log('🖼️ Thumbnail URL:', video.previewImageUrl);

/*
Video description: This is a video description
🔗 URL: https://www.tiktok.com/@username/video/1234567891234567891
👤 Author: username
❤️ Likes: 123456
💬 Comments: 1234
🔁 Shares: 1234
▶️ Plays: 1234567
🎵 Music: Music Name - Music Author
🖼️ Thumbnail URL: https://p16-sign-sg.tiktokcdn.com/...
*/

Building and testing

Build typescript files:

npm run build

Build and run test script:

npm run build:test