Search code examples
instagram-graph-api

Get video views for Instagram posts error in Graph Api


I am using the graph api explorer to create a query to get insights data about my Instagram page. It looks like this and it works fine. Some posts are photos some are videos.

IG id/media?fields=timestamp,caption,permalink,media_type,like_count,comments_count,insights.metric(reach,impressions,saved,engagement)

When i add the video_views metric though i get an error

"message": "(#100) Can not show video views count for non video media"

Anyone know what am i doing wrong? I just want to get the video views if the post is a video.


Solution

  • Probably too late, but if you call 'video_views' on an IMAGE media, it will give you this error. You must handle the IMAGE and VIDEO media separately (i mean with separate fields)

    Something like : (pseudo code)

    if(post_type == 'VIDEO'):
        fields for video ...
    else:
        fields for image ...