<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/statistics-sunday-accessing-the-youtube-api-with-tuber/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.deeplytrivial.com/2018/06/statistics-sunday-accessing-youtube-api.html"> Deeply Trivial</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I haven’t had a lot of time to play with this but yesterday, I discovered the <a rel="nofollow" href="https://github.com/soodoku/tuber" target="_blank">tuber</a> R package, which allows you to interact with the YouTube API.</p>
<p>To use the tuber package, not only do you need to install it in R – you’ll need a Google account and will have to authorize 4 APIs through <a rel="nofollow" href="https://console.developers.google.com/" target="_blank">Developer Console</a>: all 3 YouTube APIs (though the <a rel="nofollow" href="https://developers.google.com/youtube/v3/getting-started" target="_blank">Data API</a> will be doing the heavy lifting) and the Freebase API. Before you authorize the first API, Google will have you create a project to tie the APIs to. Then, you’ll find the APIs in the <a rel="nofollow" href="https://console.developers.google.com/apis/library" target="_blank">API library</a> to add to this project. Click on each API and on the next screen, select Enable. You’ll need to create credentials for each of the YouTube APIs. When asked to identify the type of app that will accessing the YouTube API, select “Other”.</p>
<p>The tuber package requires two pieces of information from you, which you’ll get when you set up credentials for the OAuth 2.0 Client: client ID and client secret. Once you set those up, you can download them at any time in <a rel="nofollow" href="http://www.deeplytrivial.com/2018/04/j-is-for-jsonlite-package.html" target="_blank">JSON</a> format by going to the <a rel="nofollow" href="https://console.developers.google.com/apis/credentials" target="_blank">Credentials dashboard</a> and clicking the download button on the far right.</p>
<p>In R, load the tuber package, then call the yt_oauth function, using the client ID (which should end with something like “apps.googleusercontent.com”) and client secret (a string of letters and numbers). R will launch a browser window to authorize tuber to access the APIs. Once that’s done, you’ll be able to use the tuber package to, for instance, access data about a channel or get information about a video. My plan is to use my <a rel="nofollow" href="http://www.deeplytrivial.com/2018/06/working-with-your-facebook-data-in-r.html" target="_blank">Facebook dataset</a> to pull out the head songs I’ve shared and get the video information to generate a dataset of my songs. Look for more on that later. In the meantime, this <a rel="nofollow" href="https://insightr.wordpress.com/2017/12/11/using-the-tuber-package-to-analyse-a-youtube-channel/" target="_blank">great post on insightr</a> can give you some details about using the tuber package.</p>
<p>[Apologies for the short and late post – I’ve been sick and haven’t had as much time to write recently. Hopefully I’ll get back to normal over the next week.]</p>
<div><a rel="nofollow" href="https://i2.wp.com/1.bp.blogspot.com/-3YG3bUQZ06k/We4DYIl5EpI/AAAAAAAAJnY/IHMK0Mmwg6YJJd6iZlCBxEl8Djz0djbqgCPcBGAYYCw/s1600/statistics_sunday.jpg?ssl=1" target="_blank"><img border="0" src="https://i1.wp.com/1.bp.blogspot.com/-3YG3bUQZ06k/We4DYIl5EpI/AAAAAAAAJnY/IHMK0Mmwg6YJJd6iZlCBxEl8Djz0djbqgCPcBGAYYCw/s320/statistics_sunday.jpg?resize=450%2C747&ssl=1" data-original-width="450" width="450" data-original-height="747" data-recalc-dims="1"></a></div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.deeplytrivial.com/2018/06/statistics-sunday-accessing-youtube-api.html"> Deeply Trivial</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/TQ--pEWiguU" height="1"></a></div>