정현민
정현민

Reputation: 11

Instagram API request more

https://api.instagram.com/v1/users/self/media/recent/?access_token=my_token&count=30

request only 20 data.

I want 30 data.

  {
    pagination: { },
    meta: {
    code: 200
    },
    data: [
    {
    attribution: null,
    tags: [...

can't find pagination in next_max_id.

but https://api.instagram.com/v1/users/self/media/recent/?access_token=my_token&count=1

This code = next_max_id ok.

Do u know what i meen?

sorry, not wall English wirte..

Help Me~

Upvotes: 1

Views: 1292

Answers (1)

poke
poke

Reputation: 387557

In general, the endpoints are limited to a certain amount of items per request. In order to get around this, endpoints support pagination. Pagination is indicated by the pagination key in the response. It may look like this:

"pagination": {
    "next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
    "next_max_id": "13872296"
}

In that case, you could pass next_max_id to the previously made request to get the next page which starts from the last id that wasn’t included in the current response. You can also simply request the URL at next_url which is automatically constructed for your by the Instagram API.

You can increase the page size for endpoints by supplying the count parameter. Note that each endpoint has a maximum page size which you cannot go above. So you will have to support paging at some point in order to access more items.

Finally, since you hit the number of 20 items in your response despite specifying a page size of 30, it’s very likely that you are hit by the sandbox mode.

Sandbox mode is a new restriction for Instagram applications created on or after November 17th, 2015. This restriction limits application in various ways, most notably, it limits all endpoints to return a maximum of the 20 most recent media items.

So if you have created your application after that date, this is exactly what you’re running into. Your application is essentially in a test mode. In order to lift these restrictions, you need to get your application reviewed and approved first. As stated in the documentation:

After your app has been reviewed and approved, you are ready to make it available to the general public. To switch your client from sandbox to live mode, you can use the button on the top section of the configuration screen for your app. When you are live, any Instagram user will be able to authorize your app, but you will have access only to the permissions that you were granted during the review.

Upvotes: 3

Related Questions