A lightweight TypeScript/JavaScript client SDK for downloading videos, images, and audio from Instagram, TikTok, YouTube, Capcut, Pinterest, Twitter, X, Google Drive, MediaFire, Douyin, SnackVideo, Xiaohongshu (and Profile), Cocofun, Spotify, Youtube Search, SounCloud, Threads, Kuaishou and Facebook.
Project Prerequisites
To ensure this project runs smoothly, make sure you have the following tools installed.
| Prerequisite |
Version |
| Node.js |
v20+ |
| Package Manager |
pnpm 10.18.3+, Yarn 4.10.3+, or Bun 1.3.0+ |
Alternatively, you can include btch-downloader by getting it from npm, downloading it from GitHub releases or by including it via unpkg or another JavaScript CDN, like jsDelivr.
<script src="https://unpkg.com/btch-downloader/dist/browser/index.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/browser/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/btch-downloader/dist/browser/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser/index.min.js"></script>
📘 Click here to see how to implement this downloader using CDN (HTML Example)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Playground Test CDN btch-downloader</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f9f9fb;
color: #222;
max-width: 900px;
margin: 40px auto;
padding: 25px;
}
h1 {
color: #0078ff;
text-align: center;
}
input {
width: 60%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 15px;
}
select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 15px;
margin-right: 10px;
}
button {
padding: 10px 20px;
border: none;
border-radius: 6px;
background: #0078ff;
color: white;
cursor: pointer;
}
button:hover {
background: #005ecc;
}
pre {
text-align: left;
background: #fff;
border: 1px solid #ddd;
border-radius: 6px;
padding: 10px;
overflow-x: auto;
white-space: pre-wrap;
}
hr {
margin: 30px 0;
}
ul {
text-align: left;
background: #fff;
border-radius: 6px;
padding: 15px;
border: 1px solid #ddd;
}
li {
margin-bottom: 6px;
}
a {
color: #0078ff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.info {
text-align: center;
margin-top: 10px;
font-size: 14px;
color: #555;
}
</style>
</head>
<body>
<h1>Playground</h1>
<p align="center">A single-page downloader for all supported platforms.</p>
<div align="center">
<select id="platformSelect">
<option value="auto">Auto Detect</option>
<option value="instagram">Instagram</option>
<option value="tiktok">TikTok</option>
<option value="facebook">Facebook</option>
<option value="twitter">Twitter</option>
<option value="youtube">YouTube</option>
<option value="mediafire">MediaFire</option>
<option value="capcut">CapCut</option>
<option value="gdrive">Google Drive</option>
<option value="pinterest">Pinterest</option>
<option value="douyin">Douyin</option>
<option value="xiaohongshu">Xiaohongshu</option>
<option value="xiaohongshuProfile">Xiaohongshu Profile</option>
<option value="snackvideo">SnackVideo</option>
<option value="cocofun">Cocofun</option>
<option value="spotify">Spotify</option>
<option value="yts">YTS</option>
<option value="soundcloud">SoundCloud</option>
<option value="threads">Threads</option>
<option value="kuaishou">Kuaishou</option>
</select>
<input id="urlInput" placeholder="Paste any supported URL here..." />
<button id="downloadBtn">Fetch</button>
</div>
<div class="info">
Developer: <strong>@prm2.0</strong> —
<a href="https://github.com/hostinger-bot/btch-downloader/issues" target="_blank">Report Issues</a>
</div>
<h3>Result:</h3>
<pre id="output">No data yet...</pre>
<hr>
<h3>Example URLs</h3>
<ul>
<li>Instagram: <a href="https://www.instagram.com/reel/DKPtUL_S9Nh/?igsh=MTE1dTVkb2E4NTFmcw==" target="_blank">https://www.instagram.com/reel/DKPtUL_S9Nh/?igsh=MTE1dTVkb2E4NTFmcw==</a></li>
<li>TikTok: <a href="https://www.tiktok.com/@omagadsus/video/7025456384175017243" target="_blank">https://www.tiktok.com/@omagadsus/video/7025456384175017243</a></li>
<li>Facebook: <a href="https://www.facebook.com/watch/?v=1393572814172251" target="_blank">https://www.facebook.com/watch/?v=1393572814172251</a></li>
<li>Twitter: <a href="https://twitter.com/gofoodindonesia/status/1229369819511709697" target="_blank">https://twitter.com/gofoodindonesia/status/1229369819511709697</a></li>
<li>YouTube: <a href="https://youtu.be/C8mJ8943X80" target="_blank">https://youtu.be/C8mJ8943X80</a></li>
<li>MediaFire: <a href="https://www.mediafire.com/file/941xczxhn27qbby/GBWA_V12.25FF-By.SamMods-.apk/file" target="_blank">https://www.mediafire.com/file/941xczxhn27qbby/GBWA_V12.25FF-By.SamMods-.apk/file</a></li>
<li>CapCut: <a href="https://www.capcut.com/template-detail/7299286607478181121" target="_blank">https://www.capcut.com/template-detail/7299286607478181121</a></li>
<li>Google Drive: <a href="https://drive.google.com/file/d/1thDYWcS5p5FFhzTpTev7RUv0VFnNQyZ4/view" target="_blank">https://drive.google.com/file/d/1thDYWcS5p5FFhzTpTev7RUv0VFnNQyZ4/view</a></li>
<li>Pinterest: <a href="https://pin.it/4CVodSq" target="_blank">https://pin.it/4CVodSq</a> or query (e.g., "Zhao Lusi")</li>
<li>Douyin: <a href="https://v.douyin.com/ikq8axJ/" target="_blank">https://v.douyin.com/ikq8axJ/</a></li>
<li>Xiaohongshu: <a href="http://xhslink.com/o/21DKXV988zp" target="_blank">http://xhslink.com/o/21DKXV988zp</a></li>
<li>Xiaohongshu Profile: <a href="https://www.xiaohongshu.com/user/profile/
提示:代码过长已自动截断
Demo HTML
Try Demo
Installing
Package manager
Using npm:
npm install btch-downloader
Using yarn:
yarn add btch-downloader
Using pnpm:
pnpm add btch-downloader
Using bun:
bun add btch-downloader
Services
Usage
Instagram
ESM
import { igdl } from 'btch-downloader';
const url = 'https://www.instagram.com/reel/DKPtUL_S9Nh/?igsh=MTE1dTVkb2E4NTFmcw==';
igdl(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { igdl } = require('btch-downloader');
const url = 'https://www.instagram.com/reel/DKPtUL_S9Nh/?igsh=MTE1dTVkb2E4NTFmcw==';
igdl(url).then(data => console.log(data)).catch(err => console.error(err));
TikTok
ESM
import { ttdl } from 'btch-downloader';
const url = 'https://www.tiktok.com/@omagadsus/video/7025456384175017243?is_from_webapp=1&sender_device=pc&web_id6982004129280116226';
ttdl(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { ttdl } = require('btch-downloader');
const url = 'https://www.tiktok.com/@omagadsus/video/7025456384175017243?is_from_webapp=1&sender_device=pc&web_id6982004129280116226';
ttdl(url).then(data => console.log(data)).catch(err => console.error(err));
Facebook
ESM
import { fbdown } from 'btch-downloader';
const url = 'https://www.facebook.com/watch/?v=1393572814172251';
fbdown(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { fbdown } = require('btch-downloader');
const url = 'https://www.facebook.com/watch/?v=1393572814172251';
fbdown(url).then(data => console.log(data)).catch(err => console.error(err));
ESM
import { twitter } from 'btch-downloader';
const url = 'https://twitter.com/gofoodindonesia/status/1229369819511709697';
twitter(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { twitter } = require('btch-downloader');
const url = 'https://twitter.com/gofoodindonesia/status/1229369819511709697';
twitter(url).then(data => console.log(data)).catch(err => console.error(err));
YouTube
ESM
import { youtube } from 'btch-downloader';
const url = 'https://youtube.com/watch?v=C8mJ8943X80';
youtube(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { youtube } = require('btch-downloader');
const url = 'https://youtube.com/watch?v=C8mJ8943X80';
youtube(url).then(data => console.log(data)).catch(err => console.error(err));
MediaFire (no longer maintained / 不再维护)
ESM
import { mediafire } from 'btch-downloader';
const url = 'https://www.mediafire.com/file/941xczxhn27qbby/GBWA_V12.25FF-By.SamMods-.apk/file';
mediafire(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { mediafire } = require('btch-downloader');
const url = 'https://www.mediafire.com/file/941xczxhn27qbby/GBWA_V12.25FF-By.SamMods-.apk/file';
mediafire(url).then(data => console.log(data)).catch(err => console.error(err));
Capcut
ESM
import { capcut } from 'btch-downloader';
const url = 'https://www.capcut.com/template-detail/7299286607478181121?template_id=7299286607478181121&share_token=80302b19-8026-4101-81df-2fd9a9cecb9c&enter_from=template_detail®ion=ID&language=in&platform=copy_link&is_copy_link=1';
capcut(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { capcut } = require('btch-downloader');
const url = 'https://www.capcut.com/template-detail/7299286607478181121?template_id=7299286607478181121&share_token=80302b19-8026-4101-81df-2fd9a9cecb9c&enter_from=template_detail®ion=ID&language=in&platform=copy_link&is_copy_link=1';
capcut(url).then(data => console.log(data)).catch(err => console.error(err));
Google Drive
ESM
import { gdrive } from 'btch-downloader';
const url = 'https://drive.google.com/file/d/1thDYWcS5p5FFhzTpTev7RUv0VFnNQyZ4/view?usp=drivesdk';
gdrive(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { gdrive } = require('btch-downloader');
const url = 'https://drive.google.com/file/d/1thDYWcS5p5FFhzTpTev7RUv0VFnNQyZ4/view?usp=drivesdk';
gdrive(url).then(data => console.log(data)).catch(err => console.error(err));
Pinterest
ESM
import { pinterest } from 'btch-downloader';
const url = 'https://pin.it/4CVodSq';
pinterest(url).then(data => console.log(data)).catch(err => console.error(err));
pinterest('Zhao Lusi')
.then(data => console.log(data))
.catch(err => console.error(err));
CJS
const { pinterest } = require('btch-downloader');
const url = 'https://pin.it/4CVodSq';
pinterest(url).then(data => console.log(data)).catch(err => console.error(err));
pinterest('Zhao Lusi')
.then(data => console.log(data))
.catch(err => console.error(err));
AIO (no longer maintained / 不再维护)
ESM
import { aio } from 'btch-downloader';
const url = 'https://vt.tiktok.com/ZSkGPK9Kj/';
aio(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { aio } = require('btch-downloader');
const url = 'https://vt.tiktok.com/ZSkGPK9Kj/';
aio(url).then(data => console.log(data)).catch(err => console.error(err));
Douyin (抖音)
ESM
import { douyin } from 'btch-downloader';
const url = 'https://v.douyin.com/ikq8axJ/';
douyin(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { douyin } = require('btch-downloader');
const url = 'https://v.douyin.com/ikq8axJ/';
douyin(url).then(data => console.log(data)).catch(err => console.error(err));
Xiaohongshu (小红书)
ESM
import { xiaohongshu } from 'btch-downloader';
const url = 'http://xhslink.com/o/21DKXV988zp';
xiaohongshu(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { xiaohongshu } = require('btch-downloader');
const url = 'http://xhslink.com/o/21DKXV988zp';
xiaohongshu(url).then(data => console.log(data)).catch(err => console.error(err));
Xiaohongshu Profile (小红书)
ESM
import { xiaohongshuProfile } from 'btch-downloader';
const url = 'https://www.xiaohongshu.com/user/profile/67873204000000000803d9a5';
xiaohongshuProfile(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { xiaohongshuProfile } = require('btch-downloader');
const url = 'https://www.xiaohongshu.com/user/profile/67873204000000000803d9a5';
xiaohongshuProfile(url).then(data => console.log(data)).catch(err => console.error(err));
Snackvideo
ESM
import { snackvideo } from 'btch-downloader';
const url = 'https://s.snackvideo.com/p/j9jKr9dR';
snackvideo(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { snackvideo } = require('btch-downloader');
const url = 'https://s.snackvideo.com/p/j9jKr9dR';
snackvideo(url).then(data => console.log(data)).catch(err => console.error(err));
Cocofun
ESM
import { cocofun } from 'btch-downloader';
const url = 'https://www.icocofun.com/share/post/379250110809?lang=id&pkg=id&share_to=copy_link&m=81638cf44ba27b2ffa708f3410a4e6c2&d=63cd2733d8d258facd28d44fde5198d4cea826e89af7efc4238ada620140eea3&nt=1';
cocofun(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { cocofun } = require('btch-downloader');
const url = 'https://www.icocofun.com/share/post/379250110809?lang=id&pkg=id&share_to=copy_link&m=81638cf44ba27b2ffa708f3410a4e6c2&d=63cd2733d8d258facd28d44fde5198d4cea826e89af7efc4238ada620140eea3&nt=1';
cocofun(url).then(data => console.log(data)).catch(err => console.error(err));
Spotify
ESM
import { spotify } from 'btch-downloader';
const url = 'https://open.spotify.com/track/3zakx7RAwdkUQlOoQ7SJRt';
spotify(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { spotify } = require('btch-downloader');
const url = 'https://open.spotify.com/track/3zakx7RAwdkUQlOoQ7SJRt';
spotify(url).then(data => console.log(data)).catch(err => console.error(err));
YT Search
ESM
import { yts } from 'btch-downloader';
const query = 'Somewhere Only We Know';
yts(query).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { yts } = require('btch-downloader');
const query = 'Somewhere Only We Know';
yts(query).then(data => console.log(data)).catch(err => console.error(err));
SoundCloud
ESM
import { soundcloud } from 'btch-downloader';
const url = 'https://soundcloud.com/issabella-marchelina/sisa-rasa-mahalini-official-audio?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing';
soundcloud(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { soundcloud } = require('btch-downloader');
const url = 'https://soundcloud.com/issabella-marchelina/sisa-rasa-mahalini-official-audio?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing';
soundcloud(url).then(data => console.log(data)).catch(err => console.error(err));
Threads
ESM
import { threads } from 'btch-downloader';
const url = 'https://www.threads.net/@cindyyuvia/post/C_Nqx3khgkI/?xmt=AQGzpsCvidh8IwIqOvq4Ov05Zd5raANiVdvCujM_pjBa1Q';
threads(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { threads } = require('btch-downloader');
const url = 'https://www.threads.net/@cindyyuvia/post/C_Nqx3khgkI/?xmt=AQGzpsCvidh8IwIqOvq4Ov05Zd5raANiVdvCujM_pjBa1Q';
threads(url).then(data => console.log(data)).catch(err => console.error(err));
Kuaishou (快手)
ESM
import { kuaishou } from 'btch-downloader';
const url = 'https://v.kuaishou.com/JT195ZHT';
kuaishou(url).then(data => console.log(data)).catch(err => console.error(err));
CJS
const { kuaishou } = require('btch-downloader');
const url = 'https://v.kuaishou.com/JT195ZHT';
kuaishou(url).then(data => console.log(data)).catch(err => console.error(err));
Important Notes
- This downloader can only be used to download media that is public or accessible to the public.
- This application is not affiliated with or endorsed by any application.
- Ensure you have permission or copyright to download media before using this application.
Contribution and Issue Reporting
If you encounter any issues or wish to contribute to the development of this application, please visit our GitHub repository.
License
btch-downloader is licensed under the MIT License. Please refer to the LICENSE file for more information.
评论