
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
ig-web-node-client
Advanced tools
A comprehensive Node.js library for Instagram Web API with support for authentication, feeds, direct messages, media upload, stories, and real-time events
A powerful and comprehensive Node.js library for interacting with Instagram's Web API. Built with modern JavaScript and designed to be simple, reliable, and feature-complete.
npm install instagram-web-api
const { InstagramClient } = require('instagram-web-api');
const client = new InstagramClient();
// Login
async function main() {
try {
const user = await client.login('your_username', 'your_password');
console.log('Logged in as:', user.username);
// Get timeline feed
const timeline = client.feed.timeline();
const posts = await timeline.getItems();
console.log('Timeline posts:', posts.length);
// Send a DM
await client.direct.sendText('user_id', 'Hello from Instagram API!');
} catch (error) {
console.error('Error:', error.message);
}
}
main();
const client = new InstagramClient();
const user = await client.login('username', 'password');
try {
await client.login('username', 'password');
} catch (error) {
if (error.name === 'AuthenticationError' && error.details.identifier) {
// Enter 2FA code
const code = '123456'; // Get from user input
const user = await client.twoFactorLogin(code, error.details.identifier);
}
}
// Export session
const sessionData = client.exportState();
localStorage.setItem('instagram_session', sessionData);
// Import session
const sessionData = localStorage.getItem('instagram_session');
client.importState(sessionData);
const userInfo = await client.user.getById('user_id');
const userByUsername = await client.user.getByUsername('username');
await client.friendship.follow('user_id');
await client.friendship.unfollow('user_id');
const followers = client.feed.followers('user_id');
const following = client.feed.following('user_id');
const followersList = await followers.getItems();
const followingList = await following.getItems();
const fs = require('fs');
const photoBuffer = fs.readFileSync('photo.jpg');
const result = await client.upload.photo({
buffer: photoBuffer,
caption: 'Check out this amazing photo! 📸'
});
const videoBuffer = fs.readFileSync('video.mp4');
const result = await client.upload.video({
buffer: videoBuffer,
caption: 'Cool video! 🎥',
thumbnail: thumbnailBuffer // Optional
});
await client.media.like('media_id');
await client.media.unlike('media_id');
await client.media.comment('media_id', 'Great post! 👍');
const timeline = client.feed.timeline();
const posts = await timeline.getItems();
// Load more posts
const morePosts = await timeline.getItems();
const userFeed = client.feed.user('user_id');
const userPosts = await userFeed.getItems();
const taggedPosts = await userFeed.getTaggedPosts();
const reels = await userFeed.getReels();
const hashtagFeed = client.feed.hashtag('nature');
const posts = await hashtagFeed.getItems();
const locationFeed = client.feed.location('location_id');
const posts = await locationFeed.getItems();
// Text message
await client.direct.sendText('user_id', 'Hello there! 👋');
// Photo message
await client.direct.sendPhoto('user_id', photoBuffer);
// Video message
await client.direct.sendVideo('user_id', videoBuffer);
// Share post
await client.direct.sharePost('user_id', 'media_id');
const inbox = client.feed.directInbox();
const threads = await inbox.getItems();
const thread = client.feed.directThread('thread_id');
const messages = await thread.getItems();
const stories = client.feed.story();
const storyItems = await stories.getItems();
const storyResult = await client.story.upload({
buffer: imageBuffer,
type: 'photo' // or 'video'
});
// Enable real-time events
await client.startRealtime();
// Listen for new messages
client.on('message', (message) => {
console.log('New message:', message);
});
// Listen for typing indicators
client.on('typing', (data) => {
console.log('User typing:', data);
});
// Listen for presence updates
client.on('presence', (data) => {
console.log('User presence:', data);
});
const { InstagramError, AuthenticationError, RateLimitError } = require('instagram-web-api');
try {
// Your Instagram API calls
} catch (error) {
if (error instanceof AuthenticationError) {
console.log('Authentication failed:', error.message);
} else if (error instanceof RateLimitError) {
console.log('Rate limited. Wait before retrying.');
} else if (error instanceof InstagramError) {
console.log('Instagram API error:', error.message);
}
}
const client = new InstagramClient({
proxy: {
host: 'proxy.example.com',
port: 8080,
auth: {
username: 'proxy_user',
password: 'proxy_pass'
}
}
});
// Generate device for specific username
client.generateDevice('username');
// Or use existing device data
client.device.import({
deviceId: 'your_device_id',
uuid: 'your_uuid',
// ... other device properties
});
The library includes built-in rate limiting to prevent Instagram from blocking your requests:
This library is for educational purposes only. Make sure to comply with Instagram's Terms of Service when using this library. The authors are not responsible for any misuse or violations.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.
If you encounter any issues, please report them on our GitHub Issues page.
Made with ❤️ for the Instagram developer community
FAQs
A comprehensive Node.js library for Instagram Web API with support for authentication, feeds, direct messages, media upload, stories, and real-time events
The npm package ig-web-node-client receives a total of 0 weekly downloads. As such, ig-web-node-client popularity was classified as not popular.
We found that ig-web-node-client 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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.