Instagram feeds using tag name of particular user - instagram

I am trying to fetch the instagram feeds to my site using tag name.
https://api.instagram.com/v1/tags/{tag-name}?access_token=ACCESS-TOKEN
above is the api which I am using to get the feeds.
Now the feeds are displaying from all the users who use the tag. I need to restrict the feeds for the particular user who use the tag name.
Anyone come across this?
Thanks,

The current version of the Instagram Api does not have an endpoint that will allow you to get media by tag-name AND user-id. Your best bet is to use 1 of the following endpoints, and then loop through the results and filter out the media that matches the 2nd condition.
Search for posts by given hashtag's name using GET /tags/{tag-name}/media/recent API endpoint request and then filter the response list of media to match the user-id for the particular user in question.
or
Search for posts by the particular user using GET /users/{user-id}/media/recent API endpoint request and then manually check every post if its tags array contains the specific hashtag you are looking for.
I recommend you go with option 2 as that will be faster, since an individual user feed is a much smaller data set than media from 1000s of Instagram users tagged with a hashtag.

Related

How to make more posts/data appear on instagram

I'm using this url: https://www.instagram.com/explore/tags/meugatonovet/?__a=1, to get hashtag data. With this parameter it shows a json, but returns only 39 posts/pots of 7,000 thousand.
Is there a tool, some parameter or something else that can make it return more data?
Using ?__a=1 parameter is a neat trick to get JSON data for any Instagram page, but it's not an official API; Instagram can block your IP address any time and the endpoint is not guaranteed to remain stable.
The official way to look up media via hashtag is with Graph API Hashtag Search.
See getting started for initial steps. You need a business account ID for your Instagram profile which is required parameter for hashtag search. Then you can do these steps:
Find the ID of the hashtag you are looking for, for example:
GET https://graph.facebook.com/v13.0/ig_hashtag_search?user_id=<business account ID>&q=meugatonovet&access_token=<user access token>
This will return a JSON of the hashtag:
{
"data": [
{
"id": "17878113037414936"
}
]
}
Use that ID in other requests, for example /recent_media:
GET https://graph.facebook.com/v13.0/17878113037414936/recent_media?user_id=<business account ID>&fields=id,media_type,comments_count,like_count,media_url&access_token=<user access token>
The response will also provide the pagination cursor which lets you read all the data within API limitations.
Other less official options are web scraping or using Instagram's private API (there are actively maintained libraries for that, like instagram-private-api), but mind that this might get you banned and it breaks Instagram's ToS. It's probably fine for a personal project, but not so fine for a commercial use.
This endpoint is not working anymore:
https://www.instagram.com/explore/tags/username/?__a=1
However, a possible solution is adding __d=dis to your payload:
https://www.instagram.com/explore/tags/username/?__a=1&__d=dis
Please, take into account that this is an unofficial method, and you can get banned as #jnv advised.
Best regards

Instagram API receiving unrelated media for specified hashtag

I'm currently making requests to the Instagram API. Specifically, the endpoint https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token=ACCESS-TOKEN (specified here).
Using the example tag doggo, I'm receiving mostly responses whose JSON tags contain doggo; however, I also receive media with empty tags entries:
Would anybody happen to know why this sort of situation might occur? The range of untagged media that appears to slip in varies wildly in relevance to the specified tag, so I'm curious if this is a bug or some sort of Instagram algorithm to infer a media item's relevance to the specified tag.
Thanks!

How to retrieve Instagram followers' locations?

I've searched through the topics but it seems that exactly this questions hadn't been asked yet.
Could anyone, please, share their opinion on how to retrieve an Instagram account followers' posts locations in order to map them after that on one map?
On the account there are around 2000-2100 followers.
Thank you in advance!
To get detailed user information from instagram you have to use the GET /users/user-id endpoint.
So to get the location information for all an accounts followers you have to use
GET/users/user-id/followed-by and iterate through the results.
Be careful. Instagram api limit is currently 5000 requests per hour. Accounts with more followers than that you will have to use some form of queue
Edit: just seen you want the post locations:
Similar method, excite instead of GET /users/user-id user GET /users/user-id/recent and grab the locations of the media. Note in my experience the location function is used very little by instagram users. I once pulled 3000 media that had only 20 media with a location
You cannot just location of a user using APIs, there are couple ways you can guess the location, by looking for bio information and check if they have any location specified or you can check location of all the photos posted by a user and kind of guess the location by analyzing where most of the photos are being posted at.
you can use the API /users/user-id/recent to get all the photos from a user and look for location property in API response and map it on google map.
you can use http://gramfeed.com to see user photos with a map of photo locations, you will have to do this for each user and determine the location.

How to grab instagram users based on a hashtag?

is there a way to grab instagram users based on a specific hashtag ?
I run contests based on re posting photos with specified hashtag then randomly pick a winner, i need a tool that can grab the usernames of those who reposted that photo and used that hashtag.
You can query instagram using the API. There are official clients for both python and ruby.
You didn't specify what language/platform you are using, so I'll give you the generic approach.
Query instagram using the Tag Recent Media endpoint.
In the response, you will receive a user object that has the user's username, id, profile url, and so on. This should be enough to do what you are describing.
As far as tools, there aren't great options to probably do things exactly how you want. If you just want a simple contest, you could use statigram, but it's not free.
If you roll your own solution, I highly recommend you also do the following:
Implement a rate limiting mechanism such as a task queue so you don't exceed your API calls (5000 per hour for most calls). Also useful for failures/network hicups, etc.
Have users authenticate so you can use OAuth to extend your API calls to 5000/per user/hour to get around #1.
Try the subscribe API if there won't be many items. You can subscribe to a specific tag as well, and you will get a change notification. At that point though you need to retrieve the actual media item(s), and this can cost a lot of API calls depending on how frequent and what volume these changes occur.
If your users don't have much photos/relatively small/known in advance, you can actually query the user's recent media instead and filter in your own code by hash tag.

find venue with twitter id via API

We integrate our service to 4sqr, this is done by our customer informing us of their venue-id from the 4sqr URL. However, if a venue is claimed and a twitter associated with the venue the url is switched to one with the twitter id.
so, one of two things after this twitter acct is in place for a venue:
1. how does one find the venue-id in your UI?
or
2. how does one query the venue details using the twitter handle?
thanks
Foursquare's /users/search should work (you're basically searching for a "venue user"). https://developer.foursquare.com/docs/explore#req=users/search%3Ftwitter%3Dwinkellyauto

Resources