
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
instagram-client-web
Advanced tools
A robust Instagram API client library for Node.js that emulates browser interactions
A robust, feature-rich Instagram API client library for Node.js that emulates browser interactions and provides comprehensive Instagram functionality.
npm install instagram-api-client
const InstagramClient = require('instagram-api-client');
const client = new InstagramClient({
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
timeout: 30000,
enableEncryption: true
});
// Authenticate with username and password
const sessionData = await client.authenticate('username', 'password', 'email@example.com');
console.log('Logged in as:', sessionData.username);
// Send a direct message
await client.sendDirectMessage('recipient_id', 'Hello!', { encrypt: true });
// Send a media message
await client.sendMediaMessage('recipient_id', 'https://example.com/image.jpg', 'Check this out!');
// Create a group chat
const group = await client.createGroup(['user1_id', 'user2_id'], 'My Group');
// Send a group message
await client.sendGroupMessage(group.id, 'Hello everyone!');
// React to a post
await client.sendPostReaction('post_id', 'love');
// React to a story
await client.sendStoryReaction('story_id', 'like');
// Listen for events
client.on('authenticated', (sessionData) => {
console.log('Logged in as:', sessionData.username);
});
client.on('message-received', (message) => {
console.log('New message:', message.text);
});
client.on('story-created', (story) => {
console.log('Story created:', story.id);
});
client.on('group-created', (group) => {
console.log('Group created:', group.name);
});
// Get conversations
const conversations = await client.getConversations(20);
// Get messages from a specific conversation
const messages = await client.getDirectMessages(50, 'thread_id');
// Mark message as seen
await client.markAsSeen('thread_id', 'item_id');
// Delete a message
await client.deleteMessage('thread_id', 'item_id');
// Queue messages for rate limiting
await client.queueMessage('recipient_id', 'Queued message');
// Get all groups
const groups = await client.getGroups(20);
// Add participants to group
await client.addParticipants('group_id', ['user1_id', 'user2_id']);
// Remove participants from group
await client.removeParticipants('group_id', ['user1_id']);
// Update group name
await client.updateGroupName('group_id', 'New Group Name');
// Mute group
await client.muteGroup('group_id', true);
// Leave group
await client.leaveGroup('group_id');
// Get stories
const stories = await client.getStories();
// Get reels
const reels = await client.getReels();
// View a story
await client.viewStory('story_id', 'user_id');
// Create a story
const story = await client.createStory('https://example.com/image.jpg', 'My story caption');
// Reply to a story
await client.replyToStory('story_id', 'Great story!');
// Share a story
await client.shareStory('story_id', ['user1_id', 'user2_id']);
// Get story highlights
const highlights = await client.getStoryHighlights('user_id');
// Add story to highlights
await client.addToHighlights('story_id', 'highlight_id');
// React to different content types
await client.reactToPost('post_id', 'love');
await client.reactToStory('story_id', 'like');
await client.reactToReel('reel_id', 'haha');
await client.reactToComment('comment_id', 'wow');
// Remove reactions
await client.removeReaction('post_id');
await client.removeStoryReaction('story_id');
await client.removeCommentReaction('comment_id');
// Get reaction lists
const postReactions = await client.getPostReactions('post_id');
const storyReactions = await client.getStoryReactions('story_id');
const commentReactions = await client.getCommentReactions('comment_id');
// Bulk reactions
const postIds = ['post1', 'post2', 'post3'];
await client.bulkReactToPosts(postIds, 'like');
const storyIds = ['story1', 'story2', 'story3'];
await client.bulkReactToStories(storyIds, 'love');
// Search for users
const users = await client.searchUsers('username', 20);
// Get user information
const userInfo = await client.getUserInfo('user_id');
const { InstagramEncryption } = require('instagram-api-client');
const encryption = new InstagramEncryption();
// Generate RSA key pair
const keys = encryption.generateRSAKeyPair(2048);
// Hybrid encryption (AES + RSA)
const encrypted = encryption.hybridEncrypt('secret message', keys.publicKey);
const decrypted = encryption.hybridDecrypt(encrypted, keys.privateKey);
// Generate ECDH key pair
const ecdhKeys = encryption.generateECDHKeyPair('secp256k1');
// Derive shared secret
const sharedSecret = encryption.deriveSharedSecret(
ecdhKeys.privateKey,
'other_public_key',
'secp256k1'
);
// Encrypt with integrity check
const encryptedWithIntegrity = encryption.encryptWithIntegrity('message', 'key');
const decryptedWithIntegrity = encryption.decryptWithIntegrity(encryptedWithIntegrity, 'key');
const client = new InstagramClient({
// Browser emulation
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
// Network settings
timeout: 30000,
retryAttempts: 3,
proxy: 'http://proxy.example.com:8080',
// Security
enableEncryption: true,
// Rate limiting
rateLimitDelay: 1000,
maxConcurrentRequests: 5
});
The library emulates a real browser with:
client.on('error', (error) => {
console.error('Client error:', error);
});
client.on('auth-error', (error) => {
console.error('Authentication error:', error);
});
client.on('message-error', (error) => {
console.error('Message error:', error);
});
// Handle specific errors
try {
await client.sendDirectMessage('invalid_id', 'Hello');
} catch (error) {
if (error.message.includes('not found')) {
console.log('User not found');
} else if (error.message.includes('rate limit')) {
console.log('Rate limited, waiting...');
}
}
Run the test suite:
npm test
Or run the demo:
node test/test.js
instagram-api-client/
βββ src/
β βββ client/
β β βββ InstagramClient.js # Main client class
β βββ auth/
β β βββ InstagramAuth.js # Authentication system
β βββ messaging/
β β βββ InstagramMessaging.js # Direct messaging
β βββ groups/
β β βββ InstagramGroups.js # Group management
β βββ stories/
β β βββ InstagramStories.js # Stories and reels
β βββ reactions/
β β βββ InstagramReactions.js # Reactions system
β βββ encryption/
β β βββ InstagramEncryption.js # Encryption utilities
β βββ utils/
β βββ BrowserEmulator.js # Browser emulation
βββ test/
β βββ test.js # Test suite
βββ package.json
βββ README.md
MIT License - see LICENSE file for details
This library is for educational and legitimate use only. Please respect Instagram's Terms of Service and use responsibly. The authors are not responsible for any misuse of this library.
Stay updated with the latest features and security patches by regularly updating the library:
npm update instagram-api-client
Made with β€οΈ for the Instagram developer community
FAQs
A robust Instagram API client library for Node.js that emulates browser interactions
We found that instagram-client-web 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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.