Search code examples
apiinstagraminstagram-api

How to pull Instagram posts for a public account for certain account?


How to pull Instagram posts for a public account for certain account however the account is not mine, but I need to pull its feed and its recent media.

I saw there's a way using the user_id, but how could I get the user_id from a username? OR doing it directly with the username?


Solution

  • Sending a GET request to https://www.instagram.com/katyperry/?__a=1 returns a JSON packed with account information including user id, recent media, feed, etc.

    user_id = responseAsJSON.graphql.user.id

    You can replace katyperry with any public username.