Learn R Programming

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,304

Version

2.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Last Published

February 24th, 2024

Functions in rtweet (2.0.0)

get_retweets

Get the most recent retweets/retweeters
get_favorites

Get tweets liked/favorited by one or more users
do_call_rbind

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

Defunct: Emojis codes and descriptions data.
clean_tweets

Clean text of tweets
list_get

List information
flatten

flatten/unflatten data frame
ids

Extract the ids
get_mentions

Get mentions for the authenticating user.
invalidate_bearer

Invalidate bearer token
entity

Extract methods
list_followers

List followers of a specified list
get_friends

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

Fetch Twitter OAuth token
langs

Defunct: Language codes recognized by Twitter data.
lists_users

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

Get one or more user timelines
lookup_collections

Collections API
get_trends

Get Twitter trends data.
lists_statuses

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

Get subscribers of a specified list.
lists_memberships

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

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

Job compliance
network_data

Network data
next_cursor

Extract cursor (for cursor based pagination)
list_members

List of members from a specified List
list_membership

Lists a specified user is a member of.
parse_stream

Parser of stream
plain_tweets

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

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

Rate limit helpers
my_friendships

Lookup friendship information between users.
read_twitter_csv

Read comma separated value Twitter data.
post_destroy

post_list

Manage Twitter lists
post_message

Posts direct message from user's Twitter account
lat_lng

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

Favorites target status id.
links

Create the links
lists_members

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

Get user IDs for accounts following target user.
lookup_coords

Get coordinates of specified location.
list_tweets

Lists tweets of a specified list
lookup_tweets

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

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

Updates friendship notifications and retweet abilities.
post_follow

Follows target Twitter user.
rtweet_client

Client
rtweet_user

Authentication options
rules

Extract the streaming rules
round_time

A generic function for rounding date and time values
lookup_friendships

Lookup friendship information between two specified users.
search_fullarchive

Premium Twitter searches
trends_available

Available Twitter trends along with associated WOEID.
retrieve_errors

Expose errors of the response
ts_data

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

Posts status update to user's Twitter account
rtweet-deprecated

Deprecated functions in rtweet
rtweet-package

rtweet: Collect Twitter data from R
previous_cursor

Previous cursor
set_fields

Create fields
set_scopes

Scopes of the OAuth2 token
stopwordslangs

Defunct: Twitter stop words in multiple languages data.
tweet_quoted

Get quoted tweet information
ts_plot

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

Post a tweet
tweet_counts_recent

Count tweets
tweet_liking_users

Liking users
tweet_get

Get tweet information
stream_tweets

Collect a live stream of Twitter data
search_tweets

Get tweets data on statuses identified via search query.
search_users

Search for users
stream_tweets2

A more robust version of stream_tweets
tweet_retweeted_by

Tweet retweeted by
tweet_search_all

Search in the Twitter archive
user_liked_tweets

Liked tweets from a user
tweet_search_recent

Search recent tweets
user_list_follows

Lists a specified user follows
user_block

Blocking or unblocking twitter users
user_blocked

Find users blocked.
tweet_embed

Create a Tweet Embed
tweet_threading

Collect statuses contained in a thread
tweet_delete

Delete tweet
user_mentions

Tweets mentioning a user
user_tweets

Tweets from a user
user_lists

Search users by username
user_bookmarks

Retrieve user bookmarks
user_muted

List muted users
stream

Streaming
tweet_shot

Capture an image of a tweet/thread
user_by_username

Search users by username
user_followers

Find followers.
user_self

Tweets from a user
user_following

Find which users are being followed.
tweets_with_users

Parsing data into tweets/users data tibbles
write_as_csv

Save Twitter data as a comma separated value file.
users_data

Get tweets from users, or users from tweets
user_search

Search users
user_timeline

User timeline
auth_clean

Remove tokens
Expansions

Expansions
auth_as

Set default authentication for the current session
auth_save

Save an authentication mechanism for use in a future session
auth_get

Get the current authentication mechanism
Fields

Fields
as_screenname

Mark a user id as a screen name
auth_setup_default

Set up default authentication
auth_sitrep

Twitter Tokens sitrep
direct_messages

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

Clean clients
client_as

Set default client for the current session
bearer_token

Bearer token
TWIT_paginate_max_id

Pagination
client_has_default

Set up default client
client_save

Save an authentication mechanism for use in a future session
create_token

Create custom Twitter OAuth token
client_get

Get the current client
direct_messages_received

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