A command line utility for streaming tweets using rules. Based on Twitter’s Filter Stream API.
Fowlstream was written for Python 3.8. Other versions may work but no guarantees.
pip install 'aiohttp[speedups]'
You’ll need a Twitter Developer account.
- Sign up for Twitter if you don’t already have an account: https://twitter.com/
- Apply to be a Twitter developer: https://developer.twitter.com/
- Once approved create an app: https://developer.twitter.com/en/apps (You’ll use the Consumer API Keys, not the “Access token & access token secret”)
- Enable the Filter Stream API in Labs and associate your app: https://developer.twitter.com/en/account/labs
export TWITTER_ACCESS_TOKEN=<token>
export TWITTER_ACCESS_SECRET=<secret>
./fowlstream.py list-rules # should return nothing
./fowlstream.py set-rule dogs "(dog OR puppy) has:image -is:retweet -is:quote"
./fowlstream.py list-rules # should see your new rule
To watch the stream:
./fowlstream.py watch
Or if you’d like to save the data later for processing in some other way
./fowlstream.py stream >> rainy_day_pictures.json
Be sure to check out the built-in documentation
./fowlstream.py --help