6

Is there a way that I can get US election-related tweets from October 15 to Nov 15 from various countries.

Can anyone tell how to use the Twitter API to get data older than a month? Alternatively, does any one know of sources where I can get this data which includes tweet content, location, date, time etc.? Any sort of help much appreciated.

1
  • 1
    You can get old twitter content with the API if you know the tweet or user ID. Otherwise, you can search up to ~7 days previous.
    – philshem
    Commented Dec 3, 2016 at 18:56

1 Answer 1

1

Some researchers have published:

2016 United States Presidential Election Tweet Ids dataset

... the SFM team is sharing the tweet id of every single tweet that we collected around the election – all 280 million of them. The tweets are broken up into 12 collections:

Candidates and key election hashtags (Twitter filter)

Democratic candidates (Twitter user timeline)

Democratic Convention (Twitter filter)

Democratic Party (Twitter user timeline)

Election Day (Twitter filter)

First presidential debate (Twitter filter)

GOP Convention (Twitter filter)

Republican candidates (Twitter user timeline)

Republican Party (Twitter user timeline)

Second presidential debate (Twitter filter)

Third presidential debate (Twitter filter)

Vice Presidential debate (Twitter filter)

Link to data


Twitter's terms of service state that you can't share the tweet content, and only the tweet id. This is to allow users to delete the content, and keep the right to be forgotten.

When you have a list of tweet ids, you can retrieve the tweet content, assuming it hasn't been deleted.

The Twitter API endpoint to retrieve a tweet based on its id is here: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id.html

or up to 100 tweet ids at a time: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-lookup


There are tons of programming libraries to access the API - pick your favorite (Python, R, etc) and search for the best.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.