I want to get the tweets of an user in a time interval, for example a user's tweets between a 6 months period. I can get all the tweets of a user with getUserTimeline functionality but it seems like it doesn't give me any option about any date interval.
I need something like since and until parameters which is provided by Query class of Twitter4j. I would use that class but it only support searching for keywords. Is there a way to accomplish this?
Thanks in advance.
I don't believe twitter itself provides any date/time related options for getting tweets (aka user timeline statuses).
If you can extract the tweet ID for the last tweet in that 6 month window, you can set that as max_id and then iterate backwards by setting the lowest tweet ID as max_id till you hit the start of the 6 month window.
The current version does not have any provision to get the tweets between a specific time interval using date and time with getUserTimeline functionality.
It can be done using since_id and max_id only AFAIK.
User TimeLine
Search tweets
Related
I want to get all tweets from my country.I tried to get all tweet by using Standart api search method. But it has some rule and limit. I want to do it limitless. Which api method can i use?
If you'd like to get all tweets for the past 7 days you could easily do it with standard API with a geocode cursor search for your country (if you specify language would be better). It will take some time as it will wait 15 minutes everytime it reaches the request limit for 15 min window. You could easily get a million tweets if you run it for 3 - 4 days.
If you need tweets more than 7 days ago you will need premium api but I wouldn't recommend it.
First of all, it is extremely expensive and second, it has a monthly limit of requests. (i am not sure how many but I reckon something about 500). Which means it will actually take you longer than waiting for the 15min rate limit every time.
Use the Premium search API :
https://developer.twitter.com/en/docs/tweets/search/api-reference/premium-search.html
You will be able to search for all tweets since 2006... it may be a lot.
The "query" parameters are listed here : https://developer.twitter.com/en/docs/tweets/search/overview/premium#AvailableOperators so you can filter by lang or with geospatial operators.
For example how could search for tweets using the #oldtweets sent on 5-29-16, from 8pm to 9pm.
According to the The Twitter Search API documentation, the query you want is not possible: https://dev.twitter.com/rest/public/search
The Twitter Search API searches against a sampling of recent Tweets
published in the past 7 days.
Beyond the last 7 days, what you want to achieve can only be done through manually searching an account on Twitter.
Another alternative would be to use https://webrecorder.io/
Scroll to the timeframe you want to record or you can attempt to capture the entire feed. Note the auto scrolling option as well.
Since the "since" param is no longer in use, how can I search tweets older than specific date ? I understand how to use since_id, but in my case I don't have any historic tweet to take the tweet_id from. How is search by date done these days ?
It's an old question, but since it has no answer i share what i have found regarding this question by reading the docs and using the API.
Since and until params are only for maximum 9 past days.
Instead we can use since_id and max_id. You have to set them to unique ids of tweets. You can find one tweet in the specified time (from any user you want). Detect the id by using the API or simply by Developer tools of your browser.
You can use the until param:
Returns tweets generated before the given date. Date should be
formatted as YYYY-MM-DD. Keep in mind that the search index may not go
back as far as the date you specify here.
Hi all
I am new to twitter API.. So my question may be a trivial one..
I am developing a new twitter widget, in which I want to get the first tweet for a given hashtag on a particular date.
say first tweet for #xyz hashtag tweeted on 12-08-10.
so far through googling and api doc I found rpp * page max = 1500.. if totaltweet for a given day is 2000 how can I retrieve last 500 tweets..
I have a few questions?
1. Is this for any hashtag that a user might request on the fly, or a set of hashtags that generally remain the same?
If it is a set of tags that stays the same for a while, roughly how many tags are there?
When you say a particular date, how far back in time are you going?
There are two standard ways to get tweets for a hashtag. You can use search, which goes back around 7 days or 1,500 tweets. For an active tag, that may only be a day or two. You can use the streaming API, but that doesn't go back, it just starts tracking from the moment you start making the request. The streaming API can track up to 400 hashtags without getting approval for a higher rate. The search API is limited to 10 to 20 hashtags per query.
If you answer questions 1-3, I can suggest a path to getting what you want.
is there a way to get tweets from some specific user and since some time of period?
I see that statuses/user_timeline has the screen_name param which I can search for specific user's tweets but can't filter these tweets by date created.
so if I want to get this user's past 1 week tweets what are some ways to do it?
Your only option is to use GET statues/user_timeline and page backwards in time until you either run out of results or get back statuses that are older then the time range of interest.