Hashtag Search API

The Hashtag Search API allows you to find public photos and videos that have been tagged with specific hashtags.

Limitations

  • You can query a maximum of 30 unique hashtags on behalf of an Instagram Business User within a rolling, 7 day period. Once you query a hashtag, it will count against this limit for 7 days. Subsequent queries on the same hashtag within this time frame will not count against your limit, and will not reset its initial query 7 day timer.
  • Personally identifiable information will not be included in responses.
  • You cannot comment on hashtagged media objects discovered through the API.
  • Hashtags on Stories are not supported.
  • Emojis in hashtag queries are not supported.
  • The API will return a generic error for any requests that include hashtags that we have deemed sensitive or offensive.

Requirements

In order to use this API, you must undergo App Review and request approval for:

Endpoints

The Hashtag Search API consists of the following nodes and edges:

  • the /ig-hashtag-search root edge, used to get a specific hashtag's node ID
  • the /hashtag node, which corresponds to a specific hashtag
  • the /hashtag/top-media edge, used to get all the most popular photos and videos that have a specific hashtag
  • the /hashtag/recent-media edge, used to get the most recently published photos and videos that have a specific hashtag
  • the /user/recently_searched_hashtags edge, used to determine the unique hashtags an Instagram Business User has searched for in the current week

Refer to each endpoint's reference documentation for supported fields, parameters, and usage requirements.

Common Uses

Getting Media Tagged With A Hashtag

To get all of the photos and videos that have a specific hashtag, first use the /ig_hashtag_search root edge and include your Business User ID and the hashtag. For example, if your Business ID is 17841405309211844, you could get the ID for the "#coke" hashtag by performing the following query:

GET graph.facebook.com/ig_hashtag_search
  ?user_id=17841405309211844
  &q=coke

This will return the ID for the “#Coke” hashtag node:

{
  "id" : "17873440459141021"
}

Now that you have the hashtag ID (17873440459141021), you can query its /top_media or /recent_media edge and include your Business Account ID to get a collection of media objects that have the “#coke” hashtag. For example:

GET graph.facebook.com/17873440459141021/recent_media
  ?user_id=17841405309211844

This would return a response that looks like this:

{
  "data": [
    {
      "id": "17880997618081620"
    },
    {
      "id": "17871527143187462"
    },
    {       
      "id": "17896450804038745"     
    }
  ]
}