Introduction to the InstaPy

InstaPy is a bot to automate Instagram Interactions like follow accounts, unfollow accounts, like posts, comments on posts.

3 min read

InstaPy is a bot to automate the Instagram Interactions like follow accounts, unfollow accounts, like posts, comments on posts. In simple and easy words we can say that it is an Automation Script for “farming” Likes, Comments, and Followers on Instagram. It is written and developed by Tim Großmann and its official repository is available on GitHub.



Official GitHub Repository of InstaPy

A simple overview of basic quickstart file

""" Quickstart script for InstaPy usage """

# imports
from instapy import InstaPy
from instapy import smart_run
from instapy import set_workspace


# set workspace folder at desired location (default is at your home folder)
set_workspace(path=None)

# get an InstaPy session!
session = InstaPy()

with smart_run(session):
    # general settings
    session.set_dont_include(["friend1", "friend2", "friend3"])

    # activity
    session.like_by_tags(["natgeo"], amount=10)


List of Action we can perform using InstaPy

  1. Basic follow & unfollow activity
  2. Follow unfollow and send telegram message
  3. Good commenting strategy and new qs system
  4. Good usage of blacklist
  5. Like by tag interact unfollow
  6. Massive follow then unfollow works non stop
  7. Playing around with quota supervisor
  8. Super simple setting for crontab
  9. Simple interaction good for beginners
  10. Stylish unfollow tips and like by tags

Language Used and its Documentation

InstaPy is written and implemented in Python using the Selenium module. Since the InstaPy is the python script so it uses the PyPI(Python Package Index). Package Manager to get installed on any device or OS. PyPi contains all the official documentation of the InstaPy.

Official PyPi Documentation of InstaPy

How it works?

InstaPy consists of python scripts that run and automate the browser with the help of selenium. Below given is the basic follow and unfollow template of InstaPy. By using this you can follow and unfollow accounts on Instagram.

# login credentials
insta_username = '' //Enter your username here
insta_password = '' //Enter your password here

Enter you login credentials and run the script. Whoa! it will start following the Instagram accounts automatically.

Basic follow-unfollow activity python script

"""
This template is written by @cormo1990

What does this quickstart script aim to do?
- Basic follow/unfollow activity.

NOTES:
- I don't want to automate comment and too much likes because I want to do
this only for post that I really like the content so at the moment I only
use the function follow/unfollow.
- I use two files "quickstart", one for follow and one for unfollow.
- I noticed that the most important thing is that the account from where I
get followers has similar contents to mine in order to be sure that my
content could be appreciated. After the following step, I start unfollowing
the user that don't followed me back.
- At the end I clean my account unfollowing all the users followed with
InstaPy.
"""

# imports
from instapy import InstaPy
from instapy import smart_run

# login credentials
insta_username = ''
insta_password = ''

# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username,
                  password=insta_password,
                  headless_browser=False)

with smart_run(session):
    """ Activity flow """
    # general settings
    session.set_relationship_bounds(enabled=True,
                                    delimit_by_numbers=True,
                                    max_followers=4590,
                                    min_followers=45,
                                    min_following=77)

    session.set_dont_include(["friend1", "friend2", "friend3"])
    session.set_dont_like(["pizza", "#store"])

    # activities

    """ Massive Follow of users followers (I suggest to follow not less than
    3500/4000 users for better results)...
    """
    session.follow_user_followers(['user1', 'user2', 'user3'], amount=800,
                                  randomize=False, interact=False)

    """ First step of Unfollow action - Unfollow not follower users...
    """
    session.unfollow_users(amount=500, InstapyFollowed=(True, "nonfollowers"),
                           style="FIFO",
                           unfollow_after=12 * 60 * 60, sleep_delay=601)

    """ Second step of Massive Follow...
    """
    session.follow_user_followers(['user1', 'user2', 'user3'], amount=800,
                                  randomize=False, interact=False)

    """ Second step of Unfollow action - Unfollow not follower users...
    """
    session.unfollow_users(amount=500, InstapyFollowed=(True, "nonfollowers"),
                           style="FIFO",
                           unfollow_after=12 * 60 * 60, sleep_delay=601)

    """ Clean all followed user - Unfollow all users followed by InstaPy...
    """
    session.unfollow_users(amount=500, InstapyFollowed=(True, "all"),
                           style="FIFO", unfollow_after=24 * 60 * 60,
                           sleep_delay=601)

    """ Joining Engagement Pods...
    """
    photo_comments = ['Nice shot! @{}',
        'Awesome! @{}',
        'Cool :thumbsup:',
        'Just incredible :open_mouth:',
        'What camera did you use @{}?',
        'Love your posts @{}',
        'Looks awesome @{}',
        'Nice @{}',
        ':raised_hands: Yes!',
        'I can feel your passion @{} :muscle:']

    session.set_do_comment(enabled = True, percentage = 95)
    session.set_comments(photo_comments, media = 'Photo')
    session.join_pods(topic='food', engagement_mode='no_comments')
    ```