5.2 Twitter API access

In order to get access to Twitter API, you will have to request for a developer account. It’s a free account but Twitter controls the approval process and it is not automatic. It can take anywhere from a few minutes to a few days. However, your chances of getting a quick approval are higher if you use your .edu email address to create an account. Also note that you will have to provide a valid mobile number. We will use rtweet package written by Mike Kearney, who has written a nice vignette for getting Twitter authentication. Please follow all the steps and create an authentication token first. The vignette is available here: https://rtweet.info/articles/auth.html

I strongly recommend that you use the second method titled Access token/secret method in this vignette. For this exercise, I assume that you have this token generated and stored on your hard drive. When you save it on your hard drive, please don’t use any file extension.

Note that without the token you will not be able to obtain data from Twitter. However, for the sake of this exercise, I have already downloaded Twitter data and made available to you from this link: http://bit.ly/2DVbGia. It’s an RDS file so once you download it on your computer, read it using readRDS() function.27


  1. You have to do this only if you do not have your own Twitter credentials.