# @prevter/tiktok-scraper

> Library for downloading videos from TikTok (without watermark)

Latest version **1.0.1** (published 2023-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @prevter/tiktok-scraper
pnpm add @prevter/tiktok-scraper
yarn add @prevter/tiktok-scraper
bun add @prevter/tiktok-scraper
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-09-19 |
| First published | 2023-07-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | prevter |
| Maintainers | prevter |
| Keywords | tiktok, video, downloader |

## Links

- npm: https://www.npmjs.com/package/@prevter/tiktok-scraper
- Repository: https://github.com/prevter/tiktok-scraper
- Homepage: https://github.com/prevter/tiktok-scraper#readme
- Issues: https://github.com/prevter/tiktok-scraper/issues
- npm.io page: https://npm.io/package/@prevter/tiktok-scraper

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-09-19
- 1.0.0 — 2023-07-08

## README

# TikTok Video Downloader

![npm](https://img.shields.io/npm/v/%40prevter%2Ftiktok-scraper)
![npm type definitions](https://img.shields.io/npm/types/%40prevter%2Ftiktok-scraper)
![GitHub](https://img.shields.io/github/license/prevter/tiktok-scraper)  

Simple library to download TikTok videos without watermark in TypeScript.

## Installation

```bash
npm install @prevter/tiktok-scraper
```

## Usage

```ts
// 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:

```ts
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:

```ts
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:

```ts
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:

```bash
npm run build
```

Build and run test script:

```bash
npm run build:test
```

---
_Source: https://npm.io/package/@prevter/tiktok-scraper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
