Pagination with /locations/location-id/media/recent Instagram - instagram

I'm using https://api.instagram.com/v1/locations/{location-id}/media/recent endpoint of the Instagram API to fetch posts in a specific location, but i'm having an issue implementing pagination.
the request https://api.instagram.com/v1/locations/106970059456743/media/recent?ACCESS_TOKEN=(ACCESS_TOKEN)
the problem comes with the MAX_ID and MIN_ID parameters, because in the response i get from the first query the pagination object comes empty (see https://www.instagram.com/developer/endpoints/), i've tried pluggin in the id's of the most recent posts in the parameters and that doesn't seem to work when i'm asking for new posts, but it does work whem i'm asking for older post.
i've successfully implemented the pagination for the https://api.instagram.com/v1/tags/{tag}/media/recent endpoint but apparently this endpoints use different paginations (media/recent does return a pagination object in the response).

If you are in Sandbox mode, you can only get 20 posts in API response in sandbox mode, pagination will not work in sandbox, this is expected behavior. When u go live mode u will get all posts and pagination.

Related

Weird Issue With Instagram API

Issue:
First API calls only returns top 3 posts.
The next_url returns no data(data array is empty and pagination string is null)
The 4th post is suspect because I am unable to get it with API calls and it is not returned in the first API call.
Details:
Using v1/users/self/media/recent endpoint
Using Javascript to loop through calls, using "next_url" for the 2nd and subsequent call.
Using Access Token
Worked fine(returned all posts) until "the 4th post" was made
Why do I think one specific post is the issue? Because I am unable to retrieve it using the API. If I set the max_id to this post id, then I get all other posts before this post.
If I leave max_id out, the first call gets all posts newer than this post.
Verified that I am not in a Sandbox.
Has anyone encountered this before? and why would one post be breaking the next_url API call? Is there something in the post causing this?
I can't give out the IG account, sorry I know that would help, but it needs to remain private.
I am a developer on a project that makes extensive use of the legacy Instagram API. It has, for a long while now, been extremely flakey. We have experienced your exact issue many times and there is no practical solution.
However, all Instagram APIs have now (finally!) been migrated to Facebook. You should use the new Instagram Basic Display API which will be properly supported going forward.

Instagram API recent media endpoint returning post URLs that can't be viewed

Users in my web app authenticate with Instagram. After, I query https://api.instagram.com/v1/users/self/media/recent/ to fetch recent posts and generate a preview of each using Instgram's oembed endpoint.
This works fine for 99% of my users so far, but now I see for one user, the recent posts endpoint is returning post links that can't be opened (I see same result when pasting URL into browser)
Also, it seems like the post link returned for this user are much longer than a usual Instagram URL like https://www.instagram.com/p/bNd86MSFv6/
What could be the reason for posts not being viewable?
Longer URLs are usually photo links from private profile, so it will not be viewed by just anyone.

Instagram API /v1/users/self/media/recent with min_id doesn't performing as doc said

I am trying to fetch my post feed through Instagram API.
I can fetch all posts by using below URL:
https://api.instagram.com/v1/users/self/media/recent?access_token=3316953021.24c30bf.5ecbae4a6b4840b68a499c01ba611c4d
I can use the same API with max_id to fetch earlier posts.
https://api.instagram.com/v1/users/3316953021/media/recent?access_token=3316953021.24c30bf.5ecbae4a6b4840b68a499c01ba611c4d&count=2&max_id=1272062614682155664_3316953021
However, when I followed Instagram docs to fetch post later than min_id post. It doesn't work as it promised.
https://api.instagram.com/v1/users/self/media/recent?access_token=3316953021.24c30bf.5ecbae4a6b4840b68a499c01ba611c4d&count=2&min_id=1272064038816135869_3316953021
It supposed to get two later posts after the min_id post. But, it actually, get post start with the latest post.
Moreover, If the min_id is the latest post id, the response will start with the latest post.
Then, I found whatever I use min_id, the API will perform equivalent with below one
https://api.instagram.com/v1/users/self/media/recent?access_token=3316953021.24c30bf.5ecbae4a6b4840b68a499c01ba611c4d&count=2
It means the min_id never works.
Question: Any one has experience to fetch feed by set min_id? Where am I wrong in my url?
P.S. The access token is working, you can click the URL to test it.
I don't believe you're doing anything wrong. I think this param has 'broken' with the update to IG's API recently. I've submitted an issue with them, and it would be helpful probably if you did, too.
I see similar issues being posted on StackOverflow, using the param with different endpoints. So I doubt it's 'user error.'

why do the posts seem to change when i look at the recent tagged instagram API

when i'm accessing the instagram API via the https://api.instagram.com/v1/tags/nofilter/media/recent and i click refresh on the browser, it seems to get more posts, but the count doesn't change on the app in iOS or on the API. Is there actually more posts being posted or is it just cycling through old ones?
There is a maximal limit of returned media per request: 33 (by now). By default the API should return 20 items. Regardless of refreshing the browser, the number of posts per request does not change.
I assume that you were getting the same number of media after refreshing the browser, but they were new, just being posted on the Instagram. However, they could have more data (longer descriptions etc.), which could give you an illusive impression of more fetched items.

graph api search not returning a post

I am searching using https://graph.facebook.com/search?q=anglogold&type=post
this is not returning a post I made myself just now. Any idea why
https://graph.facebook.com/search?q=anglogold&type=post
returns a lot of posts for me.
Facebook can restrict results on search api on different scenarios.
Not suitable for a particular country/region
Not a public post
Person is blocked by user
and may be few others.

Resources