How to Get Data from Twitter

This tutorial uses Tweepy software to use Python to get data from Twitter.  This tutorial was presented today at the Community Data Science Workshop @UW.  The first tutorial, an introduction to APIs, is here.

1) Get a a Twitter API key & access token

1) Then get a bunch of Python programs for Twitter

Screen Shot 2014-05-03 at 1.35.18 PM

2) Put the authentification information into a Python program

  • Download a text editor like Smultron
  • Open a new file and type your keys and tokens so it looks like this:

Screen Shot 2014-05-03 at 1.28.53 PM

  • Save the file as “” to the file of Twitter programs you just downloaded from GitHub.  (Replace the existing file with this name.)

3) Get tweets from Twitter

  • In your terminal run the command “python”.
  • Tweets should appear.

Screen Shot 2014-05-03 at 1.38.04 PM

  • This means you successfully used the Twitter API in a basic way.
  • This Twitter data looks messy and that is something you need to get used to.

Screen Shot 2014-05-03 at 1.50.20 PM

  • 99% data science is using your brain to figure out what the data you are looking at means.
  • 1% of data science is using statistics to interpret the data (or so says Guy)
  • Then you use additional commands in Python to extract pieces of information (like time zone) that you may want to analyze.



Leave a Reply

Your email address will not be published. Required fields are marked *


Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.