What is the proper way to format a GET request to retrieve all media items of the Instagram user "self"? - api

Looking at https://www.instagram.com/developer/endpoints/users/ I have gathered that calling https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN will return "the most recent media published by the owner of the access_token."
In sandbox mode I understand that I will receive a maximum of 20 media items from this call. I also realize that the response code has a pagination object that I can use to retrieve up to 20 more media items (see below)
"pagination": {
"next_max_tag_id": "1387272337517",
"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": "1387272337517",
"next_min_id": "1387272345517",
"min_tag_id": "1387272345517",
"next_url": "https://api.instagram.com/v1/tags/cats/media/recent?access_token=xxx&max_tag_id=1387272337517"
}
These are the listed parameters of this Request.
PARAMETERS
ACCESS_TOKEN A valid access token.
MAX_ID Return media earlier than this max_id.
MIN_ID Return media later than this min_id.
COUNT Count of media to return.
My question is: Is there a way to structure my GET request in a way that returns all media items from a single call? I understand that this is not possible in sandbox mode, given a user with more than 20 media items. If possible please provide a detailed explanation of the COUNT parameter.
I imagine a possible GET request would look like https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN?COUNT=X
Thank you. <3

When you go live mode you can use the count= param to get more than 20 in one API call, however I have noticed that count=33 is the maximum you can get for this API call, even if you anything more than 33, it only returns 33.
You still have to use the pagination in JSON response to get the next set of media items, easiest way is to use the pagination.next_url to make API call and get next set of media items

Related

Unpredictable soundcloud api tracklist

I need to get whole user's tracklist by SC api.
Before I use the next link format:
https://api.soundcloud.com/users/{user_id}/tracks/?page_size=200&linked_partitioning=1&client_id={app_id}
But it has stopped to work correct recently.
Changes:
limit has been decreased by SC from 200 tracks to 50;
returned tracks have become random (eg user has 300 tracks, but request above returns 54 tracks and link to the next page of tracks where fields "offset=50&limit=50" are appearing;
when I change field "page_size" from 200 to 50, SC returns only 18 tracks).
Also I've tried to use fields "offset" and "limit" instead of "page_size" but it has worked incorrect, too.
How I can get whole user's tracklist?
You need to parse the response and read next_href then change the url to the next_href value.
It's better to do this as a loop until there is no more next_href
Some recent updates on pagination from the API can be found below. You need to rely on the cursor rather than offset
https://developers.soundcloud.com/blog/pagination-updates-on-our-api

Vimeo API get multiple videos in one GET request

I'm in a situation where I need to make one GET request to Vimeo and get back info for multiple specific videos. Here is what I have for the query string currently:
https://api.vimeo.com/users/XXXXXXXX/videos?fields=uri,duration,pictures.sizes.link,download&containing_uri=/videos/ID1,/videos/ID2&per_page=2
Unfortunately, this only returns the information for ID2 and the video ID before it in its channel, instead of for both IDs specified. I've also tried appending multiple containing_url fields to no avail. Is there any way to make this happen? I'm using axios in react native if that helps.
Instead of "containing_uri", use "uris" as documented here:
https://developer.vimeo.com/api/common-formats#batch-requests
https://developer.vimeo.com/api/reference/videos#GET/videos
The "containing_uri" parameter will only return the page of the specified uri. The "uris" parameter will return the specified videos/objects. Your request should look like this:
https://api.vimeo.com/users/XXXXXXXX/videos?fields=uri,duration,pictures.sizes.link,download&uris=/videos/ID1,/videos/ID2&per_page=2
I hope this information helps!

How to get maximum number of tweets on an user

i have this code
("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500'
But it is giving me only 200 records , I found in twitter document that it will give 3200 tweets.Is i am doing wrong what should i do to get that much tweet.
Since there is no page system in twitter 's API, to go throught timelines, you must use the "max_id" parameter.
Here is an helpful link that explains how to work with timelines with nice illustrations: https://dev.twitter.com/rest/public/timelines.
Edit: here is how you do it.
"To use max_id correctly, an application’s first request to a timeline endpoint should only specify a count."
Make your request "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500 (you can put 200).
Then when you get all your data, " keep track of the lowest ID received" and use it as parameter (the same way you do for the count) for your next request. it will give you the 200 next posts with a lower id than the one you specified. Do it again until you reach the end.

Is it correct that the Instagram Location/Search endpoint does NOT support pagination?

I have read several postings about the fact that the Instagram API returns only 20 results at a time. In many cases, people have suggested that all you need to do is to use the next URL which is returned in the pagination information. I would be fine with that, but the JSON returned by
https://api.instagram.com/v1/locations/search?
does not appear to have any pagination information. I have seen a posting that says that /media/search does not support pagination. I just wanted to confirm that the same is true for /locations/search. Can anyone confirm?
And if this is correct, does anyone have any thoughts about how you can get a list of all Instagram events in a specific area, rather than just the first 20 or so?
/media/search end point does not have pagination, but you can get next set of 20 pics by using url param max_timestamp, get the created_time of the last photo in api response and apply it as max_timestamp for next url call, it will return the next 20. Thats how I implemented here: http://www.gramfeed.com/instagram/map
for locations/search end point, timestamp does not apply, you can change distance url param and get more results: http://www.gramfeed.com/instagram/places

Instagram tag search - filter for images and tags after a certain time or id

I am using the Instagram API to fetch a list of photos tagged with a certain hashtag. I've got a real-time subscription set up so it will notify me whenever new photos have been posted. However, I have to fetch the new results myself.
My problem: When I request the list of recently tagged photos, I get a large list and I don't want to process all of the results in the recent list every time I do this. The api docs say I can pass these optional parameters, but they seem counter-intuitive. They seem to be the opposite of what I would expect:
MIN_ID Return media before this min_id.
MAX_ID Return media after this max_id.
If I keep track of the most recent media id I've seen in my recent requests, how do I construct my next request to only return results newer than that id?
I've posted two photos with a test hashtag. When I use the following url (with my real access_token in it), I get back a json response listing both of those photos:
https://api.instagram.com/v1/tags/weirdtest/media/recent?access_token=xxx
The two photos have these ids:
221201236060507271_179249322
221190263853517857_179249322
How do I construct a query that returns only the newer of those two photos?
Tack the most recent ID you've seen on the end, using the MAX_ID request parameter:
https://api.instagram.com/v1/tags/weirdtest/media/recent?access_token=xxx&MAX_ID=221201236060507271_179249322
This should tell Instagram, *"The most recent photo I've seen is 221201236060507271_179249322, return only newer photos"*.