How to use Twitter data for research?


#1

Hi,

I am a researcher and have been trying to use the Twitter API to get data for my undergraduate project. Ideally, I am trying to get data on a particular search term within a geographically bounded area whilst streaming for tweets, but I am struggling on the coding side as I am a geographer so have no experience. I was just wondering if there is anyone with experience of doing this before that could help me out?

This is what I have done so far (I am basically struggling on finding a way to start and stop a stream for my data samples):

console.log(‘The bot is starting’);
var Twit = require(‘twit’);
var config = require(’./config’);
var T = new Twit(config);

var params = {
q: ‘racism’,
geocode: ‘51.507,-0.128,100mi’,
count: 200

}

T.get(‘search/tweets’, params, gotData);

function gotData(err, data, response) {
console.log(data);
}

Thank you :slight_smile:


#2

One thing worth understanding is that very few Tweets have location data attached. This is based on user preference and action, and do not occur automatically. The percentage of Tweets with user location shared is in the region of < 5% so depending on your geo and term this is not unusual.


#3

Hi Andy,

Thank you for your reply. From what I have read and getting further into my
project I have realised this too. I wanted to ideally get data on
geolocated tweets from a keyword, but as the percentage of tweets from the
API is so small on top of the only geo-located ones, do you think this
would be achievable to generate enough data? I understand it’s a vague
question but I am really keen on my idea and am trying to suss out if it is
still achievable.

Thank you,

Maria


#4

I’m very sorry Maria but I am not able to answer in a binary fashion. It would would depend on your search region, the nature of the search terms, and the allowable sample size for your project. Note that the free streaming API is just 1% of the Twitter firehose of ~6000 Tweets per second.


#5

Might I suggest this blog post by a colleague on collecting by geographic location in the context of academic research.


#6

Hi Justin,

Thank you very much for forwarding me that link, it has some really useful information!