- q
Query to be searched, used to filter and select tweets to
return from Twitter's REST API. Must be a character string not to
exceed maximum of 500 characters. Spaces behave like boolean
"AND" operator. To search for tweets containing at least one of
multiple possible terms, separate each search term with spaces
and "OR" (in caps). For example, the search q =
"data science"
looks for tweets containing both "data" and
"science" located anywhere in the tweets and in any order.
When "OR" is entered between search terms, query =
"data OR science"
, Twitter's REST API should return any tweet
that contains either "data" or "science." It is also possible to
search for exact phrases using double quotes. To do this, either
wrap single quotes around a search query using double quotes,
e.g., q = '"data science"'
or escape each internal double
quote with a single backslash, e.g., q =
"\"data science\""
.
Some other useful query tips:
Exclude retweets via "-filter:retweets"
Exclude quotes via "-filter:quote"
Exclude replies via "-filter:replies"
Filter (return only) verified via "filter:verified"
Exclude verified via "-filter:verified"
Get everything (firehose for free) via "-filter:verified OR filter:verified"
Filter (return only) tweets with links to news articles via "filter:news"
Filter (return only) tweets with media "filter:media"
- n
Integer, specifying the total number of desired tweets to
return. Defaults to 100. Maximum number of tweets returned from a
single token is 18,000. To return more than 18,000 tweets, users
are encouraged to set retryonratelimit
to TRUE. See
details for more information.
- type
Character string specifying which type of search
results to return from Twitter's REST API. The current default is
type = "recent"
, other valid types include type =
"mixed"
and type = "popular"
.
- include_rts
Logical, indicating whether to include retweets
in search results. Retweets are classified as any tweet generated
by Twitter's built-in "retweet" (recycle arrows) function. These
are distinct from quotes (retweets with additional text provided
from sender) or manual retweets (old school method of manually
entering "RT" into the text of one's tweets).
- geocode
Geographical limiter of the template
"latitude,longitude,radius" e.g., geocode =
"37.78,-122.40,1mi"
.
- max_id
Character, returns results with an ID less
than (that is, older than) or equal to `max_id`. Especially
useful for large data returns that require multiple iterations
interrupted by user time constraints. For searches exceeding
18,000 tweets, users are encouraged to take advantage of rtweet's
internal automation procedures for waiting on rate limits by
setting retryonratelimit
argument to TRUE. It some cases,
it is possible that due to processing time and rate limits,
retrieving several million tweets can take several hours or even
multiple days. In these cases, it would likely be useful to
leverage retryonratelimit
for sets of tweets and
max_id
to allow results to continue where previous efforts
left off.
- parse
Logical, indicating whether to return parsed
data.frame, if true, or nested list, if false. By default,
parse = TRUE
saves users from the wreck of time and
frustration associated with disentangling the nasty nested list
returned from Twitter's API. As Twitter's APIs are subject to
change, this argument would be especially useful when changes to
Twitter's APIs affect performance of internal parsers. Setting
parse = FALSE
also ensures the maximum amount of possible
information is returned. By default, the rtweet parse process
returns nearly all bits of information returned from
Twitter. However, users may occasionally encounter new or
omitted variables. In these rare cases, the nested list object
will be the only way to access these variables.
- token
Every user should have their own Oauth (Twitter API) token. By
default token = NULL
this function looks for the path to a saved
Twitter token via environment variables (which is what `create_token()`
sets up by default during initial token creation). For instruction on how
to create a Twitter token see the tokens vignette, i.e.,
`vignettes("auth", "rtweet")` or see ?tokens
.
- retryonratelimit
Logical indicating whether to wait and
retry when rate limited. This argument is only relevant if the
desired return (n) exceeds the remaining limit of available
requests (assuming no other searches have been conducted in the
past 15 minutes, this limit is 18,000 tweets). Defaults to false.
Set to TRUE to automate process of conducting big searches (i.e.,
n > 18000). For many search queries, esp. specific or specialized
searches, there won't be more than 18,000 tweets to return. But
for broad, generic, or popular topics, the total number of tweets
within the REST window of time (7-10 days) can easily reach the
millions.
- verbose
Logical, indicating whether or not to include output
processing/retrieval messages. Defaults to TRUE. For larger
searches, messages include rough estimates for time remaining
between searches. It should be noted, however, that these time
estimates only describe the amount of time between searches and
not the total time remaining. For large searches conducted with
retryonratelimit
set to TRUE, the estimated retrieval time
can be estimated by dividing the number of requested tweets by
18,000 and then multiplying the quotient by 15 (token reset
time, in minutes).
- ...
Further arguments passed as query parameters in request
sent to Twitter's REST API. To return only English language
tweets, for example, use lang = "en"
. For more options see
Twitter's API documentation.