Welcome to the second part of the twitter explorer tutorial at the ODYCCEUS online conference 2020. We will go through the preliminary steps you need to take in order to get the interface up and running.

Twitter Developer Account

In order to use the twitter explorer, you need to apply for a Twitter Developer account. Depending on your exact use case, the information you might provide in your application will vary. We prepared some example texts as inspiration for your application.

Example text for “Intended Use”

I am an academic researcher in the field of computational social science interested in analyzing interaction networks on Twitter using the Twitter Search API.

Example text for “Describe in your own words…”

I want to access the Twitter Search API endpoints to collect tweets from the last 7 days related to political events in order to better understand the role of Twitter in shaping the mediatization of certain events.

After submitting your application, you should recieve an answer from Twitter within about 1 week.

Installation

The twitter explorer relies on Python 3 for generating the networks and JavaScript for displaying them.

Windows

Download and install Python 3.8.2 from here, making sure to tick the option of adding Python to your PATH variable.

Download the current release of the twitter explorer to your Desktop folder and extract it.

Open a Powershell (hit the Windows key ❖ and start typing “power” until you see the “Powershell” icon and click it).

Type in the following command in the Powershell to go to the twitter explorer directory, followed by ENTER ↵, replacing XXX by the current release number:

cd .\Desktop\twitter-explorer-vXXX

Now, type in the following command to install the necessary packages, followed by ENTER :

pip3 install -r requirements.txt

After a while, all packages should be installed and you can start the collector with

streamlit run collector.py

To close the streamlit interface, hit CTRL + C in the Powershell.

Unix / macOS

The twitter explorer requires Python ≥ 3.6 to run. You most likely already have Python installed. To check which Python version you have, open a terminal window and type:

python -V
OR
python3 -V

If your version is above 3.6, continue to the next step. Otherwise, please refer to the guides specific to your operating system to install Python ≥ 3.6.

Download the current release of the twitter explorer and extract it. Open a terminal and change to the folder to which you downloaded the twitter explorer, replacing XXX by the release number:

cd ~/Downloads/twitter-explorer-vXXX

Now run the following command to install the necessary Python libraries (use pip3 if you used python3 before):

pip install -r requirements.txt

You can now start the collector from within the same terminal window:

streamlit run collector.py

You should see an error message that tells you to authenticate with your Twitter Developer credentials. Move on to the next section to generate the necessary keys.

To close the streamlit interface, hit CTRL + C in the terminal.

Authentication

Go to the Apps section of your Twitter account and click on Create an app in the upper right corner:

Enter twitter explorer as the name and a description of the research you want to do with the tool in the description field. As website enter http://example.org. In the last field, enter Explore Twitter data through network representations. Now create the app with the create button.

Go to your new app and enter the Keys and tokens section. Copy the Consumer API keys:

Create a new file in the twitter explorer folder called twitter_apikeys.txt with the following content:

# api_key
INSERT API_KEY HERE
# api_secret_key
INSERT API_SECRET_KEY HERE

Save the file and you are good to go. You can now refresh the page of the collector and start collecting your first dataset of tweets!