gtw.
Note
gtw.
qrtz
javascript
11
2
https://snaptik.net/
24 Jun 2026
Code
const axios = require('axios');
const { load } = require('cheerio');
const UAS = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0',
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1',
];
let uaIdx = 0;
function ua() { return UAS[uaIdx++ % UAS.length]; }
async function tikwm(url) {
const { data } = await axios.post(
'https://tikwm.com/api/',
{ url },
{
headers: {
'User-Agent': ua(),
'Accept': 'application/json',
'Content-Type': 'application/json',
},
timeout: 15000,
}
);
if (data.code !== 0) throw new Error('TikWM failed');
return {
thumbnail: data.data.cover,
mp4: data.data.play,
mp4_hd: data.data.wmplay || data.data.play,
mp3: data.data.music,
};
}
async function snaptik(url) {
for (let i = 0; i < 5; i++) {
try {
const { data } = await axios.post(
'https://snaptik.net/api/ajaxSearch',
new URLSearchParams({ q: url, lang: 'en' }).toString(),
{
headers: {
'User-Agent': ua(),
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.9',
'Referer': 'https://snaptik.net/',
'Origin': 'https://snaptik.net',
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
timeout: 15000,
}
);
if (data && data.status === 'ok') {
const $ = load(data.data);
const thumbnail = $('.image-tik img').attr('src') || $('img').first().attr('src') || null;
const result = { thumbnail, mp4: null, mp4_hd: null, mp3: null };
$('.tik-button-dl').each((i, el) => {
const href = $(el).attr('href');
const text = $(el).text().toLowerCase();
if (!href || !href.includes('snapcdn.app')) return;
if (text.includes('mp3') || text.includes('audio')) result.mp3 = href;
else if (text.includes('hd') || text.includes('original')) result.mp4_hd = href;
else if (text.includes('mp4')) result.mp4 = href;
});
return result;
}
} catch (e) {
await new Promise(r => setTimeout(r, 1000));
}
}
throw new Error('Snaptik blocked after 5 retries');
}
async function download(url) {
try {
return await tikwm(url);
} catch (e) {
return await snaptik(url);
}
}
module.exports = download;
if (require.main === module) {
const url = process.argv[2];
if (!url) { console.error('Usage: node snaptik.js <tiktok_url>'); process.exit(1); }
download(url).then(r => console.log(JSON.stringify(r, null, 2))).catch(e => { console.error('Error:', e.message); process.exit(1); });
}Rating
Gimana snippet ini menurutmu?
Embed ke website / blog
<iframe src="https://qrtzcode.vercel.app/api/embed/download/snaptik" style="width:100%;height:400px;border:none;border-radius:12px;"></iframe>Related Snippets