-1

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'?

ibexy
  • 609
  • 3
  • 16
  • 34
  • Have you seen a comment to https://stackoverflow.com/questions/59805060/getting-user-media-with-instagram-basic-display-api ? – Alex Oct 12 '21 at 12:45

1 Answers1

1

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.

krmogi
  • 2,588
  • 1
  • 10
  • 26
  • 2
    The video in the answer gave me all the information I needed. Great video btw. Thanks. All up and running now :) – ibexy Oct 15 '21 at 04:04
  • So the Graph api works but only against your own account. You cannot use it to view other accounts as you would normally do on a browser? – ibexy Oct 16 '21 at 12:47