youtubeAnalyticsR
YouTube Analytics API R library
Retrieves your YouTube Analytics data. This is an R package autogenerated via googleAuthR's Discovery API builder. The Google Documentation for this API is here.
Setup
- Get a Google Project
- Activate the YouTube API in your google project.
- Get the OAuth2 client ID and secret (see GoogleAuthR readme for details)
- Set options
options(googleAuthR.client_id = XXX)
andoptions(googleAuthR.client_secret = XXX)
- Load the library
- Run
yt_auth()
and authenticate with your user - Run
yt_analytics()
to get data
Work in progress, any requests please file a Github issue.
options(googleAuthR.client_id = XXX)
options(googleAuthR.client_secret = XXX)
library(youtubeAnalyticsR)
## authenticate with a user who has access to the YouTube channel you want to analyse
yt_auth()
## get the unique ID of your YouTube Channel
## Dimensions and metrics are here: https://developers.google.com/youtube/analytics/v1/channel_reports#video-reports
ya <- yt_analytics("UCvcKAjtJAzVr0vgLNR5w7Fg",
start.date = "2016-09-01", end.date = "2016-10-01",
metrics = c("views","comments","likes","dislikes"), dimensions = "day")
ya
# day views comments likes dislikes
#1 2016-09-23 49 0 1 0
#2 2016-09-26 91 1 0 0
#3 2016-09-13 10 0 3 0
#4 2016-09-18 42 0 3 0
#5 2016-09-30 10 1 1 0