Created
January 27, 2023 16:19
-
-
Save prezine/875d4253aa58ead388974f6e5f67ddb5 to your computer and use it in GitHub Desktop.
For Instagram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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}`); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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