instagram_private_api icon indicating copy to clipboard operation
instagram_private_api copied to clipboard

How to get suggested profiles for any username?

Open Aditya-Rajgor opened this issue 4 years ago • 1 comments


Before submitting an issue, make sure you have:

  • [X] Updated to the lastest version v1.6.0
  • [X] Read the README and docs
  • [X] Searched the bugtracker for similar issues including closed ones
  • [X] Reviewed the sample code in tests and examples

Which client are you using?

  • [X] app (instagram_private_api/)
  • [ ] web (instagram_web_api/)

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?

Aditya-Rajgor avatar Nov 10 '21 05:11 Aditya-Rajgor

api.discover_chaining(userid)

ygtmesci avatar Mar 05 '24 13:03 ygtmesci