cakkatrok-instagram-downloader
v2.0.2
Published
Instagram downloader for Node.js: download public reels, posts, videos, photos, and stories with simple API and CLI.
Maintainers
Readme
cakkatrok-instagram-downloader
Downloader media Instagram berbasis Node.js yang memakai endpoint SnapVideo.
Package ini mendukung:
- Story Instagram dengan username saja.
- Story Instagram dengan link story.
- Reels dan postingan Instagram dengan link postingan.
- Output media yang sudah difilter sesuai tipe: video hanya mengirim link video, foto hanya mengirim link foto.
Install
npm install cakkatrok-instagram-downloaderUntuk CLI global:
npm install -g cakkatrok-instagram-downloaderUsage
Download Story Dengan Username
const Instagram = require('cakkatrok-instagram-downloader');
Instagram.story('instagram')
.then(result => {
console.log(result.media);
})
.catch(console.error);Username boleh memakai @:
Instagram.story('@instagram')
.then(result => console.log(result.media))
.catch(console.error);Download Story Dengan Link
Instagram.story('https://www.instagram.com/stories/instagram/')
.then(result => console.log(result.media))
.catch(console.error);Download Reels
Instagram.media('https://www.instagram.com/reel/SHORTCODE/')
.then(result => console.log(result.media))
.catch(console.error);Download Postingan
Instagram.media('https://www.instagram.com/p/SHORTCODE/')
.then(result => console.log(result.media))
.catch(console.error);Auto Mode
Function utama juga bisa dipakai langsung. Jika input bukan link, input dianggap sebagai username story.
Instagram('instagram')
.then(result => console.log(result.media))
.catch(console.error);
Instagram('https://www.instagram.com/reel/SHORTCODE/')
.then(result => console.log(result.media))
.catch(console.error);Response
Contoh response:
{
status: 'ok',
input: 'instagram',
query: 'https://www.instagram.com/stories/instagram/',
type: 'story',
media: [
{
url: 'https://dl.snapcdn.app/get?token=...',
type: 'photo',
text: '1080x1920',
filename: 'SnapVideo.app_photo.jpg'
},
{
url: 'https://dl.snapcdn.app/get?token=...',
type: 'video',
text: 'Download Video',
filename: 'SnapVideo.app_video.mp4'
}
],
raw: {}
}Catatan filtering:
- Jika media adalah video, package hanya mengembalikan link video.
- Thumbnail atau foto preview dari video tidak ikut dikirim.
- Jika media adalah foto, package hanya mengembalikan link foto utama.
- Jika story/carousel berisi foto dan video terpisah, keduanya tetap dikirim sebagai item berbeda.
Mixed Media
Satu story atau postingan bisa memiliki lebih dari satu tipe media, misalnya ada foto dan video dalam satu hasil. Package ini akan tetap mengirim semua media utama yang ditemukan.
Contoh response mixed media:
{
status: 'ok',
type: 'story',
media: [
{
url: 'https://dl.snapcdn.app/get?token=...',
type: 'photo',
filename: 'story-photo.jpg'
},
{
url: 'https://dl.snapcdn.app/get?token=...',
type: 'video',
filename: 'story-video.mp4'
}
]
}Gunakan field type untuk menentukan cara mengirim media. Ini berguna untuk bot WhatsApp atau Telegram karena foto dan video biasanya memakai method pengiriman yang berbeda.
Contoh Untuk Bot WhatsApp
Contoh umum:
const Instagram = require('cakkatrok-instagram-downloader');
async function sendInstagramToWhatsApp(sock, jid, input) {
const result = await Instagram(input);
for (const item of result.media) {
if (item.type === 'video') {
await sock.sendMessage(jid, {
video: { url: item.url },
caption: item.filename
});
continue;
}
if (item.type === 'photo') {
await sock.sendMessage(jid, {
image: { url: item.url },
caption: item.filename
});
continue;
}
await sock.sendMessage(jid, {
document: { url: item.url },
fileName: item.filename
});
}
}Contoh Untuk Bot Telegram
Contoh dengan Telegraf:
const Instagram = require('cakkatrok-instagram-downloader');
async function sendInstagramToTelegram(ctx, input) {
const result = await Instagram(input);
for (const item of result.media) {
if (item.type === 'video') {
await ctx.replyWithVideo(item.url, {
caption: item.filename
});
continue;
}
if (item.type === 'photo') {
await ctx.replyWithPhoto(item.url, {
caption: item.filename
});
continue;
}
await ctx.replyWithDocument({
url: item.url,
filename: item.filename
});
}
}CLI
Download story dengan username:
instagram-downloader instagram --storyDownload story dengan link:
instagram-downloader https://www.instagram.com/stories/instagram/ --storyDownload reels:
instagram-downloader https://www.instagram.com/reel/SHORTCODE/Download postingan ke folder tertentu:
instagram-downloader https://www.instagram.com/p/SHORTCODE/ ./downloadsTest
npm testDi PowerShell Windows, jika npm terkena execution policy, pakai:
npm.cmd testNotes
- Media dari akun private atau story yang tidak tersedia publik bisa gagal diproses.
- Gunakan hanya untuk media yang memang boleh Anda akses dan simpan.
Credit
Created by RintisW.P.
Telegram: https://t.me/rintisdep
Bug Report
Jika menemukan bug, error endpoint, atau hasil media tidak sesuai, laporkan ke:
https://t.me/rintisdep
License
MIT
