I'm trying to get the number of tweets a user has ever liked in NodeJs using twitter-api-v2, but I can't seem to find the solution. I tried to use the "public_metrics" property but it looks like it only contains the following properties:
followers count
following count
tweet count
listed count
I also tried to use the client.v2.userLikedTweets() method but it can only go up to 100 likes, I know I could upgrade to a premium account but I don't want to
Is there a solution? Thanks.
If you have an elevated access, you can use the favourites_count field in the User objects from the Twitter API V1. But there is unfortunately no way to do so with the Twitter API V2.
Related
I want to create giveaways which require the participants to follow the twitter account of the giveaway creator.
My first idea was to use the Twitter API (endpoint: "/2/users/:id/followers"). This works fine for me however I always run into rating limits. The API allows me to send 15 requests every 15 minutes and returns a maximum of 1000 users per request. Since many accounts have more then 15000 followers and since many request happen at the same time (many users want to participate in a giveaway) this solution is not suitable for me.
My secound idea was to use web scraping instead (e.g Node Fetch). I was following along this tutoria: However doing so I always run into the issue that Twitter uses random strings to name their html elements. You can see in the picture there is no defined class to grap the elements.
So my main question is how can I access these element ?
Random Follower of my Twitter Account
I also have a follow up question regarding the effictivness of this method. Assuming I have multiple people who want to particpate in a short amount of time (e.g 10 people in 5 minutes) and they all need to follow a big twitter account (e.g 100k followers).
Is it efficent to scrape all 100k followers each time or should I instead try to fetch the 100k followers once, safe them to my database and use my database to check for each user later ?
As a side note, I am using node.js and node-fetch, however I have no problems to switch the framework. In addition I think the grabbing of the element as well as the performance should be universal.
Thanks for your help :)
They're going to detect your servers excessive calls. There is a Twitter Developer Portal where you can request elevated access which may raise the limits for you.
https://developer.twitter.com
I'm new to Python and need some help. I'm trying to search for historical tweets from 2014 to 2018 from specific Twitter users with specific keywords in a research project and have a few questions for my code.
I can't find a code on how to get the output as a number of tweets instead of a long list of many tweets. Is this possible?
Does anyone know how to connect the endpoint from Twitter Developer to the code? I will use a Premium API account.
I'm getting an Error on the code because of the functions: from and filter, is there a way to fix this? I tried to insert it in the same " " as the query, but that didn't work.
#Endpoint from Twitter Developer
endpoint = 'https://api.twitter.com/1.1/tweets/search/30day/dev.json'
#All keywords
query = 'xxxx' or 'yyyy'
#Search code
search = tweepy.Cursor(api.search, q = query, "from:TwitterUser -filter:retweets", lang = 'en').items()
for item in search:
print (item.text)
And as an additional question not related to my code, is it possible to search for retweets and likes by specific users on certain tweets? Lets say I'm searching for tweets from user1, can I then see how many times user2, user3 and user4 have retweeted and liked user1's tweets?
Thanks for any help!
Cheers
I don't believe that tweepy currently provides support for the premium search endpoints (additionally, I see that your code is hitting a 30 day endpoint, when for your use case you would need to access the full archive search endpoint).
For premium search I would recommend that you look at either TwitterAPI, or the search-tweets-python library that we (Twitter) provide. In the case of the latter, it also supports the counts endpoint, but be aware that these are only available in the paid tier, not the free sandbox. Also, note that the search syntax on the premium search API is different to standard search. Check the documentation.
On your last question unrelated to code - no, there's no API that would enable you to find that information.
I am using node.js(Meteor) for calling Amazon MWS ListMatchingProducts API for getting all products of my seller account . Its running sucessfully and i am getting the response , but as the documentation said that only ten(10) products are returned at one time. So i just want to know how we get products more than 10 . In the doc Amazon also said that you can submit NextToken with a "ByNextToken" operation to request additional pages.But i am not getting any nextToken or related to that nextToken field on my response.So how do i get the nextToken from there side or how can i get more than 10 products from that API. As i also check on one post they said that we need to use Reports for that but i want to use ListMatchingProducts API for that and want result more than 10.
Please provide me any suggestion or guidance how can i achieve that.
Any help would be appriciated
Thanks
You want to call the Reports API using the Inventory Report report type or one of the other Listing Report types. That is the way to go. The ListMatchingProductsoperation of the Products API is meant to be a search, based on a query. Yes, it only lists ten products but it does not give you a NextToken like some of the other operations. Knowing your Report Type and Marketplace ID, you can submit those to the Reports API with your credentials and get back all of your products all at once and there is no searching involved.
What I would also suggest is to use the Amazon Scratchpad to play around with your operations to make sure you get what you expect, then plug it into your node.js project.
I am trying to fetch the instagram feeds to my site using tag name.
https://api.instagram.com/v1/tags/{tag-name}?access_token=ACCESS-TOKEN
above is the api which I am using to get the feeds.
Now the feeds are displaying from all the users who use the tag. I need to restrict the feeds for the particular user who use the tag name.
Anyone come across this?
Thanks,
The current version of the Instagram Api does not have an endpoint that will allow you to get media by tag-name AND user-id. Your best bet is to use 1 of the following endpoints, and then loop through the results and filter out the media that matches the 2nd condition.
Search for posts by given hashtag's name using GET /tags/{tag-name}/media/recent API endpoint request and then filter the response list of media to match the user-id for the particular user in question.
or
Search for posts by the particular user using GET /users/{user-id}/media/recent API endpoint request and then manually check every post if its tags array contains the specific hashtag you are looking for.
I recommend you go with option 2 as that will be faster, since an individual user feed is a much smaller data set than media from 1000s of Instagram users tagged with a hashtag.
I've searched through the topics but it seems that exactly this questions hadn't been asked yet.
Could anyone, please, share their opinion on how to retrieve an Instagram account followers' posts locations in order to map them after that on one map?
On the account there are around 2000-2100 followers.
Thank you in advance!
To get detailed user information from instagram you have to use the GET /users/user-id endpoint.
So to get the location information for all an accounts followers you have to use
GET/users/user-id/followed-by and iterate through the results.
Be careful. Instagram api limit is currently 5000 requests per hour. Accounts with more followers than that you will have to use some form of queue
Edit: just seen you want the post locations:
Similar method, excite instead of GET /users/user-id user GET /users/user-id/recent and grab the locations of the media. Note in my experience the location function is used very little by instagram users. I once pulled 3000 media that had only 20 media with a location
You cannot just location of a user using APIs, there are couple ways you can guess the location, by looking for bio information and check if they have any location specified or you can check location of all the photos posted by a user and kind of guess the location by analyzing where most of the photos are being posted at.
you can use the API /users/user-id/recent to get all the photos from a user and look for location property in API response and map it on google map.
you can use http://gramfeed.com to see user photos with a map of photo locations, you will have to do this for each user and determine the location.