Learn R Programming

⚠️There's a newer version (2.0.0) of this package.Take me there.

rtweet

Use twitter from R. Get started by reading vignette("rtweet").

Installation

To get the current released version from CRAN:

install.packages("rtweet")

You can install the development version of rtweet from GitHub with:

install.packages("rtweet", repos = 'https://ropensci.r-universe.dev')

Usage

All users must be authenticated to interact with Twitter’s APIs. See vignette("auth", package = "rtweet") for details.

library(rtweet)

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

Usage

Depending on if you are a paid user or not you can do more or less things.

Free

You can post (tweet_post()) and retrieve information about yourself (user_self()).

Paid

You can do all the other things: search tweets (tweet_search_recent()), retrieve your own bookmarks (user_bookmarks()), check who follows who, (user_following(), or user_followers()), ….

Contact

Communicating with Twitter’s APIs relies on an internet connection, which can sometimes be inconsistent.

If you have questions, or needs an example or want to share a use case, you can post them on rOpenSci’s discuss. Were you can browse uses of rtweet too.

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.

Code of Conduct

Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('rtweet')

Monthly Downloads

2,782

Version

1.2.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Last Published

October 16th, 2023

Functions in rtweet (1.2.1)

auth_save

Save an authentication mechanism for use in a future session
auth_setup_default

Set up default authentication
do_call_rbind

Binds list of data frames while preserving attribute (tweets or users) data.
client_save

Save an authentication mechanism for use in a future session
client_get

Get the current client
auth_as

Set default authentication for the current session
auth_get

Get the current authentication mechanism
direct_messages

Get direct messages sent to and received by the authenticating user from the past 30 days
emojis

Defunct: Emojis codes and descriptions data.
client_has_default

Set up default client
get_retweets

Get the most recent retweets/retweeters
list_members

List of members from a specified List
get_timeline

Get one or more user timelines
clean_tweets

Clean text of tweets
direct_messages_received

(DEPRECATED) Get the most recent direct messages sent to the authenticating user.
get_token

Fetch Twitter OAuth token
get_trends

Get Twitter trends data.
entity

Extract methods
list_membership

Lists a specified user is a member of.
invalidate_bearer

Invalidate bearer token
ids

Extract the ids
get_friends

Get user IDs of accounts followed by target user(s).
flatten

flatten/unflatten data frame
lookup_coords

Get coordinates of specified location.
client_as

Set default client for the current session
list_followers

List followers of a specified list
list_tweets

Lists tweets of a specified list
job_compliance

Job compliance
langs

Defunct: Language codes recognized by Twitter data.
get_mentions

Get mentions for the authenticating user.
lists_members

Get Twitter list members (users on a given list).
lists_memberships

Get Twitter list memberships (lists containing a given user)
network_data

Network data
lists_statuses

Get a timeline of tweets authored by members of a specified list.
lookup_friendships

Lookup friendship information between two specified users.
post_list

Manage Twitter lists
next_cursor

Extract cursor (for cursor based pagination)
lists_users

Get all lists a specified user subscribes to, including their own.
list_get

List information
search_fullarchive

Premium Twitter searches
create_token

Create custom Twitter OAuth token
lookup_collections

Collections API
post_message

Posts direct message from user's Twitter account
lists_subscribers

Get subscribers of a specified list.
post_favorite

Favorites target status id.
lookup_tweets

Get tweets data for given statuses (status IDs).
search_tweets

Get tweets data on statuses identified via search query.
lists_subscriptions

Get list subscriptions of a given user but does not include the user's own lists.
post_destroy

Delete status of user's Twitter account
tweet_embed

Create a Tweet Embed
lookup_users

Get Twitter users data for given users (user IDs or screen names).
get_favorites

Get tweets liked/favorited by one or more users
post_tweet

Posts status update to user's Twitter account
get_followers

Get user IDs for accounts following target user.
search_users

Search for users
set_fields

Create fields
parse_stream

Parser of stream
plain_tweets

Clean up character vector (tweets) to more of a plain text.
post_follow

Follows target Twitter user.
post_friendship

Updates friendship notifications and retweet abilities.
lat_lng

Adds single-point latitude and longitude variables to tweets data.
rate_limit

Rate limit helpers
previous_cursor

Previous cursor
set_scopes

Scopes of the OAuth2 token
tweet_get

Get tweet information
user_list_follows

Lists a specified user follows
user_timeline

User timeline
user_lists

Search users by username
links

Create the links
read_twitter_csv

Read comma separated value Twitter data.
rtweet-package

rtweet: Collect Twitter data from R
rtweet_client

Client
stream_tweets2

A more robust version of stream_tweets
tweets_with_users

Parsing data into tweets/users data tibbles
user_block

Blocking or unblocking twitter users
stopwordslangs

Defunct: Twitter stop words in multiple languages data.
user_tweets

Tweets from a user
stream

Streaming
max_id

Extract min/max id (for id based pagination)
tweet_search_recent

Search recent tweets
tweet_search_all

Search in the Twitter archive
stream_tweets

Collect a live stream of Twitter data
user_mentions

Tweets mentioning a user
tweet_counts_recent

Count tweets
tweet_delete

Delete tweet
tweet_shot

Capture an image of a tweet/thread
users_data

Get tweets from users, or users from tweets
write_as_csv

Save Twitter data as a comma separated value file.
my_friendships

Lookup friendship information between users.
user_muted

List muted users
trends_available

Available Twitter trends along with associated WOEID.
tweet_threading

Collect statuses contained in a thread
user_following

Find which users are being followed.
retrieve_errors

Expose errors of the response
user_liked_tweets

Liked tweets from a user
tweet_post

Post a tweet
tweet_liking_users

Liking users
round_time

A generic function for rounding date and time values
user_by_username

Search users by username
rtweet_user

Authentication options
ts_data

Converts tweets data into time series-like data object.
rules

Extract the streaming rules
user_followers

Find followers.
ts_plot

Plots tweets data as a time series-like data object.
tweet_quoted

Get quoted tweet information
user_search

Search users
tweet_retweeted_by

Tweet retweeted by
user_blocked

Find followers.
user_self

Tweets from a user
user_bookmarks

Retrieve user bookmarks
Expansions

Expansions
TWIT_paginate_max_id

Pagination
as_screenname

Mark a user id as a screen name
Fields

Fields
auth_sitrep

Twitter Tokens sitrep
bearer_token

Bearer token