Search Twitter's '30day' (PREMIUM) API

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



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


Number of tweets to return; it is best to set this number in intervals of 100 for the '30day' API and either 100 (for sandbox) or 500 (for paid) for the 'fullarchive' API. Default is 100.


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


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


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


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.


Logical indicating whether to convert data into data frame.


A token associated with a user-created APP (requires a developer account), which is converted to a bearer token in order to make premium API requests


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


if (FALSE) { ## format datetime for one week ago 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) }