Search code examples
pythoninstagram-graph-api

How to tag users via Instagram Graph API - Python


I am looking to tag users when I publish media via the Instagram Graph API.

I have been able to successfully publish photos and videos but have not been able to tag users.

This is what I am trying:

params = getCreds()  # get creds from defines
params['media_type'] = 'IMAGE'  # type of asset
params['media_url'] = 'path to my image'  # url 
params['caption'] = 'My Caption'
params['user_tags'] = ('kevinhart4real',0.5, 0.8)
imageMediaObjectResponse = createMediaObject(params)  # create a media object

Where the person I want to tag is Kevinhart4real and I want to place the tag at the XY coordinates of (.5,.8)

I have been following this tutorial


Solution

  • I used this:

    params['user_tags'] = '''   [
     {
       username:'kevinhart4real',
       x: 0.5,
       y: 0.8
     }
       ]
       '''
    

    and don't forget to add this to the container:

    endpointParams['user_tags'] = params['user_tags']