Introducing go-instabot

Thibaud Ducasse
ITNEXT
Published in
3 min readMay 8, 2018

--

While I’m not a heavy Instagram user, my girlfriend is. She loves photography and uses Instagram to publish her pictures. One day, she read a medium article by Tim Grossmann where he explains how he created a bot to automate the boring parts of Instagram: liking and following people that are related to what you do. If you haven’t read it, go ahead, it’s very well documented.

She asked me if I could write something similar, something she could use without even knowing how to write code, and I came up with go-instabot!

Requirements

The requirements were at the time rather simple:

  • the bot has to be able to like and follow pictures by using the “explore by tag” feature;
  • it will only do so if the user is “not too big, but big enough” (has to have a number of followers between two set values).

And that’s it! By doing so, if we believe Tim Grossmann’s experiment, people come to your profile and “like back” or “follow back”!

Find a way to request Instagram’s API

To be able to automate all this, I needed to find a way to access Instagram’s API. The first option, and the one Tim Grossmann chose, is to do everything with Selenium. While this is fine, I did not really like the idea since I wanted to learn Go at the time.

I chose to go the other way: find a public API. Since I was writing the bot in Go, I was glad to find the excellent GoInsta, that seemed to solve all the problems I could encounter.

Let’s make it more interesting

I decided to refine the requirements a little bit, and have fun with Go. Here’s what I chose to add:

  • not only can you like and follow pictures, but you can also comment on a picture, out of a list of prewritten comments;
  • the bot will send an email with a recap when it’s done;
  • there are different boundaries for each action. For example, you can decide to like a picture only if the user has between 10 and 1000 followers, but follow only if this number is between 500 and 1000;
  • you can put as many tags as you want, and for each tag, you can set a number of likes, follows, and comments;
  • bonus option: how about cleaning your account once in a while? You can synchronize your lists of followers and following, and unfollow those that do not follow back.

Config

I decided to simplify it to the maximum. Basically, you download the bot, then you have one central config file:

How to run

I decided to separate the script into two parts, with the two following command-line options:

  • -run: main option, actually used to launch the script;
  • -sync: unfollow users that don’t follow back.

Other options exist, I invite you to read the README if you are interested!

Final note

I used this bot as a practical way to learn Go. My code is probably not optimal, and I’m open to contributions and comments!

If you want to learn more about go-instabot or read the code, the script is open source.

--

--