subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.37k stars 684 forks source link

" too many 429 error responses " in login request #1287

Open farhadyazdani401 opened 1 year ago

farhadyazdani401 commented 1 year ago

i have error " too many 429 error responses " when i request to login. it was workin fine before upgrading instagrapi. what's the problem?

100rmk commented 1 year ago

I have a similar problem, don't think it depends on the library, most likely the problem is in the Instagram API

farhadyazdani401 commented 1 year ago

I have a similar problem, don't think it depends on the library, most likely the problem is in the Instagram API

before i upgrade lib, the lib was automatically ignoring 429 error but now doesn't do it

adw0rd commented 1 year ago

@farhadyazdani401 please help me fix this if you can reproduce the problem

farhadyazdani401 commented 1 year ago

@farhadyazdani401 please help me fix this if you can reproduce the problem

i simply use code below to login:

cl = Client() time.sleep(random.randint(1,5)) cl.login(username, password)

and then i get this error:

Traceback (most recent call last): File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen( ^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen return self.urlopen( ^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen return self.urlopen( ^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen return self.urlopen( ^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 868, in urlopen retries = retries.increment(method, url, response=response, _pool=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='i.instagram.com', port=443): Max retries exceeded with url: /api/v1/accounts/contact_point_prefill/ (Caused by ResponseError('too many 429 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "E:\py\insta\Bot\ex.py", line 57, in cl.login(usernam, password) File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\auth.py", line 383, in login self.pre_login_flow() File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\auth.py", line 47, in pre_login_flow self.set_contact_point_prefill("prefill") File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\auth.py", line 150, in set_contact_point_prefill
return self.private_request("accounts/contact_point_prefill/", data, login=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\private.py", line 480, in private_request raise e File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\private.py", line 465, in private_request self._send_private_request(endpoint, kwargs) File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\private.py", line 313, in _send_private_request
response = self.private.post( ^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 635, in post return self.request("POST", url, data=data, json=json,
kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 587, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 701, in send r = adapter.send(request, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 556, in send raise RetryError(e, request=request) requests.exceptions.RetryError: HTTPSConnectionPool(host='i.instagram.com', port=443): Max retries exceeded with url: /api/v1/accounts/contact_point_prefill/ (Caused by ResponseError('too many 429 error responses'))

zhito commented 1 year ago

Custom waits between requests?

2023-04-21 12:31:21,366 [INFO ] xxxxxxxxx [401] POST https://i.instagram.com/api/v1/feed/timeline/ (269.0.0.18.75, OnePlus 6T Dev) 2023-04-21 12:31:21,373 [INFO ] Couldn't login user using session information: Please wait a few minutes before you try again. 2023-04-21 12:31:21,373 [INFO ] Attempting to login via username and password. username: xxxxxxxxx 2023-04-21 12:31:22,737 [INFO ] [None] [401] GET https://www.instagram.com/xxxxxxxxx/?__a=1&__d=dis 2023-04-21 12:31:25,963 [INFO ] [None] [401] GET https://www.instagram.com/xxxxxxxxx/?__a=1&__d=dis 2023-04-21 12:31:29,168 [INFO ] [None] [401] GET https://www.instagram.com/xxxxxxxxx/?__a=1&__d=dis 2023-04-21 12:31:34,684 [ERROR] HTTPSConnectionPool(host='i.instagram.com', port=443): Max retries exceeded with url: /api/v1/users/xxxxxxxxx/usernameinfo/ (Caused by ResponseError('too many 429 error responses'))

adw0rd commented 1 year ago

@zhito

cl = Client(request_timeout=7)

ctrlvee commented 1 year ago

still getting similar problem. I just reverted to 1.17.3 and am able to login and post successfully

ctrlvee commented 1 year ago

1.17.3 (below) is letting me login and post while 1.17.4 does not

(.venv) v@v instagram_post % /Users/v/Python/instagram_post/.venv/bin/python /Users/v/P ython/instagram_post/post.py Status 429: Too many requests Ignore 429: Continue login (.venv) v@v instagram_post %

mces89 commented 1 year ago

got the same issue too

100rmk commented 1 year ago

still getting similar problem. I just reverted to 1.17.3 and am able to login and post successfully

The next version should be correct, the current bug edits were not uploaded to pypi

yo-aiv1 commented 8 months ago

The next version should be correct, the current bug edits were not uploaded to pypi

still getting same error version: 2.0.3 os: windows 10 python; 3.11.4

yo-aiv1 commented 8 months ago

UPDATE: you can just add delay and it'll work fine, worked with 10s delay