
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
nodejs-insta-private-api
Advanced tools
A pure JavaScript Instagram Private API client inspired by instagram-private-api
nodejs-insta-private-api
VERSION 3.3.1 Update library for latest Instagram Version A pure JavaScript Instagram Private API client written in CommonJS without TypeScript.
Repository: Kunboruto20/nodejs-insta-private-api
Features
Secure authentication with username, email, and password login
Direct message support for text, images, and videos
Story operations: view, react, upload, and manage story feeds
Feed operations: upload, like, comment, and browse timeline
Session management with save and restore capability
Automatic retry logic for failed requests
Over 50 methods covering a wide range of Instagram features
Optimized for speed and reliability
Realtime MQTT support via edge-mqtt.facebook.com (GraphQL, Pub/Sub, Message Sync, Iris)
Installation
npm install nodejs-insta-private-api
Quick Start
Basic Usage
const { IgApiClient } = require('nodejs-insta-private-api');
async function main() { const ig = new IgApiClient();
try { await ig.login({ username: 'your_username', password: 'your_password', email: 'your_email@example.com' });
console.log('Logged in successfully');
await ig.dm.send({
to: 'friend_username',
message: 'Hello from the API!'
});
console.log('Message sent');
} catch (error) { console.error('Error:', error.message); } }
main();
Extending with instagram_mqttt for realtime and FBNS
This library can be extended with instagram_mqttt to add realtime and FBNS (Push Notifications) support.
Install instagram_mqttt
npm install instagram_mqttt
Extend the IgApiClient
import { IgApiClient } from 'nodejs-insta-private-api'; import { withFbnsAndRealtime, withFbns, withRealtime } from 'instagram_mqttt';
const ig = withFbnsAndRealtime(new IgApiClient()); const igFbns = withFbns(new IgApiClient()); const igRealtime = withRealtime(new IgApiClient());
Authentication
Basic Login
const { IgApiClient } = require('nodejs-insta-private-api'); const ig = new IgApiClient();
await ig.login({ username: 'your_username', password: 'your_password', email: 'your_email@example.com' });
if (ig.isLoggedIn()) { console.log('Successfully logged in'); }
Two-Factor Authentication
try { await ig.login({ username, password, email }); } catch (error) { if (error.name === 'IgLoginTwoFactorRequiredError') { const code = '123456'; await ig.account.twoFactorLogin({ username, verificationCode: code, twoFactorIdentifier: error.response.data.two_factor_info.two_factor_identifier }); } }
Session Management
const fs = require('fs');
const session = await ig.saveSession(); fs.writeFileSync('session.json', JSON.stringify(session));
const loaded = JSON.parse(fs.readFileSync('session.json')); await ig.loadSession(loaded);
if (await ig.isSessionValid()) { console.log('Session is valid'); } else { console.log('Need to login again'); }
Direct Messages
Send Text Messages
await ig.dm.send({ to: 'username', message: 'Hello' });
await ig.dm.send({ to: ['user1', 'user2', 'user3'], message: 'Group message' });
Send to Groups
await ig.dm.sendToGroup({ threadId: 'group_thread_id', message: 'Hello group' });
const group = await ig.direct.createGroupThread( ['user1', 'user2', 'user3'], 'My Group Name' );
await ig.dm.sendToGroup({ threadId: group.thread_id, message: 'Welcome to the group' });
Send Media
await ig.dm.sendImage({ to: 'username', imagePath: './photo.jpg' });
await ig.dm.sendVideo({ to: 'username', videoPath: './video.mp4' });
Manage Inbox
const inbox = await ig.dm.getInbox();
console.log(You have ${inbox.inbox.threads.length} conversations);
const thread = await ig.dm.getThread('thread_id');
for (const item of thread.thread.items) { await ig.directThread.markItemSeen(thread.thread.thread_id, item.item_id); }
Stories
React to Stories
await ig.story.react({ storyId: 'story_media_id', reaction: '❤️' });
View Stories
const storyFeed = await ig.story.getFeed(); const userStories = await ig.story.getUser('user_id'); await ig.story.seen(userStories.reel.items);
Upload Stories
await ig.story.upload({ imagePath: './story.jpg', caption: 'My story' });
await ig.story.uploadVideo({ videoPath: './story.mp4', caption: 'Video story', duration_ms: 15000 });
Story Highlights
const highlights = await ig.story.getHighlights('user_id'); const highlight = await ig.story.getHighlight('highlight_id');
Feed Operations
Upload Posts
await ig.feed.upload({ imagePath: './photo.jpg', caption: 'My photo post' });
await ig.feed.uploadVideo({ videoPath: './video.mp4', caption: 'Check out this video', duration_ms: 30000, width: 720, height: 1280 });
Upload Carousel
await ig.feed.uploadCarousel({ items: [ { type: 'photo', path: './photo1.jpg' }, { type: 'photo', path: './photo2.jpg' }, { type: 'video', path: './video1.mp4', duration_ms: 15000 } ], caption: 'My carousel post' });
Browse Feeds
const timeline = await ig.feed.getFeed(); const userFeed = await ig.feed.getUserFeed('user_id'); const hashtagFeed = await ig.feed.getTag('photography'); const locationFeed = await ig.feed.getLocation('location_id'); const exploreFeed = await ig.feed.getExploreFeed(); const likedPosts = await ig.feed.getLiked(); const savedPosts = await ig.feed.getSaved();
Error Handling
const { IgApiClient } = require('nodejs-insta-private-api'); const Utils = require('nodejs-insta-private-api/dist/utils');
try { await ig.login({ username, password, email }); } catch (error) { console.log('Error type:', error.name); console.log('Human readable:', Utils.humanizeError(error)); switch (error.name) { case 'IgLoginBadPasswordError': console.log('Wrong password'); break; case 'IgLoginTwoFactorRequiredError': console.log('2FA required'); break; case 'IgCheckpointError': console.log('Account verification required'); break; case 'IgActionSpamError': console.log('Action blocked, try again later'); break; default: console.log('Unknown error:', error.message); } }
License
This project is licensed under the MIT License. See the LICENSE file for details.
Disclaimer
This library is intended for educational purposes only. Use it responsibly and in compliance with Instagram's Terms of Service. The authors assume no liability for misuse of the library.
Support
If this library is useful to you, consider starring the repository, reporting bugs, suggesting improvements, or helping with documentation.
Changelog
v4.7.0 - New Realtime MQTT System
Complete realtime system rewrite using edge-mqtt.facebook.com
Added support for all Instagram realtime topics (GraphQL, Pub/Sub, Message Sync, Iris)
Dedicated parsers for each message type
Automatic reconnection with exponential backoff
Comprehensive event system for all realtime activities
Fixed all previous realtime implementation issues
Updated documentation for the new realtime system
FAQs
A pure JavaScript Instagram Private API client inspired by instagram-private-api
The npm package nodejs-insta-private-api receives a total of 1,092 weekly downloads. As such, nodejs-insta-private-api popularity was classified as popular.
We found that nodejs-insta-private-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.