0

sorry if this question already exists, i'm trying to get audience retention data from Youtube API: (https://youtubeanalytics.googleapis.com/v2/reports), most of them are FINE, but some of videos response empty rows, meanwhile I can export audience retention data to Google Sheets on Youtube manage page.

My headers:

        headers = {
            'Accept': 'application/json', 
            'Authorization': 'Bearer {}'.format(access_token)
        }

Parametters:

        params = {
            'dimensions': 'elapsedVideoTimeRatio',
            'ids': 'channel==MINE',
            'metrics': 'audienceWatchRatio',
            'startDate': video_published_date,
            'endDate': execute_date,
            'filters': 'video=={};audienceType=={}'.format(youtube_video_id, audience_type),
            'key': *youtube_api_key*
        }

audience_type is ORGANIC and AD_INSTREAM

Response:

root - INFO : {
  "kind": "youtubeAnalytics#resultTable",
  "columnHeaders": [
    {
      "name": "elapsedVideoTimeRatio",
      "columnType": "DIMENSION",
      "dataType": "FLOAT"
    },
    {
      "name": "audienceWatchRatio",
      "columnType": "METRIC",
      "dataType": "FLOAT"
    }
  ],
  "rows": []
}

Here is one of video audience retention data i got empty rows

What do I need to pay attention to in order to get audience retention data, Please let's me know

  • If I were you I would give a try to web-scraping, as in [this solution](https://stackoverflow.com/a/71987890/7123660), since the API doesn't seem to work correctly in your case. Would that fit your needs ? – Benjamin Loison Jun 14 '22 at 23:23
  • @BenjaminLoison thank you for your solution, I tried "Last 28 days" option in Youtube analytics interface and I got unique viewers value at "cards/0/keyMetricCardData/keyMetricTabs/1/primaryContent/total" is 0, Does this have anything to do with my audience retention data? – Dũng Nguyễn Jun 16 '22 at 10:27
  • Pay attention to ***as in** this solution*, I gave you a solution to a similar problem to yours. I invite you, if this method fits your needs, to adapt this method to your precise problem. – Benjamin Loison Jun 16 '22 at 10:33
  • @BenjaminLoison i'm confusing a little bit with json data I got from curl, can you tell me what should I pay attention to know the reason I got empty rows in the response – Dũng Nguyễn Jun 16 '22 at 10:34
  • You're welcome. Don't hesitate to answer your own question on StackOverflow, with a detailed answer [as mine](https://stackoverflow.com/a/71987890/7123660). – Benjamin Loison Jun 16 '22 at 11:03

0 Answers0