instagrapi
instagrapi copied to clipboard
[BUG] Public API is not working
I have been recently using the public API for some tests And even if in December #1666 succesfully managed to correct it I retried these last few days and I get the following exception : instagrapi.exceptions.ClientNotFoundError: 404 Client Error: Not Found for url: https://www.instagram.com/########/?__a=1&__d=dis
So I have searched from where we get that and I have found that there may be some problems with the following function :
def public_a1_request(self, endpoint, data=None, params=None, headers=None):
url = (self.PUBLIC_API_URL + str(endpoint)).replace(
".com//", ".com/"
) # (jarrodnorwell) fixed KeyError: 'data', fixed // error
params = params or {}
params.update({"__a": 1, "__d": "dis"})
response = self.public_request(
url, data=data, params=params, headers=headers, return_json=True
)
return response.get("graphql") or response
This endpoint is to the end of it's life and wont be coming back and so far there are no solutions. You can use this:
import requests
url = "https://i.instagram.com/api/v1/users/web_profile_info/?username=instagram"
headers = { "User-Agent": "iphone_ua", "x-ig-app-id": "936619743392459" }
response = requests.get(url, headers=headers)
print(response.status_code) print(response.json())
Thank's! but then how can I get some informations about random accounts (like the names of the followers of a given account ) via the public api? Is there a quite stable solution? I don't really understand the solution you gave me. But thank you very much for the answer. I'm working on fully understand it and integrate it.
Due to the Instagram API problem, the program cannot retrieve the user's information. Please fix the module. Or offer an alternative solution : File "C:\Users###\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\user.py", line 165, in user_info_by_username_v1 raise UserNotFound(e, username=username, **self.last_json) instagrapi.exceptions.UserNotFound: 404 Client Error: Not Found for url: https://i.instagram.com/api/v1/users/%20konusanlar.daily/usernameinfo/