I am currently listening from certain users by using these rules:
'value': 'from:user1 OR from:user2 OR ...'
And as a result I get tweets, retweets and quotes of these users. But, I also need to stream all retweets that include tweets of these users, since I need their public metrics like retweet count, like count and etc.
Let me explain with an example: if one of users that is included in the the rules say, user1 tweets TWEET, I can listen it. But, when a user that is not included in the rules say, user3 retweets that TWEET of user1, I cannot listen it. But I need to, since I want to keep track of public metrics of TWEET posted by user1.
To achive this I modified rule like this:
'value': 'from:user1 OR #user1 OR from:user2 OR #user2...'
and it works fine.
However, is there a way to include short rule to achieve what I want for every user I include in streaming rules? Since currently I am listening more that 1.5k users, I might exhaust charachter limit of streaming rules.
P.S. I am using Python and Twarc.Client2 with Elevated Access to the API.
Thank you in advance.
Related
Per Twitter documentation A follow is:
https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters
A comma-separated list of user IDs, indicating the users whose Tweets
should be delivered on the stream. Following protected users is not
supported. For each user specified, the stream will contain:
1. Tweets created by the user.
2. Tweets which are retweeted by the user.
3. Replies to any Tweet created by the user.
4. Retweets of any Tweet created by the user.
5. Manual replies, created without pressing a reply button (e.g.
“#twitterapi I agree”).
....
......
1 and 2 are straight forward , to get them from Status JSON just do
status.getUser().getId()
for 3 , status.inReplyToUserId
for 4 , status.getRetweetedStatus().getUser().getId()
but how the heck do you get the last one ? Do those become mentions ?
I have a list of "n" Twitter ID representing users I would like to download.
To retrieve their user profile info, should I use n times the api call get_user or there exist a method to pass the entire list and retrieve all the info within one single api call, within the twitter rate time limit?
I tried something like
api.search_users(A)
api.search_users(id in A)
where A contains the list of id
but it does not work.
Anyone helping?
You can use the Twitter API resource https://dev.twitter.com/rest/reference/get/users/lookup. It can return user objects for at most 100 users at a time.
You can use this in Tweepy like:
user_objects = api.lookup_users(user_ids=list_of_at_most_100_user_ids)
Much of this answer first appeared as part of https://stackoverflow.com/a/42946854/1921546
I want to get all the 'retweets with comments' of a tweet.
Here are few things I noticed with twitter api
Retweets with comments are treated as tweets. The retweet count does not increase if you add a comment, also the twitter message is "XYZ quoted you instead retweeted you'
You clearly can't use this API endpoint https://dev.twitter.com/rest/reference/post/statuses/retweet/:id
Is there a way to find all the 'tweet/retweet with comment' if you can supply the original Tweet/Id?
So you're referring to Quoted Tweets (retweet with comments). There is no official method for that from the REST API yet, however, there are couple of ways to do it.
Since all quoted tweets contain the short url to the original one,
you can still use in_reply_to_status_id and filter by short url of the original tweet
Search for tweets that contain the field quoted_status_id this can be done either through REST or STREAMING API.
quoted_status_id: This field only surfaces when the Tweet is a quote Tweet. This field contains the integer value Tweet ID of the quoted Tweet.
This isn't easy to accomplish. Here's the brute-force API method to find Quote Tweets.
Take your tweet id, it'll be something like 750176081987014657.
GET search/tweets
Use the Twitter API and search for the tweet.
https://dev.twitter.com/rest/reference/get/search/tweets
The GET request will look something like this:
https://api.twitter.com/1.1/search/tweets.json?q=750176081987014657&count=100
The q "query" argument is the tweet id. I've set the result count argument to the maximum (100).
Authorization
Of course with the Twitter API there's a whole bunch of tricky Authorization header work you have to do as well in order to complete the GET request. That's documented elsewhere and is beyond the scope of this answer.
Results and Conclusion
When you have the JSON results of this GET request, focus on the statuses collection. For each tweet in the collection (otherwise known as a "status"), check if it contains a quoted_status_id field. If it does, and the field value matches your tweet id, the tweet is a quote tweet. If it does not, it is simply a retweet with no added comment. You will also have to deal with iterating through the pagination of results if there are more than 100. That's done by looking for a search_metadata.next_results field and retrieving the next GET query string from it, which will be provided for you.
For example, there are 884 channels under beauty and fashion, however, Youtube only shows about 50 of them. How do i get the complete list? Either through API or web.
https://www.youtube.com/channels/beauty_fashion
Thanks,
The first thing to do is to get the Guide Category ID that you're interested in. If you do a call to
https://www.googleapis.com/youtube/v3/guideCategories?part=snippet&hl=en®ionCode=US&key={YOUR_API_KEY}
where the hl parameter is the language and the regionCode is the country code (as some categories may not be available for particular languages/regions), you'll get a list of all the categories and their IDs.
For example, that call tells us that the Beauty and Fashion guide category ID is GCQmVhdXR5ICYgRmFzaGlvbg. With that ID, we can then do a channels list call:
https://www.googleapis.com/youtube/v3/channels?part=snippet&maxResults=50&categoryId=GCQmVhdXR5ICYgRmFzaGlvbg&key={YOUR_API_KEY}
This will give you 50 channels in that category. It will also give you a 'nextPageToken' ... you do the same request as above, but add "&pageToken={WHATEVER THAT NEXT PAGE TOKEN VALUE IS}" to get the next 50, and so on.
You can retrieve up to 500 that way ... that's the limit through the API.
Note that all of these calls require an API key from console.developers.google.com
Visit this site: http://www.channelcrawler.com/
You can list the channel in selected category and many other options.
Is there any api endpoint to retrieve the shares, favorites and retweets count about a link shared on twitter?
To get the comments, likes and shares count on fb I use the following endpoint:
https://api.facebook.com/method/links.getStats?urls=my_url
Is there any similar endpoint on twitter?
Right now I'm getting only the shared count with:
http://urls.api.twitter.com/1/urls/count.json?url=my_url
EDIT: this endpoint does not return the actual shared count, it's always 1.
Retweets: https://dev.twitter.com/rest/reference/get/statuses/retweets/%3Aid
Shares: Aren´t "Retweets" actually shares?
Favorites: I am not sure if it´s possible, there is no endpoint afaik
You can also use a platform like sharedcount though, a lot easier to handle and you get all the counts in one call - for all relevant platforms. That would be the best solution if you only want to get counts.
Take a look at the "Sources" section of their old docs to see how sharedcount gets the counts: http://www.sharedcount.com/documentation.php
Twitter: http://urls.api.twitter.com/1/urls/count.jsonurl=%%URL%%&callback=twttr.receiveCount