Skip to content

[BUG] #2713

Description

@lryyds-github

What broke?

The public GQL stopped working yesterday, and it was impossible to retrieve any data from it. Although it was fixed today, video posts are no longer returning view counts. Additionally, some links are failing to retrieve data, resulting in 401 errors.

Affected area

login / challenge

Minimal reproduction code

from instagrapi import Client

cl = Client()
url = "https://www.instagram.com/reels/DaHEdwgogl4/"
pk = cl.media_pk_from_url(url)
m = cl.media_info(pk)

Full traceback

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\media.py", line 575, in media_info_gql       
    data = self.public_graphql_request(variables, query_hash="477b65a610463740ccdb83135b2014db")       
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^       
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\public.py", line 423, in public_graphql_request
    body_json = self.public_request(
                ^^^^^^^^^^^^^^^^^^^^
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\public.py", line 254, in public_request      
    raise e
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\public.py", line 231, in public_request      
    return self._send_public_request(url, update_headers=update_headers, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\public.py", line 343, in _send_public_request
    raise ClientUnauthorizedError(e, response=e.response)
instagrapi.exceptions.ClientUnauthorizedError: 401 Client Error: Unauthorized for url: https://www.instagram.com/graphql/query/?variables=%7B%22shortcode%22%3A%22DY8G_8JEgt1%22%2C%22child_comment_count%22%3A3%2C%22fetch_comment_count%22%3A40%2C%22parent_comment_count%22%3A24%2C%22has_threaded_comments%22%3Afalse%7D&query_hash=477b65a610463740ccdb83135b2014db

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\media.py", line 701, in media_info
    media = self._media_info_public(media_pk)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\media.py", line 611, in _media_info_public   
    return self.media_info_gql(media_pk)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\media.py", line 600, in media_info_gql       
    return extract_media_v1(self._normalize_xdt_media_info(media_items[0]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\extractors.py", line 60, in extract_media_v1        
    media["video_url"] = sorted(media["video_versions"], key=lambda o: o["height"] * o["width"])[-1]["url"]
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^       
TypeError: 'NoneType' object is not iterable
'NoneType' object is not iterable
Traceback (most recent call last):
  File "D:\pthon.3.12\Lib\site-packages\instagrapi\mixins\public.py", line 320, in _send_public_request
    response.raise_for_status()
  File "D:\pthon.3.12\Lib\site-packages\requests\models.py", line 1167, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://www.instagram.com/graphql/query/?variables=%7B%22shortcode%22%3A%22DY8RhgimmAN%22%2C%22child_comment_count%22%3A3%2C%22fetch_comment_count%22%3A40%2C%22parent_comment_count%22%3A24%2C%22has_threaded_comments%22%3Afalse%7D&query_hash=477b65a610463740ccdb83135b2014db

Observed result

requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://www.instagram.com/graphql/query/?variables=%7B%22shortcode%22%3A%22DY8RhgimmAN%22%2C%22child_comment_count%22%3A3%2C%22fetch_comment_count%22%3A40%2C%22parent_comment_count%22%3A24%2C%22has_threaded_comments%22%3Afalse%7D&query_hash=477b65a610463740ccdb83135b2014db

Expected result

The data object should be returned as before, and include the number of impressions.

instagrapi version

2.16.26

Python version

3.12.0

Operating system

Windows 11

Login method

no login required

Proxy used?

http proxy

Can you reproduce on current master?

yes

Raw API response or payload sample

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions