subzeroid / instagrapi

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

[BUG] 400 error when i try to get following #1292

Closed zhito closed 1 year ago

zhito commented 1 year ago

Hello friends! With getting followers script working well but with getting following i get an error v1.17.3 or v1.17.4

2023-04-24 09:48:46,220 [INFO ] xxxxxxxxx [403] POST https://i.instagram.com/api/v1/feed/timeline/ (269.0.0.18.75, OnePlus 6T Dev) 2023-04-24 09:48:46,223 [INFO ] Session is invalid, need to login via username and password 2023-04-24 09:48:50,508 [INFO ] xxxxxxxxx [200] POST https://i.instagram.com/api/v1/accounts/contact_point_prefill/ (269.0.0.18.75, OnePlus 6T Dev) 2023-04-24 09:48:53,863 [INFO ] xxxxxxxxx [200] POST https://i.instagram.com/api/v1/launcher/sync/ (269.0.0.18.75, OnePlus 6T Dev) 2023-04-24 09:49:02,538 [INFO ] xxxxxxxxx [200] POST https://i.instagram.com/api/v1/accounts/login/ (269.0.0.18.75, OnePlus 6T Dev) 2023-04-24 09:49:12,587 [INFO ] xxxxxxxxx [200] POST https://i.instagram.com/api/v1/feed/reels_tray/ (269.0.0.18.75, OnePlus 6T Dev) 2023-04-24 09:49:23,867 [INFO ] xxxxxxxxx [200] POST https://i.instagram.com/api/v1/feed/timeline/ (269.0.0.18.75, OnePlus 6T Dev) 2023-04-24 09:49:23,868 [INFO ] Login is OK 2023-04-24 09:49:23,869 [INFO ] Getting following.. 2023-04-24 09:49:34,564 [INFO ] xxxxxxxxx [400] GET https://i.instagram.com/api/v1/friendships/111111111/following/?max_id=&count=10000&rank_token=111111111_149b68e2-01ce-4197-899e-492f4c1e0cd8&search_surface=follow_list_page&query=&enable_groups=true (269.0.0.18.75, OnePlus 6T Dev) 2023-04-24 09:49:34,565 [ERROR] 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/friendships/111111111/following/?max_id=&count=10000&rank_token=111111111_149b68e2-01ce-4197-899e-492f4c1e0cd8&search_surface=follow_list_page&query=&enable_groups=true Traceback (most recent call last): File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 313, in _send_private_request response.raise_for_status() File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/friendships/111111111/following/?max_id=&count=10000&rank_token=111111111_149b68e2-01ce-4197-899e-492f4c1e0cd8&search_surface=follow_list_page&query=&enable_groups=true 2023-04-24 09:49:34,567 [WARNI] Status 400: Empty response message. Maybe enabled Two-factor auth? Traceback (most recent call last): File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 313, in _send_private_request response.raise_for_status() File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/friendships/111111111/following/?max_id=&count=10000&rank_token=111111111_149b68e2-01ce-4197-899e-492f4c1e0cd8&search_surface=follow_list_page&query=&enable_groups=true

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/zhito/web/instagram-private-api/main.py", line 125, in main() File "/Users/zhito/web/instagram-private-api/main.py", line 120, in main i.get_following('111111111') File "/Users/zhito/web/instagram-private-api/main.py", line 95, in get_following user_following = self.cl.user_following(inst_pk) File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/instagrapi/mixins/user.py", line 613, in user_following users = self.user_following_v1(user_id, amount) File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/instagrapi/mixins/user.py", line 577, in user_followingv1 users, = self.user_following_v1_chunk(str(user_id), amount) File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/instagrapi/mixins/user.py", line 539, in user_following_v1_chunk result = self.private_request( File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 461, in private_request raise e File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 446, in private_request self._send_private_request(endpoint, kwargs) File "/Users/zhito/web/instagram-private-api/venv/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 375, in _send_private_request raise ClientBadRequestError(e, response=e.response, last_json) instagrapi.exceptions.ClientBadRequestError: Unknown ({'message': '', 'response': <Response [400]>, 'status': 'fail'})

claell commented 1 year ago

I described the same issue here: https://github.com/adw0rd/instagrapi/issues/1050#issuecomment-1517619574

What I could imagine is either https://github.com/adw0rd/instagrapi/issues/1280 is the problem here or there are tighter limits set by Instagram.