Skip to content

Instantly share code, notes, and snippets.

@prezine
Created January 27, 2023 16:19
Show Gist options
  • Save prezine/875d4253aa58ead388974f6e5f67ddb5 to your computer and use it in GitHub Desktop.
Save prezine/875d4253aa58ead388974f6e5f67ddb5 to your computer and use it in GitHub Desktop.
For Instagram
// This file is relative, it could be any name but the extension should be .js, as in javascript.
const Client = require('instagram-private-api').V1;
const device = new Client.Device('my_device');
const storage = new Client.CookieFileStorage(__dirname + '/cookies/my_account.json');
Client.Session.create(device, storage, 'my_username', 'my_password')
.then(session => {
return session.getAccount();
})
.then(account => {
console.log(`Username: ${account.params.username}`);
console.log(`Number of followers: ${account.params.follower_count}`);
})
.catch(err => {
console.log(`Error: ${err}`);
});
# Copy and paste this code in shell / terminal after you've navigated into the code directory, this file doesn't matter, only the npm code below does.
npm install instagram-private-api
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment