Build Status CRAN_Status_Badge DownloadsDownloadsTravis-CI Build Status Coverage Status Rdoc

R client for interacting with Twitter’s REST and stream API’s.

Check out the rtweet package documentation website.

Install

To get the current released version from CRAN:

install.packages("rtweet")
library(rtweet)

To get the current development version from Github:

if (!"devtools" %in% installed.packages()) {
  install.packages("devtools")
}
devtools::install_github("mkearney/rtweet")
library(rtweet)

Getting started

Update: rtweet’s website has a new domain: http://rtweet.info

  • First, you’ll need to create a Twitter app. For the callback field, make sure to enter: http://127.0.0.1:1410.

  • Once you’ve created an app, record your consumer (api) and secret keys. Screeshots can be found here.

  • Generate a token by using the create_token() function.

## name assigned to created app
appname <- "rtweet_token"
## api key (example below is not a real key)
key <- "XYznzPFOFZR2a39FwWKN1Jp41"
## api secret (example below is not a real key)
secret <- "CtkGEWmSevZqJuKl6HHrBxbCybxI1xGLqrD5ynPd9jG0SoHZbD"
twitter_token <- create_token(
  app = appname,
  consumer_key = key,
  consumer_secret = secret)
  • Once twitter_token is part of your global environment, rtweet functions should find it. However, using this method, the token will not automatically load in future sessions (you’ll need to create a token every time you start a new session).

  • Although not necessary, functions also accept tokens via the token argument. For example:

rt <- search_tweets("data science", n = 1000, token = twitter_token)

Vignettes

## authorizing API access
vignette("auth", package = "rtweet")
## quick overview of rtweet functions
vignette("intro", package = "rtweet")
## working with the stream
vignette("stream", package = "rtweet")

Package description

More technical description: An implementation of calls designed to extract and organize Twitter data via Twitter’s REST and stream API’s. Functions formulate GET and POST requests and convert response objects to more user friendly structures, e.g., data frames or lists. Specific consideration is given to functions designed to return tweets data from searches, streams, and timelines and user ids from friends and followers lists.

Contact

Communicating with Twitter’s APIs relies on an internet connection, which can sometimes be inconsistent. With that said, if you encounter an obvious bug for which there is not already an active issue, please create a new issue with all code used (preferably a reproducible example) on Github.