Search code examples
google-apiyoutubeyoutube-apiyoutube-data-apiyoutube-analytics-api

Google API to get impressions of youtube videos?


Is there any API available to fetch Impressions of a youtube video? or the Impressions of all the videos in a account?

Note: I'm looking for video thumbnail impressions and not (card or annotation impressions)

Sample: This 1.9M is the data I'm interested in this video

enter image description here


Solution

  • As always YouTube APIs doesn't provide access to a basic feature but here is a workaround:

    The following answer is similar to the one I wrote about retrieving Unique viewers from the Audience tab.

    Go on your Video analytics interface in YouTube Studio.

    Open the Web Developer Tools Network tab of your web-browser (by using Ctrl + Shift + E on Firefox for instance).

    Now select Reach, pay attention to select one of following:

    Because options:

    Are maybe unavailable (depends if its a published video or depends on the time of video upload):

    Total number of unique viewers is only available for periods of up to 90 days to ensure data quality.

    You should see a request to get_screen, copy it as cURL (by right-clicking).

    Pay attention to remove -H 'Accept-Encoding: gzip, deflate, br' from it in order to get the JSON response in a human readable format. Otherwise you would face the following warning:

    Warning: Binary output can mess up your terminal. Use "--output -" to tell curl to output it to your terminal anyway, or consider "--output " to save to a file.

    In --data-raw request argument --data-raw '{"screenConfig":{"entity":{"videoId":"VIDEO_ID"} pay attention to change the VIDEO_ID for the one interesting you.

    Execute the modified cURL request and your Impressions and Impressions click-through rate values are in the JSON response respectively at the keys /cards/0/keyMetricCardData/keyMetricTabs/{0,1}/primaryContent/total.