Search code examples
facebookfacebook-graph-apiinstagraminstagram-api

Search recent media and comment via Instagram API and Graph API


I want to build an app where the app user can from within the app

  1. search Instagram's most recent media by a search term (Hashtag-Search)
  2. post comments to Instagram posts

For searching Instagram the Graph API can't be used, because it doesn't has such capability. Therefore I need to use the old Instagram API, correct? But Instagram states "The Instagram Graph API is Now Available to All Developers. For Non-Business Instagram Accounts please continue to use the existing Instagram Platform API". The users of my platform have business accounts which I need for posting comments via the Graph API.

Do I have to use the Instagram API for searches by the app users (1.) and the Graph API for posting comments(2.)?

Is there another way to search for Instagram media which is not against Instagram policies?


Solution

  • Yes, You need to use both APIs; in other words, have to have access token for both apps just for the same Instagram account, doing oauth handshake to each API's authentication.

    Also to note - for your first requirement: Search media by hashtags in Instagram API, you need your app to have public_content scope; which Instagram no longer approves to new apps. So, unless you have an oauth app already with this scope for Instagram API; most likely it wouldn't be possible to use developer apis for search.

    For limited tag search you can use public web api:

    https://www.instagram.com/explore/tags/{tagName}/?__a=1
    

    for example: https://www.instagram.com/explore/tags/apple/?__a=1

    This is just for recent media - I guess, this API does not guarantee all media.