mobcdi
mobcdi

Reputation: 1592

twitteR r package: How to get as many tweets as possible per account within API limits

I'm a novice R and twitteR package user but I wasn't able to find a strong recommendation on how to accomplish the following.

I'd like to mine a small number of twitter accounts to identify their output for keyword usage. (i.e. I don't know what the keywords are yet)

Assumptions:

  1. I have a small number of tweeter accounts (<6) I want to mine with a max of 7000 tweets if you aggregate the various account statuses
  2. Those accounts are not generating new tweets at a fast rate (a few a day)
  3. The accounts all have less than 3200 tweets according to the profile data returned by lookupUsers()

When I use the twitteR function userTimeline("accountname", n=3200) I get between 40 and 600 observations returned i.e no where near the 3200. I know there are API limits but if it was an issue of limits I would expect to get the same number of observations back or get the notice that I need to wait 15 mins

How do I get all the text I need while still playing nice ?

Upvotes: 2

Views: 5462

Answers (2)

Adam_G
Adam_G

Reputation: 7879

This can be accomplished with rtweet package, which is still supported. First you need to be approved as a developer and create an app. (As a note, twitter has now changed their policies, and approval can take a while. It took me almost a week.)

After that, just use get_timeline() to get all of the tweets from a timeline, up to 3200.

djt <- get_timeline("adamgreatkind", n = 3200)

Upvotes: 0

mobcdi
mobcdi

Reputation: 1592

By using a combination of cran and github packages it was possible to get all the tweets for a user

The packages used were streamR available in cran and https://github.com/SMAPPNYU/smappR/ to help with the analysis and getting the tweets.

The basic steps are

  1. Authenticate to twitter using oauth and your twitter keys, tokens and secrets
  2. use smappR function getTimeline() which saves the tweets to a json file you specify
  3. Use parseTweets(jsonfile) to read the json contents into a dataframe

Upvotes: 4

Related Questions