Pagination info missing in instagram api - pagination

I am using the most popular api via instagram api
In the document, it saying something about pagination and next_url but when I
use the link below with my app ID. I don't see any pagination info in the json.
Am i missing something?
https://api.instagram.com/v1/media/popular?client_id=CLIENT-ID
or
https://api.instagram.com/v1/media/popular?client_id=CLIENT-ID&count=10

you should get the pagination info back in a an object callged "pagination"
"pagination": {
"next_max_tag_id": "1335465136530",
"deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead",
"next_max_id": "1335465136530",
"next_min_id": "1335465556125",
"min_tag_id": "1335465556125",
"next_url": "https:\/\/api.instagram.com\/v1\/tags\/cats\/media\/recent?callback=jQuery17201362594123929739_1335440328560&_=133544032857&client_id=xxx&max_tag_id=1335465136530"
}
Which has the next_url you are looking for

The pagination information will be empty if the requested user's feed has fewer posts than the default query count. In other words, if the instagram account only has five pictures, there is no pagination info.

There is not a lot of documentation around pagination on the official API.
Check out this tutorial for more guidance and depth.
http://eduvoyage.com/search-instagram-pagination.html
You need to use the "min_tag_id" and "max_tag_id" to get the images you want.
As your using the endpoint to get popular images, you might want to try something like this.
https://api.instagram.com/v1/tags/cats/media/recent?callback=?&client_id=YOURID&max_tag_id=1364206789229
But if you are after a specific tag, try something like this.
https://api.instagram.com/v1/tags/cats/media/recent?callback=?&client_id=YOURID&max_tag_id=1364206789229

media/popular endpoint does not have a pagination object. As Ryan Ore explained some endpoints provide pagination and some dot not.
You check whether the endpoint has a pagination or not by "pagination": {} object. If the object exists the endpoint has pagination.

Related

Instagram API - get like count on media

Good morning,
I'm writing my own library to improve skills for getting media from Instagram profile and showing it on my website.
I read a lot of articles, documentation, etc. but there are many old versions and endpoints. At the official API documentation, I'm unable to find, how to get like count or comment count on every single media.
So:
I can OAuth - OK
Get short-live token - OK
Get long-live token - OK
Refresh long-live token - OK
Get media list - OK
Get one media based on its ID - OK
But none of endpoints gives me like count or comment count. How can I achieve this?
https://graph.instagram.com/me/media?fields=id,caption,comments_count,like_count,media_type,media_url,thumbnail_url&access_token=
returns me:
{ data: [{ "id":"123456798", "caption":"My title", "media_type":"IMAGE", "media_url":"https://..." }, { ... }] }
I found in the documentation https://developers.facebook.com/docs/instagram-api/reference/ig-media/ that I can get the like_count field only for requests at media with their ID. So I tried EP:
https://graph.instagram.com/v15.0/123456789?fields=id,caption,media_type,media_url,thumbnail_url,like_count&access_token=
and return is: Tried accessing nonexisting field (like_count) on node type (Media).
On the instagram I've able to get likes and comments and the media has likes and comments. What I'm doing bad? Thank you for your time.

How to retrieve all images from multiple photo post on Instagram

Recently Instagram announced support for multiple photos post.
I tried with endpoint, GET /media/media-id, but response has information about only one image.
Anyone is able to retrieve all images from single multiple photo post using their API?
Thanks.
Not available in official API yet, but you can use the "Instagram Photo Page URL" and add ?__a=1, this will give you JSON with all the multi-images in it.
For example:
https://www.instagram.com/p/BQ00n_BB7Dm/?__a=1
You will get JSON response with media.edge_sidecar_to_children.edges[] will have all media urls and info
Instagram API now supports the "multi photo" posts.
If a post is of type "multi photo", in the API the "type" property will now be with the value "carousel" and the "mediaData" property will contain "carousel_media" property with an array of the images (posts).

tags/tag-name/media/recent endpoint returns null

I try to pull the posts from Instagram by hashtags.
So I use the tags endpoint to get recently posts about particular hashtags.
I use the url like this https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token=ACCESS-TOKEN.
But I get empty data in return, like:
{"pagination": {"deprecation_warning": "next_max_id and min_id are deprecated
for this endpoint; use min_tag_id and max_tag_id instead"},
"meta": {"code": 200}, "data": []}
I should get something back in the "data", because there are posts with that hashtag. Does tat means I use this api in a wrong way?
I think you are in Sandbox mode?
In Sandbox mode you will only see posts from you and your sandbox user, once you go live API will return posts from all users.
In Sandbox mode, You can search for hashtag that you have posted on Instagram, it will then have just that post in API response.
Read more about Sandbox mode and limitations here: https://www.instagram.com/developer/sandbox/

Instagram api not-working

I trying to use instagtram api. But endpoints: comments and likes not working.
https://www.instagram.com/developer/endpoints/comments/
But if I try to get comments - Data is empty.
What`s wrong?
Instagram API after Jun'16 is so unusable.
Try fetch this https://www.instagram.com/query/?q=ig_shortcode(BK07W-Xhq6S){comments.last(20){count,nodes{id,created_at,text,user{id,username,full_name}},page_info}} and you receive JSON with comments data.

Updating a wiki page with the REST API

How do you update a SharePoint 2013 wiki page using the REST API?
Three permutations:
Reading an existing page (content only)
Updating an existing page
Creating a new page
For reading an existing page, of course I can just to a "GET" of the correct URL, but this also brings down all the various decorations around the actual data on the wiki page-- rather than fish that out myself, it would be better if there was a way to just get the content if that is possible.
Are there special endpoints is the REST API that allow for any of these three operations on wiki pages?
As stated in GMasucci's post, there does not appear to be a clean or obvious way of instantiating pages through the REST API.
You can call the AddWikiPage method from the SOAP service at http://[site]/_vti_bin/Lists.asmx. This is an out of the box service that will be accessible unless it has been specifically locked down for whatever reason.
To read the content of a wiki page through the REST API, you can use the following endpoint:
https://[siteurl]/_vti_bin/client.svc/Web/GetFileByServerRelativeUrl('/page/to/wikipage.aspx')/ListItemAllFields
The content is contained within the WikiContent field. You may want to add a select to that URL and return it as JSON to reduce the amount of data getting passed over if that is a concern.
As for updating the content of an existing wiki page, it is not something I have tried but I would imagine it's just like populating another field through the REST API. This is how I would expect to do it:
Do a HTTP POST to the same endpoint as above
Use the following HTTP headers:
Cookie = "yourauthcookie"
Content-Type = "application/json;odata=verbose"
X-RequestDigest = "yourformdigest"
X-HTTP-Method, "MERGE"
If-Match = "etag value from entry node, returned from a GET to the above endpoint"
Post the following JSON body
{
"__metadata": { "type": "SP.Data.SitePagesItem" },
"WikiField" : "HTML entity coded wiki content goes here"
}
The interim answer I have found is to not utilise REST, as it appears to not be
fully documented
fully featured
supported across Sharepoint 2013 and On-line in the same way
So my current recommendation would be to utilise the SOAP services to achieve the same, as these are more documented and easily accessible.

Resources