I'm trying to make a tool that log in into Instagram account and do some jobs using requests library, but after about 7-10 attempts I got banned I think, and I got this reply:
{"message":"Please wait a few minutes before you try again.","status":"fail"}
I tried many things to unban me, I used a proxy, and I changed the user agent, but none of them worked and the ban still exists.
from uuid import uuid4
import requests
r = requests.Session()
def check(username, password):
proxies = { "https": "https://proxy:port" }
url = 'https://i.instagram.com/api/v1/accounts/login/'
headers = {'User-Agent':'Instagram 113.0.0.39.122 Android (24/5.0; 515dpi; 1440x2416; huawei/google; Nexus 6P; angler; angler; en_US)', 'Accept':'*/*', 'Cookie':'missing', 'Accept-Encoding':'gzip, deflate', 'Accept-Language':'en-US', 'X-IG-Capabilities':'3brTvw==', 'X-IG-Connection-Type':'WIFI', 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8', 'Host':'i.instagram.com'}
uid = str(uuid4())
data = {'uuid':uid, 'password':password, 'username':username, 'device_id':uid, 'from_reg':'false', '_csrftoken':'missing', 'login_attempt_countn':'0'}
req_login = r.post(url, headers=headers, data=data, allow_redirects=True, proxies=proxies)
print (req_login.text)
check("user", "password")
This is the code, but as I said before, nothing changes, the ban is there for now, but if I wait two or three days and try again, it works, and it blocks me again after number of attempts.
You need permissions to use instagram API and the limit is very strict.
You can read more and apply for permissions here: https://www.instagram.com/developer/
The reason why changing proxies / user-agent doesn't work is because the ban is tied to your account.
You'd be better off using an automation script with Frida that interacts with the Instagram app itself, rather than trying to bypass the API limit with only one account.