
Get direct messages sent to and received by the authenticating user from the past 30 days
Source:R/direct_messages.R
direct_messages.Rd
Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order. Includes detailed information about the sender and recipient.
Usage
direct_messages(
n = 50,
cursor = NULL,
next_cursor = NULL,
parse = TRUE,
token = NULL,
retryonratelimit = NULL,
verbose = TRUE
)
Arguments
- n
Desired number of results to return. Results are downloaded in pages when
n
is large; the default value will download a single page. Setn = Inf
to download as many results as possible.The Twitter API rate limits the number of requests you can perform in each 15 minute period. The easiest way to download more than that is to use
retryonratelimit = TRUE
.You are not guaranteed to get exactly
n
results back. You will get fewer results when tweets have been deleted or if you hit a rate limit. You will get more results if you ask for a number of tweets that's not a multiple of page size, e.g. if you requestn = 150
and the page size is 200, you'll get 200 results back.- cursor
Which page of results to return. The default will return the first page; you can supply the result from a previous call to continue pagination from where it left off.
- next_cursor
- parse
If
TRUE
, the default, returns a tidy data frame. UseFALSE
to return the "raw" list corresponding to the JSON returned from the Twitter API.- token
Use this to override authentication for a single API call. In many cases you are better off changing the default for all calls. See
auth_as()
for details.- retryonratelimit
If
TRUE
, and a rate limit is exhausted, will wait until it refreshes. Most Twitter rate limits refresh every 15 minutes. IfFALSE
, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. The default value,NULL
, consults the optionrtweet.retryonratelimit
so that you can globally set it toTRUE
, if desired.If you expect a query to take hours or days to perform, you should not rely solely on
retryonratelimit
because it does not handle other common failure modes like temporarily losing your internet connection.- verbose
Show progress bars and other messages indicating current progress?
Examples
if (FALSE) {
## get my direct messages
dms <- direct_messages()
## inspect data structure
str(dms)
}