'Get view count from Twitter in R [closed]
I'm using the rtweet package in R to access Twitter data. While the package provides a lot of information (incl. retweet count, favorite count etc.), one function that I can't seem to find is to retrieve how many views a tweet generated.
Realizing that this may be a long shot - has anyone found a different R package or a way to retrieve the view count?
Thanks, Philipp
Solution 1:[1]
This is what Twitter calls a "private metric", so it is only possible to get the views of your own tweets.
Any (serious) twitter package would use Twitter's API behind the scenes. If you look at the Twitter API documentation for GET tweets, we see that the response includes several impression_count metrics (i.e. view count), but only if you're authenticated. I'm guessing the non_public_metrics.impression_count would be the most interesting for you, from the docs it's stated that:
Number of times the Tweet has been viewed. This is a private metric, and requires the use of OAuth 1.0a or OAuth 2.0 User Context authentication.
If you're only interested in views from your own Tweets, then you should look into how to authenticate using any of the Twitter packages. If that is not possible you could always do your own API calls with the httpr package.
If you want the view count of other people's tweets, you're in bad luck unfortunately.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jpiversen |
