Unfollow Users who aren't following you.
See original GitHub issueGeneral Question
Form
Put an [x]
if you meet the condition, else leave [ ]
.
- I’ve searched the Issues
- I’ve read the basic concepts
- I’m using the latest version
Question
Hello, i have wrote a little code to unfollow users who aren’t following you. Can you please take a look at it, and maybe add it as a template or you can critique and improve it.
Code
A meaningful section of your code (else delete this). If you are using TypeScript replace js
with typescript
.
const { IgApiClient } = require('instagram-private-api');
const ig = new IgApiClient();
ig.state.generateDevice(process.env.USERNAME);
(async () => {
await ig.simulate.preLoginFlow();
/*
Logging in to account
*/
const auth = await ig.account.login(process.env.USERNAME, process.env.PASSWORD);
const followersFeed = ig.feed.accountFollowers(auth.pk);
const followingFeed = ig.feed.accountFollowing(auth.pk);
const followers = [
...await followersFeed.items(),
...await followersFeed.items(),
]
const following = [
...await followingFeed.items(),
...await followingFeed.items(),
]
/*
Making a new set of all user usernames
*/
const users = new Set(followers.map(({ username }) => username));
/*
Filtering the ones who aren't following you back
*/
const notFollowingYou = following.filter(({ username }) => !users.has(username));
/*
Loop through eash and unfollowing them.
(suggested change by nerix)
*/
for (const user of notFollowingYou) {
await ig.friendship.destroy(user.pk);
console.log(`unfollowed ${user.username}`)
}
})();
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to Find and Unfollow Instagram Users Who Don't Follow ...
Open your profile and navigate to your “Followers” list. · Scroll down the list to check if the user's name in question appears....
Read more >How to Unfollow Instagram Users Who Don't Follow You Back
The safest way to unfollow people on Instagram is to do it all manually. Yes, that means going through every individual account yourself...
Read more >How to Unfollow Users on Instagram Who Don't Follow You ...
If you're looking to unfollow Instagram users who don't follow you back, simply navigate to the tab on the app that says, “are...
Read more >How to unfollow users that don't follow me on Instagram - Quora
You can unfollow people who don't follow you back on Instagram by visiting their profile and clicking on 'Unfollow'. Be very careful when...
Read more >How to Unfollow Instagram Users Who Don't Follow You Back
Manually Unfollowing Instagram Users · Toggle back to your Google Sheet and paste (CTRL+V or command+V) into the Followers row. Don't worry about ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PR Submitted
This really depends on the account you’re doing this with.
Just to note: In the inapp followers-page, you can select
accounts you don't follow back
, however it’s not supported in this library.Don’t do this. This is only possible if you know how many followers the account has. You should use a function. It can be generic over the item of a feed. Here is an example (Comment).
This code works but it will probably break if there are too many users,
await