'Twitter API Javascript: How to count total number of likes and retweets a user has? If impossible due to rate limiting how else to measure engagement?
I'm trying to utilize Twitter API v2 in a javascript file to count how the average number of likes and retweets a user has per tweet. For example, if a user has 3 tweets, one has 5 likes, one has 6 likes, and one has 0 likes, I'd want a function to be able to return the average number of likes (3.67).
I'm finding the total number of tweets utilizing the following endpoint by extracting the status count from the object.
https://api.twitter.com/1.1/users/show.json?screen_name=${username}
How would I go about counting how many total likes a user has across their tweets? How would I go about counting the total number of times a user's tweets have been retweeted?
The closest thing I've found is the user tweet timeline endpoint, however it doesn't return how many likes and retweets each tweet in the timeline has.
https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-tweets
I've considered looping through each tweet id in the timeline and calling the following endpoint to get the likes for each tweet, and then sum them. However, there's a rate limit of 50 calls per 15 minutes on this endpoint.
Is there any way to get the average number of likes and retweets a user has?
If not, would you have any suggestions of how else I could use the Twitter API to measure how much engagement a Twitter account has? I'm currently tracking number of followers and number of tweets, but I'd like to track engagement in other ways.
Thank you so much!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
