def get_lifetime_account_metrics(base, node, access_token): parameters = ( f"/insights?metric=audience_city,audience_country,audience_gender_age,audience_locale,online_followers" f"&period=lifetime" f"&access_token={access_token}") url = build_url(base, node, parameters) return request_data(url)
def get_day_account_metrics(base, node, access_token): parameters = ( f"/insights?metric=email_contacts,follower_count,get_directions_clicks,impressions," f"phone_call_clicks,reach,profile_views,text_message_clicks,website_clicks&period=day" f"&access_token={access_token}") url = build_url(base, node, parameters) return request_data(url)
def get_followers_and_media_count(base, username, node, access_token): parameters = ( f"?fields=business_discovery.username({username}){{followers_count,media_count}}" f"&access_token={access_token} " ) url = build_url(base, node, parameters) return request_data(url)
def get_basic_media_metrics(base, username, node, access_token): parameters = ( f"?fields=business_discovery.username({username}){{followers_count,media_count,media{{" f"comments_count,like_count}}}}&access_token={access_token} " ) url = build_url(base, node, parameters) return request_data(url)
def get_stories_metrics(base, media_id_list, access_token): metrics_list = [] parameters = f"/insights?metric=exits,impressions,reach,replies,taps_forward,taps_back&access_token={access_token}" for media_id in media_id_list: media_node = f"/{media_id}" url = build_url(base, media_node, parameters) metrics_list.append(request_data(url)) return metrics_list
def get_media_comments(base, media_id_list, access_token): metrics_list = [] parameters = f"/comments?access_token={access_token}" for media_id in media_id_list: media_node = f"/{media_id}" url = build_url(base, media_node, parameters) metrics_list.append(request_data(url)) return metrics_list
def get_media_metrics(base, media_id_list, access_token): metrics_list = [] parameters = f"/insights?metric=engagement,impressions,reach,saved&access_token={access_token}" for media_id in media_id_list: media_node = f"/{media_id}" url = build_url(base, media_node, parameters) metrics_list.append(request_data(url)) return metrics_list
def get_media_info(base, media_id_list, access_token): att_list = [] parameters = ( f"/?fields=id,like_count,comments_count,media_type,media_url,owner,thumbnail_url," f"timestamp,username" f"&access_token={access_token} " ) for media_id in media_id_list: media_node = f"/{media_id}" url = build_url(base, media_node, parameters) att_list.append(request_data(url)) return att_list
def get_stories_id(base, node, access_token): parameters = f"/stories?access_token={access_token}" url = build_url(base, node, parameters) return request_data(url)
def get_media_id(base, node, access_token): parameters = f"/media?access_token={access_token}" url = build_url(base, node, parameters) return request_data(url)
def get_account_info(base, node, access_token): parameters = ( f"/?fields=id%2Cig_id%2Cusername%2Cname%2Cfollowers_count%2Cfollows_count%2Cmedia_count%2Cbiography" f"%2Cwebsite&access_token={access_token} ") url = build_url(base, node, parameters) return request_data(url)