Reputation: 995
I am trying to use the following URL: https://api.instagram.com/v1/tags/snow/media/recent?access_token=x&min_id=x&max_id=x to fetch some images and their ID's. It's working fine, but how can I have more images? I want thousands of images, but I'm only getting about 30 at most. I'm guessing it has to do with the min_id and max_id, but I can't get any more images. Could anyone help me out?
Edit: I found out that Instagram has a 20 result limit. Is there any way using C# that will allow me to fetch older pictures for a total of X amount of pictures?
Upvotes: 1
Views: 1118
Reputation: 7495
Using the Instasharp Client library (https://github.com/InstaSharp/InstaSharp) you can do something like this:
var tags = new Endpoints.Tags(Config);
var result = await tags.RecentMultiplePages("csharp", minTagId: null, maxTagId: null, maxPageCount: 3);
You can inspect the result.RateLimitRemaining property to ensure you're not going to get blocked for spammy behaviour.
Upvotes: 1
Reputation: 1756
You will need to use the pagination property in the response for paging through results. Look for the next_url
property in the pagination object for the next url to call.
You can add a count parameter to your call to specify the number of records to receive for each call. This count parameter has a maximum value of 50 (or maybe 20) I think, I can't remember the exact number.
So return your first 20 records, then call the next_url property to get the next 20 images for the tag you specified.
Look in the response you get back from Instagram for the pagination property:
{
pagination: {"next_max_tag_id": "12345678", "next_max_id": "12345678",
"next_min_id": "12345678",
"min_tag_id": "12345678",
"next_url": "THE URL WILL BE HERE"}
data: {}
}
Upvotes: 2