ping / instagram_private_api

A Python library to access Instagram's private API.
MIT License
2.94k stars 608 forks source link

How to get suggested profiles for any username? #369

Open Aditya-Rajgor opened 2 years ago

Aditya-Rajgor commented 2 years ago

Before submitting an issue, make sure you have:

Which client are you using?


Describe your Feature Request:

I want to fetch Related/Similar/Suggested accounts for a particular Instagram username.

I have tried following methods, but it doesn't give the suggested users

from instagram_private_api import Client
api = Client(username, password)

api.user_info(userid)
api.username_info(target_username)
api.username_detail_info(userid)

I have found that with given URL

https://www.instagram.com/{username}/?__a=1

we can get the suggested profiles like this

import requests
user_agent =  'Chrome'
url = 'https://www.instagram.com/{username}/?__a=1'

res = requests.get(url, headers={'user-agent':user_agent})
data = res.json()
data2 = data['graphql']['user']['edge_related_profiles']['edges']

len(data2)
>>>80

Somehow I am not able to use web_api. But I have found that user_info2 uses the same URL to get the info about the username. It always returns JSONDecodeError. Is there any other method in` private or web api to get suggested profiles?

yitopeligo commented 5 months ago

api.discover_chaining(userid)