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] Unable to get All user_followers #646

Closed pbalajiips closed 2 years ago

pbalajiips commented 2 years ago

if a user has more number of followers(10k) the user_followers(user_id) method hangs and returns 429. i tried playing with multiple values for request_timeout ,but still has the same issue.

====== Error========

>>> followes = cl.user_followers(user_id)

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/public.py", line 128, in _send_public_request
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://www.instagram.com/graphql/query/?variables=%7B%22id%22%3A%2211410157%22%2C%22include_reel%22%3Atrue%2C%22fetch_mutual%22%3Afalse%2C%22first%22%3A12%2C%22after%22%3A%22QVFCaS0zcURXVFFIWEhQaW5uREQtYkNSbXAxLWZTQmRjSkZRc2NpYlI2bDRsbnp5c2FEZ1ktNV9IeUtIZGdyNUlTQ3U5ZW9WZGdtV0FsZURYMWQxQTdhXw%3D%3D%22%7D&query_hash=5aefa9893005572d237da5068082d8d5

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/user.py", line 711, in user_followers
    users = self.user_followers_gql(user_id, amount)
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/user.py", line 620, in user_followers_gql
    users, _ = self.user_followers_gql_chunk(str(user_id), amount)
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/user.py", line 588, in user_followers_gql_chunk
    data = self.public_graphql_request(
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/public.py", line 210, in public_graphql_request
    body_json = self.public_request(
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/public.py", line 89, in public_request
    raise e
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/public.py", line 72, in public_request
    return self._send_public_request(url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/public.py", line 156, in _send_public_request
    raise ClientThrottledError(e, response=e.response)
instagrapi.exceptions.ClientThrottledError: 429 Client Error: Too Many Requests for url: https://www.instagram.com/graphql/query/?variables=%7B%22id%22%3A%2211410157%22%2C%22include_reel%22%3Atrue%2C%22fetch_mutual%22%3Afalse%2C%22first%22%3A12%2C%22after%22%3A%22QVFCaS0zcURXVFFIWEhQaW5uREQtYkNSbXAxLWZTQmRjSkZRc2NpYlI2bDRsbnp5c2FEZ1ktNV9IeUtIZGdyNUlTQ3U5ZW9WZGdtV0FsZURYMWQxQTdhXw%3D%3D%22%7D&query_hash=5aefa9893005572d237da5068082d8d5
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/private.py", line 298, in _send_private_request
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 960, 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/11410157/followers/?max_id=&count=10000&rank_token=52736483020_412bca80-c40a-41ae-89c7-d4c25fce7fb1&search_surface=follow_list_page&query=&enable_groups=true

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/user.py", line 715, in user_followers
    users = self.user_followers_v1(user_id, amount)
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/user.py", line 682, in user_followers_v1
    users, _ = self.user_followers_v1_chunk(str(user_id), amount)
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/user.py", line 647, in user_followers_v1_chunk
    result = self.private_request(f"friendships/{user_id}/followers/", params={
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/private.py", line 445, in private_request
    raise e
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/private.py", line 432, in private_request
    self._send_private_request(endpoint, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/private.py", line 354, in _send_private_request
    raise UnknownError(**last_json)
instagrapi.exceptions.UnknownError: checkpoint_required

========================

vitormendes977 commented 2 years ago

Yeah, I'm facing same issue here. It stopped all our operation

adw0rd commented 2 years ago

@pbalajiips @vitormendes977 I don't know how to fix it now, so i advise to use https://lamadava.com/

andreadibartolo commented 2 years ago

has this bug been fixed?

Piscen commented 2 years ago

@pbalajiips @vitormendes977 I don't know how to fix it now, so i advise to use https://lamadava.com/

Even with this, each request returns a maximum of 50 results