search_fullarchive: Premium Twitter searches

View source: R/premium.R

search_fullarchiveR Documentation

Premium Twitter searches


Search 30day or fullarchive premium products. There is a limit of 5000 tweets and 25000 for the fullarchive and 30day endpoints respectively. In addition, there are some limits in the number of requests that are possible on a certain amount of time, this have already been taken into account. See the info provided by Twitter.


  n = 100,
  fromDate = NULL,
  toDate = NULL,
  continue = NULL,
  env_name = NULL,
  premium = FALSE,
  safedir = NULL,
  parse = TRUE,
  token = NULL

  n = 100,
  fromDate = NULL,
  toDate = NULL,
  env_name = NULL,
  continue = NULL,
  premium = FALSE,
  safedir = NULL,
  parse = TRUE,
  token = NULL



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


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.


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


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


A character string with the next results of a query. You must make the exact same query as the original, including q, toDate, and fromDate.


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


A logical value if the environment is paid (TRUE) or sandboxed, the default (FALSE). It limits the number of results retrieved so the number of API queries needed to retrieve n results.


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.


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.


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.


Note: The env_name must match the ones you set up for the token you are using.


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

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


  • "" ~~ match exact phrase

  • # ~~ hashtag

  • @ ~~ at mentions)

  • url: ~~ found in URL

  • lang: ~~ language of tweet

Accounts of interest

  • from: ~~ authored by

  • to: ~~ sent to

  • retweets_of: ~~ retweet author

Tweet attributes

  • is:retweet ~~ only retweets

  • has:mentions ~~ uses mention(s)

  • has:hashtags ~~ uses hashtags(s)

  • has:media ~~ includes media(s)

  • has:videos ~~ includes video(s)

  • has:images ~~ includes image(s)

  • has:links ~~ includes URL(s)

  • is:verified ~~ from verified accounts


  • bounding_box:[west_long south_lat east_long north_lat] ~~ lat/long coordinates box

  • point_radius:[lon lat radius] ~~ center of search radius

  • has:geo ~~ uses geotagging

  • place: ~~ by place

  • place_country: ~~ by country

  • has:profile_geo ~~ geo associated with profile

  • profile_country: ~~ country associated with profile

  • profile_region: ~~ region associated with profile

  • profile_locality: ~~ locality associated with profile


Endpoint: Full archive limits 30day limits


## Not run: 
## search fullarchive for up to 300 rstats tweets sent in Jan 2014
rt <- search_fullarchive("#rstats", n = 300, env_name = "SetYourLabel",
  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 = "SetYourLabel", toDate = toDate)

## End(Not run)

rtweet documentation built on July 21, 2022, 5:10 p.m.