Pathetic state of Instagram API - instagram-api

Related questions with answers which are no more valid:
How Does Instagram's GET/tags//media/recent Pagination Actually Work?
Understanding min_tag_id and max_tag_id
Instagram Search for a tag within particular date range
As I am exploring the Instagram API and my app is in sandbox mode, I am surprised by API at every step. This should not be condition of public API
( who cares !).
The Api end point I am trying to is:
https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token=ACCESS-TOKEN
Well the required parameters are:
access_token [A valid access token.]
max_tag_id [Return media after this max_tag_id.]
min_tag_id [Return media before this min_tag_id.]
count [Count of tagged media to return.]
Since I dont know how to get or generate max_tag_id and min_tag_id, I skipped and tried this :
https://api.instagram.com/v1/tags/jokes/media/recent?access_token=x.y.x&count=10
The response I get is:
{"pagination": {"deprecation_warning": "next_max_id and min_id are
deprecated for this endpoint; use min_tag_id and max_tag_id instead"},
"data": [], "meta": {"code": 200}}
May be I need max_tag_id and min_tag_id and lets trying putting
rang values 1 to 10 ( I dont know how to generate these values )
https://api.instagram.com/v1/tags/jokes/media/recent?access_token=x.y.x&count=10&min_tag_id=1&max_tag_id=10
The response I get is:
{"meta": {"code": 400, "error_type": "APIInvalidParametersError",
"error_message": "max_id must not be a media id."}}
Now the error is misleading, I never provided parameter max_id as you can see.
Please help to reduce this insanity
For those who are not getting the question:
What is the valid value for max_tag_id and min_tag_id
What is the meaning of max_id must not be a media id. when there is no such parameter passed etc ..

Looks like you are in Sandbox mode, so you will not get any public data, you will only get data from you or your sandbox users.
Try search for an hashtag that you have posted a photo for, then you will just see that photo in API response.
Once you get approved with public_content permission, and go live, you will see all data.
max_tag_id and min_tag_id are encrypted now, you cannot just generate, you first make a API call without the max_id or min_id, you will get the response with 20 results with max_tag_id in the pagination section of API response, which you can use this max_tag_id to make next API call, for next set of 20 results.
(and btw you will have pagination in API response only if you are approved by Instagram and are out of Sandbox, so go figure, good luck)

Related

Finding Instagram tag_id of a post to search by date range

I'm building a JavaScript app that returns Instagram posts with a given tag, using the tags/tag-name/media/recent endpoint. I'm trying to add in functionality to search by date range. Min/max_timestamp works for the Users API, but the Tag API only accepts min/max_tag_id. Following the suggestion here, I am trying to search the Users API with my dates of interest. The idea is to get post id's that correspond with my dates, then plug those id's into the min/max_tag_id in the Tag API.
However, the post id returned from the Users API (ie 9999999999999999999_9999999) appears to be a different format than what min/max_tag_id is looking for, confirmed by a Tag API paging response (131 character string of characters, numbers, underscores and hyphens).
Is there any way I can find a tag_id using a date-based search?
The max_tag_id and min_tag_id value is not media_id anymore after the June 1, 2016 API changes.
When API was first launched, the max_tag_id and min_tag_id was taking epoch timestamp value, then it was changed to actual media_id and now it looks like it is some cryptic value that is not easy to decode.
I was supporting date/time search for all feeds before, but now it is not possible for tag media feed. I have implemented date/time search in https://picodash.com for all feeds except tag media

Instagram API search by tag, blank return

I'm trying to use the search by tag API to return the JSON result, but it returned a blank result.
This is the API request format from their website. I only set the tag-name & access token parameters.
https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token=ACCESS-TOKEN
I already set my access token's scope as public_content so that I can use this particular API.
However, the result I got is:
{
"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": []
}
Which was basically nothing. I read that I should be expecting max & min ids. I had already checked that the hashtag I'm searching has more than 200 entries, so there should be more than one page.
No issues with other insta APIs when searching by userids, just can't get it to work on this and searching by recent media.
Really appreciate any help. Thank you!
By the looks of things, you're getting a deprecation warning because you are passing the next_max_id and min_id parameters in your request.
As mentioned in the result you got, you should use min_tag_id and max_tag_id instead (if you want these parameters in your request). This is mentioned in the Instagram Developer documentation
ACCESS_TOKEN A valid access token.
COUNT Count of tagged media to return.
MIN_TAG_ID Return media before this min_tag_id.
MAX_TAG_ID Return media after this max_tag_id.
Sorry, I'm not sure what you mean by "expecting max & min ids". If you mean you're expecting them in the response, then this is a wrong expectation.
Also, another possible cause for your problem is the recent Instagram Platform update, which has forced all clients created after November 17th, 2015 to be in Sandbox mode and go through a review process. If you are affected by this, note that your results will be "filtered" depending on the Sandbox users you have (in which case, you might not have the number of results you were expecting).

Instagram min_tag_id leaves out posts

I am using the Instagram real-time API to get the most recent posts of a certain hashtag. Therefore I subscribed to the API and Instagram makes a callback everytime a post gets tagged with that hashtag.
Ever 5 seconds my application checks if there where any callbacks (I register every callback to make sure, that I don't make any requests to Instagram if there where no callbacks before)
When there was at least one callback, I make a request to the "tags/media/recent" endpoint. Additionaly I store the min_tag_id of every response and send it with the next request. That way Instagram only sends me the "newest" content.
So far so good.
Instagram is "kind" enough to indicate the min_tag_id I should use next. In a normal response it should look like this (I shortened the response a little):
"pagination":{
"min_tag_id": "1061443126713008625" // the min_tag_id I can use for the next request
},
"data":[
{
"id" : "1061443126713008625_782775143", // id of the first post
// rest of the data...
},{
"id" : "1061443123569823070_176952626", // id of another post
// rest of the data...
}
]
As you can see, the min_tag_id given by Instagram is part of the id of the first post.
"min_tag_id":"1061443126713008625"
"id":1061443126713008625_782775143"
So next time I make a request with that min_tag_id, I receive all posts coming afterwards.
But
Sometimes Instagram gives me a min_tag_id but doesn't send me the post with that id. Like so:
"pagination": {
"min_tag_id": "1061443926677909216"
}
"data":[
{
"id" : "1061443924303843601_1666507083"
// ...
},{
"id" : "1061443905925893282_479418538"
// ...
}
]
And the next time I use the new min_tag_id I get all the posts coming afterwards but not the post with that id.
In short I am missing some posts when using the pagination.
Is there anything that I am doing wrong? Is the pagination not meant for that?
Sometimes Instagram doesn't send me anything at all (besides the pagination) and sometimes the post with the min_tag_id is contained in a response afterwards.
If I am not doing anything wrong and if I just have to live with it, does anyone know a way to get the real id of the post with just the min_tag_id ? As you can see they are not the same and I don't know the last part (***_1666507083)
This seems to be a known issue, as discussed here.
Have you tried passing in a large count parameter as suggested by #Amir
You will also need to pass a large count parameter and follow the
pagination of the response to receive all data without losing anything
when the speed of tagging is faster than your polling.
Source: https://stackoverflow.com/a/29877510/325521

Whats the new max_tag_id value for pagination set by Instagram API?

I am creating app where I use Instagram API to display images filtered by Tag, date and likes. Previously, to filter date instagram used to append the epoch time with max_tag_id and min_tag_id. Now, the format has changed:
"pagination": {
"next_max_tag_id": "962224976421224235",
"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": "962224976421224235",
"next_min_id": "962225472549366575",
"min_tag_id": "962225472549366575",
"next_url": "https://api.instagram.com/v1/tags/nyc/media/recent?client_id=02e15f8b37f34d1f8da7ddcb0a55bae6&max_tag_id=962224976421224235"
}
max_tag_id=962224976421224235
How is max_tag_id calculated now? Instagram has not updated it's API doc on the same. Also, gramfeed.com had implemented the date filtering functionality but now they have disabled it. Can anyone help me with this?
the new max_tag_id is the media_id of the next photo.
So in your case, if you make a request with the next_url, the first photo in the response will have the id 962224976421224235, (the actual id will look like xxx_xxxx which is mediaId_userId)
Cannot do time filter anymore :(, so I disabled it in http://gramfeed.com

Using min_id in the Instagram API

Just the fact that I can find no-one else having this problem with the Instagram API indicates to me that I am doing something wrong.
If I was to enter: https://api.instagram.com/v1/users/334250900/media/recent/?client_id=xxx&min_id=678453535718114828_919796408 and 678453535718114828_919796408 was the very latest post ID for that user, I should get nothing back, right?
Well I don't. I get one post back - the one in the min_id parameter.
The documentation states:
MIN_ID - Return media later than this min_id.
but the behaviour seems to be to return media LATER OR EQUAL TO this min_id.
If I specify a min_id that is the THIRD most recent post, I should get TWO posts back, but no, I get three.
Sure, I can throw away the last result in the returned array, or do some checking to see whether I already have it - but that kinda defeats the purpose of the parameter.
Is it just me?

Resources