Search code examples
ajaxapicountinstagraminstagram-api

Instagram API not returning more than 16 regardless of count parameter


I've been searching everywhere for the last two days but haven't seen any solutions to this problem. I'm new to javascript and working with APIs and thought it'd be fun to dive in and make a calendar on my personal site that gets populated with photos from my Instagram account with a particular tag.

I use the proper request url and even started adding on a count for the hell of it:

var url = 'https://api.instagram.com/v1/tags/' + tag + '/media/recent?access_token=' + accessToken + '&count=100';

$.ajax({
    url: url,
    dataType: 'jsonp',
    type: 'GET',
    success: function (data) {
        console.log(data);
    },

Going in I understood that I'd probably get around 20 results back as that was the max and was alright with that. However, no matter what I do I only get 16 results back.

I even went in and added a unique tag to the last 30 photos I wanted to show and changed the url to use it, but I still only get the last 16. Is this a new limit? I'm working in sandbox mode but nowhere on the internet do I see anyone else getting this specific result.

I'm also still struggling to figure out how to get pagination to work as that doesn't seem to do anything, even if I hand grab the min_tag_id from the first results and do

url: url + '?min_tag_id="' + minTagId + '"',

Solution

  • After rereading the docs, it seems like they're saying only the most recent 20 of my photos exist. I thought that meant only 20 could be reached at a time but they mean literally the last 20 I took exist, regardless of their tags.

    4 of my latest photos are not a part of this series as they don't have the right tags, but they are being counted in my 20 photos. So there we have it.