Skip to content

BONUS Part 7. The Unlimited Stream

Rachel edited this page Mar 31, 2017 · 5 revisions

If you're looking to sift through every single tweet that's coming in you'll need to consume the Twitter API directly. You can do this using the pubnubStreamUnlimited.py script or the pubnubStreamUnlimited.js script.

If you're planning on analyzing more than 1000 tweets a day, you'll also have to upgrade your IBM Bluemix plan. The current AlchemyAPI plan looks like this:

As I mentioned earlier, IBM will soon be switching sentiment analysis over from the AlchemyAPI to Natural Language Understanding. The pricing structure is slightly different:

Once you've figured out if you need to upgrade your IBM Bluemix service or not, you can get started using the Twitter API!

Get Twitter API Credentials

To get your Twitter API Credentials you will need to:

  1. Create a Twitter developer account
  2. Create an application
  3. Click on your app to be taken to its Details page. Click on the "Keys and Access Tokens" tab at the top to find and copy your Consumer Key, Consumer Secret, Access Token, and Access Token Secret (you may need to generate the access tokens).

Copy-paste these keys into their respective spots on lines 11-14 in the Python script or lines 7-10 in the Node script.

Install a Twitter Module

Python

Tweepy is an awesome library for accessing the Twitter API through Python. To install it run:

pip install tweepy

Node

You can install Twitter for Node.js with:

npm install twitter

Note: If you receive a permissions error, add "sudo" to the front of the command

Don't Forget

Add your PubNub subscribe and publish keys to this script too!

Now you should be all set to ingest the flood of data! I must say that I was super impressed watching PubNub successfully send messages to Watson, give me the response, and then send that data to Initial State even though I was absolutely hammering it. I mean, I hit my 1000 calls a day in less than 5 minutes!

<< BONUS - Part 6: Add Tweet Locations

Clone this wiki locally