Newb Question for twitter streaming

Meteor Newb here. I’m digging through the packages and I’m interested in streaming tweets. I found the mrt:user-stream package and see that there is a code example for streaming tweets to the console. Which file would I put this block of code in to get the tweets to stream via console. Do I need to create a server folder and put this code in there? any help is appreciated. Thanks

here is the code (I already have all my twitter keys):

var Stream = require(‘user-stream’);
var stream = new Stream({
consumer_key: ‘’,
consumer_secret: ‘’,
access_token_key: ‘’,
access_token_secret: ‘’

//create stream;

//listen stream data
stream.on(‘data’, function(json) {

Just try it :smile: But yes, this would need to go into a file in /server. And you don’t have to require user-stream. That’s already been done. So just leave out the first line, and save your file.
: )

Thanks for the reply! I tried deleting that line and not its telling me that Stream is not defined.

I just created a new Meteor project to test it and it worked great. Should be quite clear what to do and the only thing I can imagine is that you forgot to add the package. If not that’s what I did:

  1. meteor create twitter-test

  2. Remove all files from twitter-test/

  3. Create a folder server with a file twitter.js inside

  4. Run meteor add mrt:user-stream

  5. Paste this code into the twitter.js file, without the first line (var Stream = require('user-stream');)

  6. Go to and create an app, or get the keys you already have

  7. Insert keys into the Stream configuration

  8. Set request parameters (here and here). I changed to{
    with: ‘meteorjs’

  9. Run meteor and tweet the MDG guys something nice

  10. The tweet gets logged.

1 Like

Thanks, fvg! It works. Thanks again for the help.

1 Like