Need help with rtweet?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

ropensci
631 Stars 175 Forks Other 1.3K Commits 21 Opened issues

Description

🐦 R client for interacting with Twitter's [stream and REST] APIs

Services available

!
?

Need anything else?

Contributors list

No Data

rtweet

R-CMD-check CRAN
status Coverage
Status Downloads DOI DOI <!-- badges: end -->

Use twitter from R. Get started by reading

vignette("rtweet")
.

Installation

To get the current released version from CRAN:

install.packages("rtweet")

Usage

All users must be authenticated to interact with Twitter’s APIs. The easiest way to authenticate is to use your personal twitter account - this will happen automatically (via a browser popup) the first time you use an rtweet function. See

auth_setup_default()
for details. Using your personal account is fine for casual use, but if you are trying to collect a lot of data it’s a good idea to authentication with your own Twitter “app”. See
vignette("auth", package = "rtweet")
for details.
library(rtweet)

{{rtweet}} should be used in strict accordance with Twitter’s developer terms.

Search tweets or users

Search for up to 10,000 tweets containing #rstats, excluding retweets:

rt 

Twitter rate limits cap the number of search results returned to 18,000 every 15 minutes. To request more than that, set

retryonratelimit = TRUE
and rtweet will wait for rate limit resets for you.

Search for 1,000 users with the #rstats in their profile:

usrs 

Stream tweets

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

rt 

Stream all geo-located tweets from London for 60 seconds:

rt 

Get friends and followers

Get all accounts followed by a user:

## get user IDs of accounts followed by CNN
cnn_fds 

Get all accounts following a user:

## get user IDs of accounts following CNN
cnn_flw 

If you want all followers, you’ll need you’ll need to set

n = Inf
and
retryonratelimit = TRUE
but be warned that this might take a long time.

Get timelines

Get the most recent 3,200 tweets from CNN, BBC World, and Fox News:

## get user IDs of accounts followed by CNN
tmls 

Get favorites

Get the 3,000 most recently favorited statuses by Justin Bieber:

jkr 

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.

ropensci\_footer

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.