Search code examples
instagramendpointinstagram-api

Instagram EndPoint URL with hastags min_tag and max_tag


I've a url which gets the latest images posted in instagram with a hashtag,

the problem with the url is if the images count are more than 20, it returns a max_tag_id, if i search with a hastag - #selfie, i get the max tag and main tag and the next pagination url also,

But the main problem is if the images with that hashtag are less than 20, it is not returning the media or even the max tag, the JSON response has only min tag

URL :

https://api.instagram.com/v1/tags/{tagname}/media/recent?client_id=XXX

Response :

{"pagination":{"next_min_id":"XXXXXXXX","deprecation_warning":"next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead","min_tag_id":"XXXXXXXX"},"meta":{"code":200},"data":[]}

Solution

  • next_max_tag_id, next_max_id, next_url are returned to facilitate pagination when there are more media available on the server. When all the available media is returned there would be no pagination hence no max_tag is returned.

    The #idonothingbut tag, currently, has 2 media which are returned by one call, and there would be no pagination needed.

    The API also accepts a count parameter that specifies the number of media per page, and the default is 20 that you have mentioned.