Search code examples
pythoninstagraminstagram-api

Get public images with hashtag from Instagram API


I'm trying to get any photo from any user on Instagram with a certain hashtag, but when I go to:

https://api.instagram.com/v1/tags/{hashtag}/media/recent?access_token=ACCESS_TOKEN

I only get my photos.


Solution

  • If your app is on sandbox mode than that explains it.

    The behaviour of the request /tags/{tag-name}/media/recent changes to return only tagged posts from sandbox users.
    This is also correct for all other API requests; When app is on sandbox mode, the API behaves as if the sandbox users are the only users on Instagram.

    From the documentation:

    As another example, let's consider an endpoint that returns a list of media: /tags/{tag-name}/media/recent.
    The response returned by this endpoint will contain only media with the given tag, as expected. But instead of returning media from any public Instagram user, it will return only media that belongs to your sandbox users, restricted to the last 20 for each user.

    You can use the Instagram API console (APIGEE) to see this request returns public data with a different authentication type.

    Also, note that if all your app does is displaying public content from Instagram then Instagram would not approve the app outside sandbox mode.

    enter image description here