I have the Instagram basic Display api set up and working ok to get my data. However if I try to get a user data (not mine), non of the ids work.
Here is how am searching in python code but its failing:
media = instagram_basic_display.get_user_media(user_id='nnnnn')
If I insert the user is from the url, it doesn't work.
What is the correct user_id to use in the above code in place of 'nnnnn'?
In Basic Display API overview it says:
The API can be used to access any type of Instagram account but only provides read-access to basic data. If you are building an app that will allow Instagram Businesses or Creators to publish media, moderate comments, identify @mentioned and hashtagged media, or get data about other Instagram users, use the Instagram Graph API instead.
So you may need to look into Instagram Graph API instead.
Here are a couple great resources:
Instabot is also a terrific library.
To install it, simply run pip install instabot
.
To get the users id and username, you can do this:
from instabot import Bot
bot = Bot()
user_id = bot.get_user_id_from_username("yourusername")
username = bot.get_username_from_user_id(user_id)
print(f"Welcome {username} your userid is {user_id}")
In conclusion, you cannot currently use Basic Display API to access a user name or id. Instead, you can use Instagram Graph API, or a useful instabot library.