Git Product home page Git Product logo

rtweet's Introduction

rtweet

R-CMD-check CRAN status Coverage Status Downloads ZENODO rOpenSci JOSS

Use twitter from R. Get started by reading vignette("rtweet").

Installation

To get the current released version from CRAN:

install.packages("rtweet")

Usage

All users must be authenticated to interact with Twitter’s APIs. The easiest way to authenticate is to use your personal twitter account - this will happen automatically (via a browser popup) the first time you use an rtweet function. See auth_setup_default() for details. Using your personal account is fine for casual use, but if you are trying to collect a lot of data it’s a good idea to authentication with your own Twitter “app”. See vignette("auth", package = "rtweet") for details.

library(rtweet)

{{rtweet}} should be used in strict accordance with Twitter’s developer terms.

Search tweets or users

Search for up to 10,000 tweets containing #rstats, excluding retweets:

rt <- search_tweets("#rstats", n = 10000, include_rts = FALSE)

Twitter rate limits cap the number of search results returned to 18,000 every 15 minutes. To request more than that, set retryonratelimit = TRUE and rtweet will wait for rate limit resets for you.

Search for 1,000 users with the #rstats in their profile:

usrs <- search_users("#rstats", n = 1000)

Stream tweets

Randomly sample (approximately 1%) from the live stream of all tweets:

rt <- stream_tweets("")

Stream all geo-located tweets from London for 60 seconds:

rt <- stream_tweets(lookup_coords("london, uk"), timeout = 60)

Get friends and followers

Get all accounts followed by a user:

## get user IDs of accounts followed by CNN
cnn_fds <- get_friends("cnn")

## lookup data on those accounts
cnn_fds_data <- lookup_users(cnn_fds$user_id)

Get all accounts following a user:

## get user IDs of accounts following CNN
cnn_flw <- get_followers("cnn", n = 10000)
cnn_flw_data <- lookup_users(cnn_flw$user_id)

If you want all followers, you’ll need you’ll need to set n = Inf and retryonratelimit = TRUE but be warned that this might take a long time.

Get timelines

Get the most recent 3,200 tweets from CNN, BBC World, and Fox News:

## get user IDs of accounts followed by CNN
tmls <- get_timelines(c("cnn", "BBCWorld", "foxnews"), n = 3200)

Get favorites

Get the 3,000 most recently favorited statuses by Justin Bieber:

jkr <- get_favorites("justinbieber", n = 3000)

Contact

Communicating with Twitter’s APIs relies on an internet connection, which can sometimes be inconsistent. With that said, if you encounter an obvious bug for which there is not already an active issue, please create a new issue with all code used (preferably a reproducible example) on Github.

Code of Conduct

Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

rtweet's People

Contributors

mkearney avatar hadley avatar llrs avatar hrbrmstr avatar thomas-keller avatar tylermorganwall avatar kevintaylor avatar simonheb avatar dieghernan avatar giocomai avatar mikechapple avatar engineerchange avatar maelle avatar jeroen avatar bdilday avatar alexpghayes avatar xvrdm avatar tylerlittlefield avatar tbuckl avatar suppaman avatar mine-cetinkaya-rundel avatar charliejhadley avatar malcolmbarrett avatar kwazao avatar kohlkopf avatar jonthegeek avatar jdblischak avatar jennybc avatar jsta avatar enchufa2 avatar

Stargazers

 avatar Pflegende Angehörige avatar Brendan J. Kelly, MD, MS avatar Shubharup Ganguly  avatar Aaron avatar  avatar Brian Ataka  avatar Kestutis Vinciunas avatar Selja SeppÀlÀ avatar Nakatai avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.