Tools-for-Instagram
Automation scripts for Instagram
How to use it
Easy way:
1. npm install tools-for-instagram
2. create a .env file on the main directory with this fields:
IG_USERNAME=myUsername
IG_PASSWORD=myPassword
# Uncomment next line to use a proxy
# IG_PROXY=http://proxyuser:proxypassword@xxx.xxx.xxx.xxx:xxxxx
# Uncomment next line to use email verifications | sms by default
# IG_VERIFICATION=email
3. Copy the example.js on the root folder of your project from the repo
4. Execute'node example.js' to test the scripts.
Following steps:
1. Write your automation bots or copy the existent ones inside Tools-for-Instagram module
(Recommended to create a 'bots' folder in root of the project)
2. Tests the bot using 'node bots/yourBot.js'
Git way:
1. Download the repo and install dependencies using this terminal commands:
git clone https://github.com/linkfy/Tools-for-Instagram.git
cd Tools-for-Instagram
npm install
2. Rename .env_example to .env and edit the configuration.
3. Execute 'node example.js' to test the scripts.
Following steps:
1. Write your automation bots inside bots folder or use the existent ones
2. Tests the bot using 'node bots/bot.js'
Bot skills:
Wiki
https://github.com/linkfy/Tools-for-Instagram/wiki
Follow the project
You can follow the streams of the project on the Twitch channel
https://www.twitch.tv/mimi_twitchbot
Follow the development status
Follow the development status to see what's the next upcoming idea
https://trello.com/b/ZlwRr6l0/tools-for-instagram
Api mods
- Injected loggedInUser inside ig Object after login (ig.loggedInUser)
- Injected db inside ig Object after login (ig.db)
- Injected shortid generator inside ig Object
Api
Basic example
Using npm package
require("tools-for-instagram");
(async () => {
let ig = await login();
let info = await getUserInfo(ig, "Instagram");
console.log("User information, username: " + info.username);
})();
Using Git repo:
require('./src/tools-for-instagram');
(async () => {
let ig = await login();
let info = await getUserInfo(ig, "Instagram");
console.log("User information, username: " + info.username);
})();
loadConfig(loginFileName)
Load a config file from the logins folder
By default it will use the proxy from .env file if the proxy is not set on login().
let acc = loadConfig('exampleAccount');
let myAccount2 = await login(acc.account, acc.password, acc.proxy);
To avoid the default proxy from the .env file use false as a third parameter on login:
let acc = loadConfig('exampleAccount');
let myAccount2 = await login(acc.account, acc.password, false);
getUserInfo(ig, username)
Get the user information of the desired username
let info = await getUserInfo(ig, 'Instagram');
getRecentPostLikers(ig, post);
Get the last likers (max of 1000) of a post
let posts = await getUserRecentPosts(ig, username);
let likers = await getRecentPostLikers(ig, posts[0]);
getRecentPostLikersByUsername(ig, username)
Get the last likers (max of 1000) of the last post of the desired username
let likers = await getRecentPostLikersByUsername(ig,'instagram');
console.log(likers[likers.length-1]);
getFollowers(ig, username)
It will save the followers inside the outputfolder with the format "acountName_followers.json"
await getFollowers(ig, 'Instagram');
getFollowing(ig, username)
It will save the following inside the outputfolder with the format "acountName_following.json"
await getFollowing(ig, 'Instagram');
readFollowers(ig, username)
It will return the followers inside the outputfolder with the format "acountName_followers.json"
let followers = await readFollowers(ig, 'Instagram');
readFollowing(ig, username)
It will return the following inside the outputfolder with the format "acountName_following.json"
let followers = await readFollowing(ig, 'Instagram');
likeUrl(ig, username, [force: bool])
like the desired instagram Url, the like will be saved inside database.
await likeUrl(ig, 'https://www.instagram.com/p/B1gzzVpA462/');
If 'force' is set to true, when the item was already liked before it will force to continue the operation.
await likeUrl(ig, 'https://www.instagram.com/p/B1gzzVpA462/', true);
viewStoriesFromUser(ig, username)
View all the current stories of the given username
await viewStoriesFromUser(ig, 'instagram');
isTimeInRange(startTime, endTime)
Returns True or False if the current time is inside the range
await isTimeInRange("10:00", "23:00");
It is also possible to calculate night ranges between the current day and tomorrow.
await isTimeInRange("23:00", "3:00");
likeRecentHashtagsByIntervals(ig, hashtagArray, intervals, likesPerInterval, waitMinutesBetweenLikes)
Automate like actions on given array of recent hashtags feed
let likesPerInterval = 15;
let waitMinutesBetweenLikes = 3;
let intervals = [
["7:00", "8:00"],
["10:00", "11:00"],
["22:00", "23:00"],
];
let hashtagArray = [
"cats",
"dogs",
"music"
];
let likeInterval = likeRecentHashtagsByIntervals(
ig,
hashtagArray,
intervals,
likesPerInterval,
waitMinutesBetweenLikes);
It is also possible to stop the interval clearing it
clearInterval(likeInterval);
This documentation is not yet finished...
recentHashtagList(ig, hashtag)
topHashtagList(ig, hashtag)
likePost(ig, post)
recentLocationList(ig, location, [randomize: bool])
topLocationList(ig, location, [randomize: bool])
savePosts(ig, posts, filename)
followUser(ig, username)
followUserByPost(ig. post)
getLikeActivityByHours(ig, startingHour)
getFollowActivityByHours(ig, startingHour)
getUnfollowActivityByHours(ig, startingHour)
getLikeActivityFromHourToNow(ig, "12:05")
lastLikeMinutesAgo(ig)
removeCookie(ig)
followRecentHashtagsByIntervals(ig, hashtagArray, intervals, followsPerInterval, waitMinutesBetweenFollows)
viewStoriesFromId(ig, userId)
viewStoriesFromFollowing(ig, username)
viewStoriesFromFollowers(ig, username)
getUserRecentPosts(ig, username)
requestLivestream(ig)