user846437
user846437

Reputation:

Instagram API and Pagination

I can't get all images using Instagram API, Pagination seems to be working somehow different and I can't understand it yet

I use request: https://api.instagram.com/v1/users/self/media/recent?access_token=TOKEN

and can get first 20 photos:

...
{
  "attribution": null,
  "tags": [
    "beautiful",
    "instalife",
    "picoftheday",
    "beauty",
    "instalike",
    "gf",
    "traveling",
    "instatravel",
    "vsco",
    "tourism",
    "\u0438\u0441\u043f\u0430\u043d\u0438\u044f",
    "travelphoto",
    "vscogood",
    "instafollow",
    "travel",
    "\u0433\u0440\u0430\u043d\u0430\u0434\u0430",
    "amazing",
    "vscocam",
    "followme",
    "photooftheday"
  ],
  "type": "image",
  "location": null,
  "comments": {
    "count": 1
  },
  "filter": "Normal",
  "created_time": "1442825564",
  "link": "https:\/\/instagram.com\/p\/74vm3GOCEn\/",
  "likes": {
    "count": 18
  },
  "images": {
    "low_resolution": {
      "url": "https:\/\/scontent.cdninstagram.com\/hphotos-xap1\/t51.2885-15\/s320x320\/e15\/11934647_531283580370186_1131008999_n.jpg",
      "width": 320,
      "height": 320
    },
    "thumbnail": {
      "url": "https:\/\/scontent.cdninstagram.com\/hphotos-xap1\/t51.2885-15\/s150x150\/e15\/11934647_531283580370186_1131008999_n.jpg",
      "width": 150,
      "height": 150
    },
    "standard_resolution": {
      "url": "https:\/\/scontent.cdninstagram.com\/hphotos-xap1\/t51.2885-15\/e15\/11934647_531283580370186_1131008999_n.jpg",
      "width": 612,
      "height": 612
    }
  },
  "users_in_photo": [

  ],
  "caption": {
    "created_time": "1442825564",
    "text": "#\u0413\u0440\u0430\u043d\u0430\u0434\u0430 #\u0418\u0441\u043f\u0430\u043d\u0438\u044f #photooftheday #picoftheday #instalike #followme #vscogood #vscocam #vsco #instafollow #travel #traveling #instatravel #instalife #tourism #gf #beauty #beautiful #amazing #travelphoto",
    "from": {
      "username": "solotravel_me",
      "profile_picture": "https:\/\/igcdn-photos-h-a.akamaihd.net\/hphotos-ak-xaf1\/t51.2885-19\/11282631_115839268762391_863189534_a.jpg",
      "id": "736938591",
      "full_name": "and"
    },
    "id": "1078821495951073761"
  },
  "user_has_liked": false,
  "id": "1078821489441513767_736938591",
  "user": {
    "username": "solotravel_me",
    "profile_picture": "https:\/\/igcdn-photos-h-a.akamaihd.net\/hphotos-ak-xaf1\/t51.2885-19\/11282631_115839268762391_863189534_a.jpg",
    "id": "736938591",
    "full_name": "and"
  }
}
...

after that I'm trying use max_id parameter, but I'm not sure which ID I need to use I tried id of the photo, photo_user id, I even tried timestamp (found this idea on some forum), but every time I receive only first 20 photos

example: https://api.instagram.com/v1/users/self/media/recent?access_token=TOKEN&max_id=1078821495951073761

Upvotes: 4

Views: 8060

Answers (2)

Daksh
Daksh

Reputation: 1

Use this API for getting all posts of the user:

https://i.instagram.com/api/v1/feed/user/{user_id}

For pagination, the parameter name is max_id

Pass max_id which you have returned in this API's response.

Hope this helps !!

Upvotes: 0

RoggA
RoggA

Reputation: 513

I was having the same problem with the empty pagination object while the account actually had more photos.

And just to make things clear here. This question is answered in the comments of the origial question.

There is nothing in the pagination object because the app is in sandbox mode and app's in sandbox mode never returns more than 20 posts(photos).

Upvotes: 15

Related Questions