DownloadsDownloadsDepsy lifecycle

R client for accessing Twitter’s REST and stream APIs. Check out the rtweet package documentation website.


NEW: All you need is a Twitter account and rtweet and you’re up and running!

API authorization

And that’s it! You’re ready to start collecting and analyzing Twitter data!

Package features

Search tweets

Search for up to 18,000 (non-retweeted) tweets containing the rstats hashtag.

Quickly visualize frequency of tweets over time using ts_plot().

Twitter rate limits cap the number of search results returned to 18,000 every 15 minutes. To request more than that, simply set retryonratelimit = TRUE and rtweet will wait for rate limit resets for you.

Search by geo-location—for example, find 10,000 tweets in the English language sent from the United States.

Stream tweets

Randomly sample (approximately 1%) from the live stream of all tweets.

Stream all geo enabled tweets from London for 60 seconds.

Stream all tweets mentioning realDonaldTrump or Trump for a week.

Get favorites

Get the 3,000 most recently favorited statuses by JK Rowling.

jkr <- get_favorites("jk_rowling", n = 3000)

Search users

Search for 1,000 users with the rstats hashtag in their profile bios.

Post actions

  • Posting (tweeting from R console) or reading direct messages require addtional permissions
  • If you’d like to post Twitter statuses, follow or unfollow accounts, and/or read your direct messages, you’ll need to create your own Twitter app.
  • To create your own Twitter app, follow the instructions in the authorization vignette on obtaining and using access tokens.


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.