Search code examples
facebookfacebook-graph-apipaginationinstagram-graph-api

No next url for getting instagram medias on facebook's graph API for business accounts


I am trying to fetch all of my instagram page's posts (around 57k posts) from facebook's graph API. using the 'media' endpoint described here:

https://developers.facebook.com/docs/instagram-api/getting-started

I have managed to get around 12k posts using it using the query below:

https://graph.facebook.com/v3.3/{ig-user-id}/media?access_token=XXX&pretty=0&fields=timestamp,caption,comments_count,like_count,media_type,media_url,owner,permalink,shortcode,thumbnail_url,username&limit=200

when using this link returning result contains a data part which is for posts' data and a pagination section which includes next and previous urls and cursors for after and before. I used next and got remaining posts each time, until the result didn't have a next url but it had an after cursor but when I used it the data returned was empty.

I thought there might be some kind of limitation, but couldn't find anything so far except for the API rate limits which I don't exceed.

I also tried the graph API explorer and got the same result.


Solution

  • The problem was not solved but I found something I hadn't seen before, it might help people confused like me.

    in the endpoint documentation it is declared that this endpoint has a 10k recent posts limitation, therefor we cannot get any more of our posts.