I can enter the following url to get all the IG posts with the #losangeles tag in them by going/requesting the following endpoint:
https://www.instagram.com/explore/tags/losangeles/?__a=1
In the json data returned from this url i can see the page_info attribute and within it there is the has_next_page attribute and that is set equal to true. My question is how do I ammend the above url to get to the next page, and the one after that, and so until I check has_next_page and it is false.
It seemed intuitive to try
https://www.instagram.com/explore/tags/losangeles/?__a=2
and
https://www.instagram.com/explore/tags/losangeles/?__b=1
But neither seem to work. I suspect maybe the end_cursor attribute in the data returned from the original url may be a clue as to what url I need to go to to get to the next page but am not sure. Does anyone know how to do this?
This is possible. Each response includes an end_cursor
parameter. In your next request add a max_id
parameter using the value of end_cursor
, like so: https://www.instagram.com/explore/tags/losangeles/?__a=1&max_id=<value>
.
I have a working example here written in react/axios: https://codepen.io/ghostreef/pen/ZrKrXX. My example pulls from a user account, so my response xml is different. The end_cursor for tags is at data.graphql.hashtag.edge_hashtag_to_media.page_info.end_cursor
and the image data is at data.graphql.hashtag.edge_hashtag_to_media.edges
and you'll have to iterate over the nodes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With