Search code examples
instagram-api

how can I use the Instagram API to get photos with a certain hashtag and that I like


I want to fetch data from the Instagram api that has images with a certain hashtag that I have also liked. How would I do that, please? This part works:

https://api.instagram.com/v1/tags/testlaura/?client_id=2b3f8303808e4dd6bbba72023c7c5d65

Now how do I filter that for just the images I liked?


Solution

  • To my knowledge there isn't a specific filter for the hashtag endpoint to only get media that you've liked, but there's a way you could still figure it.

    1. Paginate through the media/recent endpoint (ex https://api.instagram.com/v1/tags/testlaura/media/recent?access_token=) using the next_min_id value they give you with each request.
    2. Instead of using your client id, use the user access_token you want to know the "like" status of. If you use an access_token, each media will have a property of "user_has_liked" attached that is either true or false.
    3. Put this request on a loop and exit after a certain number of requests or once you've gone through all the media for that tag.