Elections DATA ACCESS SERVICES Toolkit
1
why monitor
social media
Effects of Manipulation Manipulation Around the Clock How Manipulators Work What Research Can be Done
2
getting started in
your own context
3
build your own
methodology
4
how you can
access data
5
Tools and
Techniques
6
make an
impact

Twitter

How can you access data?

Twitter data is available for academics and researchers via the Twitter API. The process to gain access is quite easy, but programming skills are required.

First, you will need to gain access credentials from Twitter through their developer website:

1. Apply for a developer account identify yourself as an "academic or researcher".

You will be directed to a login page if you are not already logged in. Create a Twitter account in case you don’t have one.

2. Select “doing academic research”. This means that you are “doing research to advance human understanding of a topic through Twitter data.”

3. Confirm the basic information and select "Next".

4. Complete the application form on how you will use the Twitter API or Twitter data. Click next and confirm that everything looks good on the following page. Clicks “Looks Good” to submit your application.

5. Twitter will send you an email (typically within a day or so) confirming your access. Once you receive this email, sign in to your developer account to get started.

6. Hover over your name and click “Apps” and select "Create an app".

7. Complete the form with information about how your app. Your Callback URL should be http://localhost:1410. When you're done select "Create".

8. Once you have created your app, return to the app page and click on your app.

9. Click “Keys and tokens” to find your Consumer API keys, Access token and access token secret. You will need this information to connect to the API through your program of choice. 

10. Save this information in a secure place. Note that Twitter will not show your access token and access token secret beyond the first time you generate it for security reasons. You can regenerate it from this same webpage, but it will invalidate your current access token and secret.

11. Use your programming language of choice to pull Tweets using the credentials gained in steps 1-10.

  • There are various packages within R that you can use to analyse Twitter data: rtweet, twitteR, streamR and RTwitterAPI. Rtweet has the strongest capabilities, but you can find a full comparison of the packages, here.
  • For Python, the Tweepy library is a great option. See Dilan Jayasekara's tutorial to get started.

What data is available?

Under this free access for academics and researchers, note that data is only available for the past 7 days! You will need to constantly pull new Tweets each day. Learn more from Twitter on what exactly is available from the "standard" tier.

First, you can search for Tweets based on a query (keyword or account name) in addition to (location, language, etc) and Twitter will return the most recent or popular responses (relevence not completeness).

For each Tweet, you can request the following data:

user_idstatus_idcreated_at
screen_nametext sourcedisplay_text_width
reply_to_status_idreply_to_user_idreply_to_screen_name
is_quoteis_retweetfavorite_count
retweet_counthashtags symbolsurls_url
urls.t.courls_expanded_urlmedia_url
media_typeprofile_banner_urlmedia_type
ext_media_urlext_media_t.coext_media_expanded_url
ext_media_typementions_user_idmentions_screen_name
langquoted_status_idquoted text
quoted_created_atquoted_sourcequoted_favorite_count
quoted_retweet_countquoted_user_idquoted_screen_name
quoted_namequoted_followers_countquoted_friends_count
quoted_statuses_countquoted_locationprofile_background_url
quoted_descriptionquoted_verifiedretweet_status_id
retweet_textretweet_created_atretweet_source
retweet_favorite_countretweet_retweet_countretweet_user_id
retweet_screen_nameretweet_nameretweet_follwers_count
retweet_friends_countretweet_statuses_countretweet_location
retweet_descriptionretweet_verifiedplace_url
place_nameplace_full_nameplace_type
profile_image_urlcountrycountry_code
geo_coordscoords_coordsbbox_coords
status_urlnamelocation
descriptionurlprotected
followers_countfriends_countlisted_count
statuses_countfavourites_countaccount_created_at
verifiedprofile_urlprofile_expanded_url
account_lang

(list courtesy of Rania Wazir)

Using Twitter data ethically

Twitter’s Developer Terms describe how to use data ethically:

  • Twitter data should never be used to derive or infer sensitive characteristics about users (e.g. political affiliation and beliefs, racial or ethnic origin, etc.)

  • Researchers are actually permitted to redistribute an unlimited number of Tweet IDs and/or User IDs. 

  • User Twitter data should not be matched to third party data to infer associations.

  • Twitter data should not be used to track sensitive groups and organisations (i.e. unions or activists), individual profiling or psychographic segmentation and more

  • You cannot create multiple applications to exceed token access.

Select another platform

Facebook Instagram WhatsApp YouTube
go to next chapter
With Contributions by Sponsored by Created By Contact us
Thank you for using the Digital Democracy Monitor Toolkit.
Please send us a message with any questions or feedback

Send

Thank you!
Your message has been successfully sent. We will contact you very soon!
Sorry, your message was not sent.
Please try again.