Use private Instagram API for free
TL;DR I’ll show you how to use private Instagram API with couple POST requests.
You may ask me “How is it possible to automate Instagram if this popular social network doesn’t have a public API?“ Well, there are two possible ways:
- Parsing the Instagram.com webpage and automate “pressing buttons” with tools like Selenium. There are some tools that can do this, the most popular one is my friend’s InstaPy by TimG.
- Find leaked signature keys from old Instagram apps for Android and perform POST requests manually.
While the first one is the most stable and reliable way (Instagram is unlikely to be able to change the site beyond bots recognition, I think no one can), the second one is most extensive: you can automate almost anything you can see in the mobile app, while the web version has very limited functionality. I said “almost” because some endpoints may be not yet implemented at the moment when the old Instagram app version had been hacked. Moreover, someday old Instagram API may be finally deprecated — they are migrating to Graph API to tackle the big scale problems.
To be honest, my Instabot library is more than 3 year old now and the cracked signature keys are still working. I don’t think Instagram will deprecate old devices with old API bacause the Android devices adoption rate is very low. I believe we have at least couple more years to use these leacked signature keys.
It is quite easy to perform private Instagram API requests, the hardest part is to grant access to it —to login. Since logged in, you can call any endpoint with simple GET or POST requests. Don’t forget that no one likes frequent requests — don’t try to like media or follow users several times per second, because you would be banned for sure.
I’ll show you how to login into Instagram with your login and password and how to perform several basic actions with just some GET and POST requests. For this demonstration make sure that you’ve disabled your 2FA.
How to login into Instagram private API
For demonstration purposes, I’ll use Python and it’s library requests because the code would (at least should) be very straightforward even to those who do not know Python. Also, I’ll use some auxiliary and encryption libraries that can be found for any programming language.
Let’s start with some constant values that I use to login into Instagram. In the Gists attached, you can find the link to some more User agents that can be used here. Don’t forget to add your Instagram username and password — no one can login into Instagram without them ;)
Next, let’s move on to the functions that will be used for request params signing. To be honest, I don’t understand why some of them are used, but since they allow me to login into Instagram, I’m ok with that.
And the final part: the request with all parameters and methods that we’ve prepared. All the magic is happening down below.
That’s it. If the latest
assert line hadn’t thrown an error — you are logged in. Now with within this session, you can call Instagram endpoints: check Instabot library for some Instagram endpoints inspiration.
What if you don’t want to install anything on your laptop or even hate programming, but you still really really frustrating by liking a huge amount of photos that were published by your girlfriend or friends? Well, I have something to offer to you.
To kick off, you’ll need a fresh Chrome browser and our browser extension (its source code can be found here). After installation, you will be asked to enter your Instagram credentials, but don’t worry — we store all your data inside your browser (feel free to audit our source code if you don’t believe). For now, you can’t log in the account with enabled 2FA, but I really want to fix it soon. Next, go to our dashboard and start pushing buttons!
There are a lot of (paid) Instagram automation services. But they run scripts on their side, while in Instagram Yourself everything is happening on your side, you control every request that the scripts do and (the most important) our code is available on GitHub. Did I forget to mention that this is also completely free?
Thanks for reading! Leave a comment if you’d like to know something more about Instagram scripting. See you!