2

It's confusing some doc says it's deprecated but other pages explains how to see it in the web interface. If it's visible from studio.youtube.com it should be accessible from the API... right?

Q: With the API, how can I get the Unique viewer for a YouTube video?


According to the docs: The uniques metric was deprecated on September 27, 2016. It is not a core metric and will be supported until October 31, 2016.

But it is still present in the Studio Interface as described in the page of the Help Center

enter image description here

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Frank Boucher
  • 1,834
  • 20
  • 25
  • Does an answer like [this one](https://stackoverflow.com/a/71490683/7123660) (in term of kind of answer) interest you ? If so I can add this feature to my open-source [YouTube operational API](https://yt.lemnoslife.com). – Benjamin Loison Apr 20 '22 at 18:51
  • I would prefer an official way instead of a "screen scrapper" but it's a nice idea. – Frank Boucher Apr 20 '22 at 18:59
  • Sorry for the delay, I was looking for a solution as above but it took a lot of time due to YouTube time limitation in terms of *data processing* for my tests. So after having found a new method [like this](https://stackoverflow.com/a/71970181/7123660), I realized that it would be an alternative solution that I found easier. – Benjamin Loison Apr 24 '22 at 10:52

1 Answers1

4

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 Audience, pay attention to select one of following:

Because options:

Are maybe unavailable (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_cards, 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 Unique viewers value is in the JSON response at the key /cards/7/keyMetricCardData/keyMetricTabs/3/primaryContent/total.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
  • 1
    Wow! That's nice. Still hacky... but with the proper Cookie it works! I would have prefer a legit way, but I guess that's about it... thanks – Frank Boucher Apr 25 '22 at 20:20
  • Glad to have helped – Benjamin Loison Apr 25 '22 at 20:46
  • Seems this is not working workinymore. I cannot find a `get_screen`request. A yes weeks ago I was able to do this. – eDeviser Oct 19 '22 at 20:18
  • @eDeviser [I modified accordingly my answer](https://stackoverflow.com/posts/71987890/revisions), let me know if it's still not working on your end. – Benjamin Loison Oct 19 '22 at 23:24
  • @eDeviser I was able to make it work, but the request did not contain "get_screen" but rather started with "join?alt..." and the network request was displayed the second I applied the filters I was interested in Youtube studio. (Thanks Benjamin for the tricky solution) – Nicolas Sturm Aug 18 '23 at 09:23