Settings

Liking

This method is only needed for the interact_by_... actions. Posts will be liked by default when using like_by_... actions.

# ~70% of the by InstaPy viewed posts will be liked
session.set_do_like(enabled=True, percentage=70)

Commenting

# enable comments (by default enabled=False) and set commenting probability to 25% so ~ every 4th image will be commented on
session.set_do_comment(enabled=True, percentage=25)
# Configure a simple list of optional comments, one will be selected at random when commenting:
session.set_comments(['Awesome', 'Really Cool', 'I like your stuff'])

Or configure conditional comments to provide a more contextual commenting based on the caption of the image: Conditional comments are created as a list of dictionaries, each one contains a definition of mandatory words and a list of comments. The list of conditional comments is scanned until the first item that satisfies the mandatory words condition is found and then one of the comments associated with that item is selected at random to be used. This can best be understood with an example:

comments=[
# either "icecave" OR "ice_cave" will satisfy this:
{'mandatory_words': ["icecave", "ice_cave"], 'comments': ["Nice shot. Ice caves are amazing", "Cool. Aren't ice caves just amazing?"]},
# either "high_mountain" OR ("high" AND "mountain") will satisfy this:
{'mandatory_words': ["high_mountain", ["high", "mountain"]], 'comments': ["I just love high mountains"]},
# Only ("high" AND "tide" together) will satisfy this:
{'mandatory_words': [["high", "tide"]], 'comments': ["High tides are better than low"]}
# Only "summer" AND ("lake" OR "occean") will satisfy this:
{'mandatory_words': [["summer", ["lake", "occean"]], 'comments': ["Summer fun"]}
]
session.set_comments(comments)

You can also set comments for specific media types (Photo / Video)

session.set_comments(['Nice shot!'], media='Photo')
session.set_comments(['Great Video!'], media='Video')
# and you can add the username of the poster to the comment by using
session.set_comments(['Nice shot! @{}'], media='Photo')

Emoji Support

To use an emoji just add an u in front of the opening apostrophe:

session.set_comments([u'This post is ๐Ÿ”ฅ',u'More emojis are always better ๐Ÿ’ฏ',u'I love your posts ๐Ÿ˜๐Ÿ˜๐Ÿ˜']);
# or
session.set_comments([u'Emoji text codes are also supported :100: :thumbsup: :thumbs_up: \u2764 ๐Ÿ’ฏ๐Ÿ’ฏ']);

Emoji text codes are implemented using 2 different naming codes. A complete list of emojis codes can be found on the Python Emoji Github, but you can use the alternate shorted naming scheme found for Emoji text codes here. Note: Every Emoji has not been tested. Please report any inconsistencies.

Following

# default enabled=False, follows ~ 10% of the users from the images, times=1
# (only follows a user once (if unfollowed again))
session.set_do_follow(enabled=True, percentage=10, times=2)

Smart Hashtags

# Generate smart hashtags based on https://displaypurposes.com ranking,
# banned and spammy tags are filtered out.
# (limit) defines amount limit of generated hashtags by hashtag
# (sort) sort generated hashtag list 'top' and 'random' are available
# (log_tags) shows generated hashtags before use it
# (use_smart_hashtags) activates like_by_tag to use smart hashtags
session.set_smart_hashtags(['cycling', 'roadbike'], limit=3, sort='top', log_tags=True)
session.like_by_tags(amount=10, use_smart_hashtags=True)

Smart Location Hashtags

Generate smart hashtags based on https://displaypurposes.com/map ranking. Banned and spammy tags are filtered out.

Use_smart_location_hashtags activates like_by_tag to use smart hashtags
session.set_smart_location_hashtags(['204517928/chicago-illinois', '213570652/nagoya-shi-aichi-japan'], radius=20, limit=10)
session.like_by_tags(amount=10, use_smart_location_hashtags=True)

Parameters

radius: Radius around the location in Miles limit: Defines amount limit of generated hashtags by hashtag log_tags: Shows generated hashtags before use it (default is True)

Quota Supervisor

Take full control of the actions with the most sophisticated approaches
session.set_quota_supervisor(enabled=True, sleep_after=["likes", "comments_d", "follows", "unfollows", "server_calls_h"], sleepyhead=True, stochastic_flow=True, notify_me=True,
peak_likes_hourly=57,
peak_likes_daily=585,
peak_comments_hourly=21,
peak_comments_daily=182,
peak_follows_hourly=48,
peak_follows_daily=None,
peak_unfollows_hourly=35,
peak_unfollows_daily=402,
peak_server_calls_hourly=None,
peak_server_calls_daily=4700)

Parameters:

enabled: put True to activate or False to deactivate supervising any time

If you don't want to supervise likes at all, simply remove peak_likes parameter OR use peak_likes=(None, None). Once likes reach peak, it will jump every other like, yet, will do all available actions (e.g. follow or unfollow).

  • Only server calls does not jump, it exits the program once reaches the peak.

    Although, you can put server calls to sleep once reaches peak, read sleep_after parameter.

  • Every action will be jumped separately after reaching it's peak, except comments. Cos commenting without a like isn't welcomed that's why as like peak is reached, it will jump comments, too.

sleep_after: is used to put InstaPy to sleep after reaching peak rather than jumping the action (or exiting- for server calls) Any action can be included ["likes", "comments", "follows", "unfollows", "server_calls"]. As if you want to put sleep only after reaching hourly like peak, put "likes_h" OR put "likes_d" for sleeping only after reaching daily like peak. such as,

  • sleep_after=['follows_h'] will sleep after reaching hourly follow peak
  • sleep_after=['likes_d', 'follows', 'server_calls_h'] will sleep after reaching daily like peak, follow peaks (hourly and daily) and hourly server call peak.

Notice: there can be either "likes" (for both hourly and daily sleep) OR "likes_h" (for hourly sleep only) OR "likes_d" (for daily sleep only).

Once gone to sleep, it will wake up as new hour/day (according to the interval) arrives AND continue the activity.

sleepyhead: can help to sound more humanly which will wake up a little bit later in a randomly chosen time interval around accurate wake up time.

e.g., if remaining time is 17 minutes, it will sleep 20 minutes instead (random values each time)..

stochastic_flow: can provide smooth peak value generation by your original values.

  • Every ~hour/day it will generate peaks at close range around your original peaks (but below them).

    e.g., your peak likes hourly is 45, next hour that peak will be 39, the next 43, etc.

notify_me: sends toast notifications (directly to your OS) about the important states of supervisor- sleep, wake up and exit messages.

Mini-Examples:

  • Claudio has written a new ๐Ÿ˜Š quickstart script where it mostly put likes and comments. He wants the program to comment safely cos he is afraid of exceeding hourly & daily comment limits,
session.set_quota_supervisor(enabled=True, peak_comments_daily=21, peak_comments_hourly=240)

That's it! When it reaches the comments peak, it will just jump all of the comments and will again continue to put comments when is available [in the next hour/day].

  • Alicia has a 24/7 ๐Ÿ•ฆ working quickstart script and would like to keep server calls in control to AVOID excessive amount of requests to the server in hourly basis, also,
    • wants the program to sleep after reaching hourly server calls peak: adds "server_calls_h" into sleep_after parameter
    • wants the program to wake up a little bit later than real sleep time [once reaches the peaks]: uses sleepyhead=True parameter
session.set_quota_supervisor(enabled=True, peak_server_calls_daily=490, sleep_after=["server_calls_h"], sleepyhead=True)

It will sleep after hourly server calls reaches its peak given - 490 and never allow one more extra request to the server out of the peak and wake up when new hour comes in WHILST daily server calls will not be supervised at all- as Alicia wishes.

  • Sam has a casual ๐Ÿฆ† quickstart script full of follow/unfollow features and he wants to do it safely, also,
    • is gonna run on local computer and wants to receive toast notifications ๐Ÿ˜‹ on supervising states: uses notify_me parameter
    • wants QS to randomize his pre-defined peak values [at close range] each new hour/day: uses stochastic_flow=True parameter
    • wants the program to sleep after reaching hourly follow peak and daily unfollow peak: adds "follows_h" and "unfollows_d"into sleep_after parameter
session.set_quota_supervisor(enabled=True, peak_follows_daily=560, peak_follows_hourly=56, peak_unfollows_hourly=49, peak_unfollows_daily=550, sleep_after=["follows_h", "unfollows_d"], stochastic_flow=True, notify_me=True)

Big Hint: Find your NEED ๐Ÿค” and supervise it!

  • EITHER fully configure QS to supervise all of the actions all time
  • OR just supervise the desired action(s) in desired interval(s) [hourly and/or daily] per your need

Restricting Likes

session.set_dont_like(['#exactmatch', '[startswith', ']endswith', 'broadmatch'])

.set_dont_like searches the description and owner comments for hashtags and won't like the image if one of those hashtags are in there

You have 4 options to exclude posts from your InstaPy session:

  • words starting with # will match only exact hashtags (e. g. #cat matches #cat, but not #catpic)
  • words starting with [ will match all hashtags starting with your word (e. g. [cat matches #catpic, #caturday and so on)
  • words starting with ] will match all hashtags ending with your word (e. g. ]cat matches #mycat, #instacat and so on)
  • words without these prefixes will match all hashtags that contain your word regardless if it is placed at the beginning, middle or end of the hashtag (e. g. cat will match #cat, #mycat, #caturday, #rainingcatsanddogs and so on)

Ignoring Restrictions

# will ignore the don't like if the description contains
# one of the given words
session.set_ignore_if_contains(['glutenfree', 'french', 'tasty'])

Ignoring Users

# completely ignore liking images from certain users
session.set_ignore_users(['random_user', 'another_username'])

Excluding friends

# will prevent commenting on and unfollowing your good friends (the images will
# still be liked)
session.set_dont_include(['friend1', 'friend2', 'friend3'])

Mandatory Words

session.set_mandatory_words(['#food', '#instafood'])

.set_mandatory_words searches the description, location and owner comments for words and will like the image if the mandatory words condition is met. The mandatory words list can be a simple list of words or a nested structure of lists within lists.

  • When using a simple word list the condition between the words is "OR" so if any of the words from the list exists in the image text it will be matched.
  • When using a nested list of lists the top level list condition is "OR" and the condition alternates between "AND" and "OR" with every nesting level.

For example:

# either "icecave" or "ice_cave" will satisfy this:
["icecave", "ice_cave"]
# either "high_mountain" OR ("high" AND "mountain") will satisfy this:
["high_mountain", ["high", "mountain"]]
# Only ("high" AND "tide" together) will satisfy this:
[["high", "tide"]]
# Only "summer" AND ("lake" OR "occean") will satisfy this:
[["summer", ["lake", "occean"]]

Mandatory Language

session.set_mandatory_language(enabled=True, character_set=['LATIN'])
session.set_mandatory_language(enabled=True, character_set=['LATIN', 'CYRILLIC'])

.set_mandatory_language restrict the interactions, liking and following if any character of the description is outside of the character sets you selected (the location is not included and non-alphabetic characters are ignored). For example if you choose LATIN, any character in Cyrillic will flag the post as inappropriate. If you choose 'LATIN' and 'CYRILLIC', any other character sets will flag the post as inappropriate as well.

  • Available character sets: LATIN, GREEK, CYRILLIC, ARABIC, HEBREW, CJK, HANGUL, HIRAGANA, KATAKANA and THAI

Don't unfollow active users

# Prevents unfollow followers who have liked one of your latest 5 posts
session.set_dont_unfollow_active_users(enabled=True, posts=5)

Blacklist Campaign

# Controls your interactions by campaigns.
# ex. this week InstaPy will like and comment interacting by campaign called
# 'soccer', next time InstaPy runs, it will not interact again with users in
# blacklist
# In general, this means that once we turn off the soccer_campaign again, InstaPy
# will have no track of the people it interacted with about soccer.
# This will help you target people only once but several times for different campaigns
session.set_blacklist(enabled=True, campaign='soccer_campaign')
session.set_do_comment(True, percentage=50)
session.set_comments(['Neymar is better than CR7', 'Soccer is cool'])
session.like_by_tags(['soccer', 'cr7', 'neymar'], amount=100, media='Photo')

Simulation

During indirect data retrieval, simulation happens to provide a genuine activity flow triggered by a wise algorithm.

To turn off simulation or to decrease its occurrence frequency, use set_simulation setting:

#use the value of `False` to permanently turn it off
session.set_simulation(enabled=False)
#use a desired occurrence percentage
session.set_simulation(enabled=True, percentage=66)

Skipping user for private account, no profile picture, business account, bio keywords

This is used to skip users with certain condition

session.set_skip_users(skip_private=True,
private_percentage=100,
skip_no_profile_pic=False,
no_profile_pic_percentage=100,
skip_business=False,
skip_non_business=False,
business_percentage=100,
skip_business_categories=[],
dont_skip_business_categories=[],
skip_bio_keyword=[],
mandatory_bio_keywords=[])
Skip private account

This is done by default

session.set_skip_users(skip_private=True,
private_percentage=100)

Will skip users that have private account, even if are followed by running account. You can set a percentage of skipping: private_percentage= 100 always skip private users private_percentage= 0 never skip private users (so set skip_private=False)

Skip users that don't have profile picture
session.set_skip_users(skip_private=True,
skip_no_profile_pic=True,
no_profile_pic_percentage=100)

Will skip users that haven't uploaded yet a profile picture You can set a percentage of skipping: no_profile_pic_percentage= 100 always skip users without profile picture no_profile_pic_percentage= 0 never skip users without profile picture (so set skip_no_profile_pic=False)

Skip users that have business account
session.set_skip_users(skip_private=True,
skip_no_profile_pic=True,
skip_business=True,
business_percentage=100)

This will skip all users that have business account activated. You can set a percentage of skipping: business_percentage= 100 always skip business users business_percentage= 0 never skip business users (so set skip_business=False)

N.B.: This business_percentage parameter works only if no skip_business_categories or dont_skip_business_categories are provided!

Skip only users that have certain business account
session.set_skip_users(skip_private=True,
skip_no_profile_pic=True,
skip_business=True,
skip_business_categories=['Creators & Celebrities'])

This will skip all business accounts that have category in given list N.B. In skip_business_categories you can add more than one category

Skip all business accounts, except from list given
session.set_skip_users(skip_private=True,
skip_no_profile_pic=True,
skip_business=True,
dont_skip_business_categories=['Creators & Celebrities'])

This will skip all business accounts except the ones that have a category that matches one item in the list of dont_skip_business_categories N.B. If both dont_skip_business_categories and skip_business_categories, InstaPy will skip only business accounts in the list given from skip_business_categories.

A list of all availlable business categories can be found here

Skip all non business and bussines accounts, except from list given
session.set_skip_users(skip_private=True,
skip_no_profile_pic=True,
skip_business=True,
skip_non_business=True,
dont_skip_business_categories=['Creators & Celebrities'])

This will skip all non business and business accounts except categories in dont_skip_business_categories.

Skip based on bio keywords
session.set_skip_users(skip_bio_keyword=["lifestyle"],
mandatory_bio_keywords=["art", "photography"])

This will skip users that have "lifestyle" and users that don't have "art" or "photography" in their bio or username. See the Mandatory Words section for details on how to define complex mandatory words conditions.

Liking based on the number of existing likes a post has

This is used to check the number of existing likes a post has and if it either exceed the maximum value set OR does not pass the minimum value set then it will not like that post
session.set_delimit_liking(enabled=True, max_likes=1005, min_likes=20)

Use enabled=True to activate and enabled=False to deactivate it, any time max is the maximum number of likes to compare min is the minimum number of likes to compare

You can use both max & min values OR one of them as you desire, just put the value of None to the one you don't want to check for., e.g.,

session.set_delimit_liking(enabled=True, max_likes=242, min_likes=None)

at this configuration above, it will not check number of the existing likes against minimum value

  • Example:
session.set_delimit_liking(enabled=True, max_likes=500, min_likes=7)

Now, if a post has more existing likes than maximum value of 500, then it will not like that post, similarly, if that post has less existing likes than the minimum value of 7, then it will not like that post...

Commenting based on the number of existing comments a post has

This is used to check the number of existing comments a post has and if it either exceed the maximum value set OR does not pass the minimum value set then it will not comment on that post
session.set_delimit_commenting(enabled=True, max_comments=32, min_comments=0)

Use enabled=True to activate and enabled=False to deactivate it, any time max is the maximum number of comments to compare min is the minimum number of comments to compare

You can use both max & min values OR one of them as you desire, just leave it out or put it to None to the one you don't want to check for., e.g.,

session.set_delimit_commenting(enabled=True, min_comments=4)
# or
session.set_delimit_commenting(enabled=True, max_comments=None, min_comments=4)

at this configuration above, it will not check number of the existing comments against maximum value

  • Example:
session.set_delimit_commenting(enabled=True, max_comments=70, min_comments=5)

Now, if a post has more comments than the maximum value of 70, then it will not comment on that post, similarly, if that post has less comments than the minimum value of 5, then it will not comment on that post...

Commenting based on mandatory words in the description or first comment

This is used to check the description of the post and the first comment of the post (some users only put tags in the comments instead of the post description) for the occurence of mandatory words before commenting. If none of the mandatory words is present, the post will not be commented.

This feature is helpful when you want to comment only on specific tags.

session.set_delimit_commenting(enabled=True, comments_mandatory_words=['cat', 'dog'])

This will only comment on posts that contain either cat or dog in the post description or first comment. You can also require sets of words. See the Commenting section for detains on how to do that

Interactions based on the number of followers and/or following a user has

This is used to check the number of followers and/or following a user has and if these numbers either exceed the number set OR does not pass the number set OR if their ratio does not reach desired potency ratio then no further interaction happens
session.set_relationship_bounds(enabled=True,
potency_ratio=1.34,
delimit_by_numbers=True,
max_followers=8500,
max_following=4490,
min_followers=100,
min_following=56,
min_posts=10,
max_posts=1000)

Use enabled=True to activate this feature, and enabled=False to deactivate it, any time delimit_by_numbers is used to activate & deactivate the usage of max & min values potency_ratio accepts values in 2 formats according to your style: positive & negative

  • potency_ratio with POSITIVE values can be used to route interactions to only potential (real) users WHOSE followers count is higher than following count (e.g., potency_ratio = 1.39) find desired potency_ratio with this formula: potency_ratio == followers count / following count (use desired counts)

    e.g., target user has 5000 followers & 4000 following and you set potency_ratio=1.35. Now it will not interact with this user, cos the user's relationship ratio is 5000/4000==1.25 and 1.25 is below desired potency_ratio of 1.35

  • potency_ratio with NEGATIVE values can be used to route interactions to only massive followers WHOSE following count is higher than followers count (e.g., potency_ratio = -1.42) find desired potency_ratio with this formula: potency_ratio == following count / followers count (use desired counts)

    e.g., target user has 2000 followers & 3000 following and you set potency_ratio = -1.7. Now it will not interact with this user, cos the user's relationship ratio is 3000/2000==1.5 and 1.5 is below desired potency_ratio of 1.7 (note that, negative - sign is only used to determine your style, nothing more)

There are 3 COMBINATIONS available to use:
  • 1. You can use potency_ratio or not (e.g., potency_ratio=None, delimit_by_numbers=True) - will decide only by your pre-defined max & min values regardless of the potency_ratio
session.set_relationship_bounds(enabled=True, potency_ratio=None, delimit_by_numbers=True, max_followers=22668, max_following=10200, min_followers=400, min_following=240)
  • 2. You can use only potency_ratio (e.g., potency_ratio=-1.5, delimit_by_numbers=False) - will decide per potency_ratio regardless of the pre-defined max & min values
session.set_relationship_bounds(enabled=True, potency_ratio=-1.5, delimit_by_numbers=False, max_followers=400701, max_following=90004, min_followers=963, min_following=2310)

apparently, once delimit_by_numbers gets False value, max & min values do not matter

  • 3. You can use both potency_ratio and pre-defined max & min values together (e.g., potency_ratio=2.35, delimit_by_numbers=True) - will decide per potency_ratio & your pre-defined max & min values
session.set_relationship_bounds(enabled=True, potency_ratio=2.35, delimit_by_numbers=True, max_followers=10005, max_following=24200, min_followers=77, min_following=500)

All of the 4 max & min values are able to freely operate, e.g., you may want to only delimit max_followers and min_following (e.g., max_followers=52639, max_following=None, min_followers=None, min_following=2240)

session.set_relationship_bounds(enabled=True, potency_ratio=-1.44, delimit_by_numbers=True, max_followers=52639, max_following=None, min_followers=None, min_following=2240)

Interactions based on the number of posts a user has

This is used to check number of posts of a user and skip if they aren't in the boundaries provided

session.set_relationship_bounds(min_posts=10,
max_posts=1000)

Users that have more than 1000 posts or less than 10 will be discarded

N.B.: It is up to the user to check that min_posts < max_posts

You can also set only one parameter at a time:

session.set_relationship_bounds(max_posts=1000)

Will skip only users that have more than 1000 posts in their feed

Custom action delays

After doing each action- like, comment, follow, unfollow or story, there is a sleep delay to provide smooth activity flow.
But you can set a custom sleep delay for each action yourself by using the set_action_delays setting!
session.set_action_delays(enabled=True,
like=3,
comment=5,
follow=4.17,
unfollow=28,
story=10)

Now it will sleep 3 seconds after putting every single like, 5 seconds for every single comment and similarly for the others..

You can also customize the sleep delay of e.g. only the likes:

session.set_action_delays(enabled=True, like=3)
Wanna go smarter? - use random_range_from and random_range_to

By just enabling randomize parameter, you can enjoy having random sleep delays at desired range, e.g.,

session.set_action_delays(enabled=True, like=5.2, randomize=True, random_range_from=70, random_range_to=140)

There, it will have a random sleep delay between 3.64 (70% of 5.2) and 7.28(140% of 5.2) seconds _each time after putting a like._

  • You can also put only the max range as- random_range_from=None, random_range_to=200 Then, the min range will automatically be 100%- the same time delay itself. And the random sleep delays will be between 5.2 and 10.4 seconds.
  • If you put only the min range as- random_range_from=70, random_range_to=None Then, the max range will automatically be 100%- the same time delay itself. And the random sleep delays will be between 3.64 and 5.2 seconds.
  • But if you put None to both min & max ranges as- random_range_from=None, random_range_to=None Then no randomization will occur and the sleep delay will always be 5.2 seconds.
  • Heh! You mistakenly put min range instead of max range as- random_range_from=100, random_range_to=70? No worries. It will automatically take the smaller number as min and the bigger one as max.
  • Make sure to use the values bigger than 0 for the random_rage percentages. E.g. random_range_from=-10, random_range_to=140 is an invalid range and no randomization will happen.
  • You can provide floating point numbers as percentages, too! random_range_from=70.7, random_range_to=200.45 will work greatly.
Note: There is a minimum default delay for each action and if you enter a smaller time of delay than the default value, then it will pick the default value. You can turn that behaviour off with safety_match parameter.
session.set_action_delays(enabled=True, like=0.15, safety_match=False)

It has been held due to safety considerations. Cos sleeping a respective time after doing actions- for example ~10 seconds after an unfollow, is very important to avoid possible temporary blocks and if you might enter e.g. 3 seconds for that without realizing the outcome...

Target Lists

This is used to parse text files containing target lists of users, hashtags, comments etc

For example:

# Like posts based on hashtags
hashtags = session.target_list("C:\\Users\\......\\hashtags.txt")
session.like_by_tags(hashtags, amount=10)
# Follow the followers of each given user
users = session.target_list("C:\\Users\\......\\users.txt")
session.follow_user_followers(users, amount=10, randomize=False)

Note that your text file should look like this:

hashtag1
hashtag2
hashtag3

or

user1
user2
user3

Functions you can use target_list with:

story_by_user, story_by_tag, like_by_tags, follow_by_tags, follow_user_followers, follow_user_following, follow_likers, follow_commenters, follow_by_list, set_skip_users, set_ignore_users, set_dont_include, interact_by_users, interact_by_users_tagged_posts, interact_user_followers, interact_user_following, interact_by_comments, set_comments, set_comment_replies, set_mandatory_words, unfollow_users