I have a problem with twitter API. I tweeted in the past (around 400) but recently I haven't tweeted anything. When I try to fetch tweets by me using the twitter api, there are no results. How can I retrieve the older tweets?
5 Answers
Twitter doesn't return tweets older than a week through search api. Take a look at the limitations section from the below link:

- 7,800
- 4
- 35
- 62
-
1There isn't any free solution, but you can retrieve tweets up to 2 years back using twitter partners such as data-sift. You can take a look at their web-site. http://datasift.com/ – cubbuk Jan 07 '13 at 13:19
-
2-1 That limit applies to the Twitter Search API, not the Twitter API. – Bennett McElwee May 26 '13 at 10:45
-
But to retrieve older tweets you have to use Search API, or is there any other way to retrieve older tweets that I am not aware of? – cubbuk May 28 '13 at 06:47
-
is there a way to search by a particular hashtag to get tweets longer than 7 days old? – Metin Dagcilar Mar 31 '17 at 12:38
I have the same problem as you, so after see that Twitter Web Search works I've started to implement my own solution, you can see on my GitHub. It is implemented in Java, but it will make a post on my blog to explain how to do in other languages. I've downloaded tweets without any problems, my last test I parse more than 600k within 2014 from some specific users.

- 968
- 7
- 11
-
Could you share link to you blog with this post, please? I'd like to do it in Python. – Simplex Jul 09 '15 at 14:00
-
Hello, I did it in python, take a look: https://github.com/Jefferson-Henrique/GetOldTweets-python – Jefferson Henrique C. Soares Jan 29 '16 at 06:01
-
-
I ask because I tried your command line implementation from the Readme, copied/pasted exact, and it just yells at me to provide arguments. – Jibril Apr 12 '16 at 08:41
-
Actually, I got your Java implementation working. The Python one just hates me for some reason. Is there a way to modify this to instead of including just M/D/Y, get Month/Day/Year Hour:Minute:Second time stamps? – Jibril Apr 12 '16 at 15:18
-
Hi @Jibril, it is possible, you can change the exporter.java and modifiy the date formatter. – Jefferson Henrique C. Soares Aug 26 '16 at 19:57
You can use the REST API resource GET statuses/user_timeline to retrieve the most recent 3200 tweets from any public timeline.

- 6,987
- 24
- 106
- 158

- 24,740
- 6
- 54
- 63
-
this is good to know, but not a solution if you're searching for all tweets with a certain hashtag – Flion Feb 11 '16 at 19:01
-
1
-
Is there a way to get older tweets with a certain search criteria? For example, any tweets mentioning a certain @user? – Jibril Apr 12 '16 at 08:29
-
using GET statuses/user_timeline you can get tweets posted by user only. – bittu Dec 07 '16 at 07:44
-
-
@BennettMcElwee is there a way to search twitters API for a specific hashtag for longer than the past 7 days? – Metin Dagcilar Mar 31 '17 at 12:37
-
@AVERAGE The answer to your question lies in the [Twitter API Reference Documentation](https://dev.twitter.com/rest/reference). – Bennett McElwee Apr 03 '17 at 21:30
This is possible in Twitter web search portal but not through their API. Bummer https://twitter.com/search-home

- 21
- 1
- 2
This elaborates on @bennett-mcelwee 's answer where getting up to 3200 most recent user tweets can be done in series of API calls. Currently the max # of tweets you can get by a user in 1 request is 200, using the GET statuses/user_timeline
API call. To get all tweets a user has posted on their timeline do the following:
STEP 1
Make a GET call to this endpoint passing parameter count=200
.
STEP 2
From the returned data in step 1, get the ID of the last tweet
Make the same GET call but this time pass in parameter max_id=
followed by the ID of last tweet returned form the first call, or -1
. So for example max_id=9987999
STEP 3
Repeat step 2 until you don't get any new(older) data.
For my purpose I was able to do this in Ruby using https://github.com/sferik/twitter
Once a client object is instantiated, it's as simple as:
tweets = client.user_timeline('foobar', count: 200)
max_id = tweets.last.id - 1
tweets << client.user_timeline('foobar', count: 200, max_id: max_id)
From here you get idea and it's fairly trivial to write a loop until you've gotten all the tweets you can grab from the API.

- 1,138
- 11
- 24

- 10,623
- 4
- 31
- 48