Trouble accessing user profile, media data, and insights using Instagram Graph API

238 views Asked by At

I have created an app on the Meta Developer Account and have added the Instagram Basic Display API and Instagram Graph API to my app. I have successfully obtained the necessary permissions, including instagram_graph_user_profile and instagram_graph_user_media, and I have completed the verification process.

However, I'm encountering difficulties in accessing user profile data, media data, and insights using the Instagram Graph API. Here is what I have tried:

Retrieving user profile data:

const profileResponse = await fetch(`https://graph.instagram.com/me?fields=id,username,media_count,followers_count,follows_count&access_token=${accessToken}`);
const profileData = await profileResponse.json();

Retrieving media data:

const mediaResponse = await fetch(`https://graph.instagram.com/me/media?fields=id,caption,permalink,media_type,thumbnail_url,media_url,timestamp&access_token=${accessToken}`);
const mediaData = await mediaResponse.json();

Retrieving insights for each media item:

for (const media of mediaData.data) {
  const insightsResponse = await fetch(`https://graph.instagram.com/${media.id}/insights?metric=engagement,impressions,reach&access_token=${accessToken}`);
  const insightsData = await insightsResponse.json();
}

I expected to receive comprehensive user profile data, including fields such as followers count, follows count, and other relevant information. For media data, I expected to obtain detailed information such as like count, comment count, and view count. Additionally, I anticipated retrieving insights for each media item, including engagement, impressions, and reach metrics.

What actually resulted: Unfortunately, the received profile data only contains basic information such as id, username, media_count, followers_count, and follows_count. The media data does not include the desired insights such as like count, comment count, and view count. Furthermore, attempting to retrieve insights for each media item throws an error stating "Tried accessing nonexisting field (insights) on node type (Media)."

I have carefully reviewed the official documentation and ensured that my app has the necessary permissions. However, I am still unable to access the desired data. Can anyone provide guidance or suggest any additional steps required to access the comprehensive user profile data, media data with insights?

Any help or insights would be greatly appreciated. Thank you!

0

There are 0 answers

Related Questions in INSTAGRAM-GRAPH-API