Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram API: How to get pictures by tag name

I'm trying to get recent pictures by tagname. In API Doc I found that I need to send request to https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token=ACCESS-TOKEN

I'm using JavaScript (node.js), But this is not JavaScript specific question ,so you can skip the code.

Note: access_token is valid, I checked.

here is my code:

 var tag = 'nexus5x';
 var url = 'https://api.instagram.com/v1/tags/'+ tag +'?access_token=' + access_token;

 request({
    url: url,
    method: 'GET'
 }, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(body);
    }
    console.log('done');
 });

Result

So it requires max_tag_id or min_tag_id. But i don't have max/min id as I'm requesting first time and pagination object is empty

like image 220
mavup Avatar asked Jan 27 '26 00:01

mavup


1 Answers

If you are in sandbox mode, you will only get maximum 20 pics in API response and there will be no pagination, also u will see only pics from your sandbox authorized users, more info on sandbox mode here: https://www.instagram.com/developer/sandbox/

max_tag_id and min_tag_id are not required for the first call, once your app is live, you will have pagination object and the next_url will have all the relevant max_tag_id in the url.

like image 113
krisrak Avatar answered Jan 28 '26 13:01

krisrak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!