search_fullarchive: Premium twitter searches

Description Usage Arguments Value Developer Account Search operators Keyword Accounts of interest Tweet attributes Geospatial References Examples

View source: R/premium.R

Description

Search 30day or fullarchive products

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
search_fullarchive(
  q,
  n = 100,
  fromDate = NULL,
  toDate = NULL,
  env_name = NULL,
  safedir = NULL,
  parse = TRUE,
  token = NULL
)

search_30day(
  q,
  n = 100,
  fromDate = NULL,
  toDate = NULL,
  env_name = NULL,
  safedir = NULL,
  parse = TRUE,
  token = NULL
)

Arguments

q

Search query on which to match/filter tweets. See details for information about available search operators.

n

Desired number of results to return. Results are downloaded in pages when n is large; the default value will download a single page. Set n = 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 request n = 150 and the page size is 200, you'll get 200 results back.

fromDate

Oldest date-time (YYYYMMDDHHMM) from which tweets should be searched for.

toDate

Newest date-time (YYYYMMDDHHMM) from which tweets should be searched for.

env_name

Name/label of developer environment to use for the search.

safedir

Name of directory to which each response object should be saved. If the directory doesn't exist, it will be created. If NULL (the default) then a dir will be created in the current working directory. To override/deactivate safedir set this to FALSE.

parse

If TRUE, the default, returns a tidy data frame. Use FALSE to return the "raw" list corresponding to the JSON returned from the Twitter API.

token

Expert use only. Use this to override authentication for a single API call. In most cases you are better off changing the default for all calls. See auth_as() for details.

Value

A tibble data frame of Twitter data

Developer Account

Users must have an approved developer account and an active/labeled environment to access Twitter's premium APIs. For more information, to check your current Subscriptions and Dev Environments, or to apply for a developer account visit https://developer.twitter.com.

Search operators

Note: Bolded operators ending with a colon should be immediately followed by a word or quoted phrase (if appropriate)–e.g., lang:en

Keyword

Accounts of interest

Tweet attributes

Geospatial

References

https://developer.twitter.com/en/docs/twitter-api/premium/search-api/api-reference/premium-search

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
## search fullarchive for up to 300 rstats tweets sent in Jan 2014
rt <- search_fullarchive("#rstats", n = 300, env_name = "research",
  fromDate = "201401010000", toDate = "201401312359")

toDate <- format(Sys.time() - 60 * 60 * 24 * 7, "%Y%m%d%H%M")

## search 30day for up to 300 rstats tweets sent before the last week
rt <- search_30day("#rstats", n = 300,
  env_name = "research", toDate = toDate)

## End(Not run)

mkearney/rtweet documentation built on Sept. 29, 2021, 12:01 p.m.