Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the most popular tags?

Tags:

instagram

How do I get the most popular tags from Instagram API? I searched the API, but didn't find a way to retrieve this data. This website gets it, but how?

like image 825
Jyotsna Avatar asked Mar 03 '14 04:03

Jyotsna


People also ask

How do you get your hashtags noticed?

Be Smart With Your Hashtags The more popular and generic a hashtag is, the harder it is to get noticed by the people who you want to interact with your posts. Choose hashtags that are relevant to your interests and industry. You can also make your own hashtags or put a spin on a trending topic.


1 Answers

The question is old, but for others also struggling the same problem, as Sebastien mentioned there is no such query. However I have been recently needing same functionality and came down idea that small traversal pretty much solves the problem.

Instagram doesn't respond you a list of tags starting with just one letter. Example:

  • https://api.instagram.com/v1/tags/search?q=a

This URL returns just one element, which is "a". However if you send a request containing two characters like

  • https://api.instagram.com/v1/tags/search?q=aa

then you'll end up with the most popular tags starting on "aa"

Afterwards you can simply traverse your desired alphabet in O(N^2) time and by joining responses you'll end up with a list of most popular tags.

Length in case of English(Latin) alphabet would be 26^2 = 676 Though you shouldn't probably try getting any more tags as the limit is still 5,000 requests and 26^3 would go for 17576.

foreach(character in 'a'...'
{
   foreach(character in 'a'...'z')
   {
       Send hashtag request 'aa'...'az'...'zz'
       Get json and merge with previous array
   }
}

Sort final array by [media_count]

Alternate approach would be to parse some huge dictionary (wikipedia dump for example) and sort out top 5000 most common prefixes and try querying them.

like image 145
georgegach Avatar answered Oct 12 '22 21:10

georgegach