Skip to content

Instantly share code, notes, and snippets.

@ritik1009
Last active September 30, 2022 17:45
Show Gist options
  • Save ritik1009/4d171fcc846f8b6cf9c8ef6f5edceca5 to your computer and use it in GitHub Desktop.
Save ritik1009/4d171fcc846f8b6cf9c8ef6f5edceca5 to your computer and use it in GitHub Desktop.
def get_post_insights(access_token = '',api_url = '',instagram_account_id = ''):
url = api_url + instagram_account_id + '/media'
param = dict()
param['access_token'] = access_token
response = requests.get(url=url, params=param)
response = response.json()
media_insights = []
for i in response['data']:
url = api_url + i + '/insights'
param = dict()
param['access_token'] = access_token
param['metric'] = 'engagement,impression,reach,saved,video_views'
response = requests.get(url=url,params=param)
print("\n response",response)
response = response.json()
print("\n response",response)
media_insights.append(response)
return media_insights
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment