Skip to content

An infinite stream connected to Twitter and focusing on Retweets forecasting for River.

License

Notifications You must be signed in to change notification settings

raphaelsty/twiver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twiver

An infinite stream connected to Twitter and focusing on [retweets, likes, quotes, replies] forecasting for River.

Installation 🤖

pip install git+https://github.com/raphaelsty/twiver --upgrade

Bearer token

To use Twiver, you must create a Twitter developer account. Everything is explained here. Once you have your BEARER_TOKEN, you can save it as an environment variable.

export BEARER_TOKEN=<YOUR_BEARER_TOKEN>

Quickstart 🐥

>>> from twiver import stream
>>> import datetime
>>> import os

>>> bearer_token = os.environ["BEARER_TOKEN"]

>>> stream = stream.Twitter(
...     bearer_token = bearer_token,
...     sample_rules = [
...         {"value": "Brooklyn lang:fr", "tag": "Tweets that mention Brooklyn in French."},
...         {"value": "Brooklyn lang:en", "tag": "Tweets that mention Brooklyn in English."},
...     ],
...     delay = datetime.timedelta(seconds=20),
...     target = "retweet_count", # Available targets are: ["retweet_count", "reply_count", "like_count", "quote_count"]
... )

>>> for i, x, y in stream:
...     break

>>> x
{
    'created_at': datetime.datetime(2021, 4, 26, 22, 59, 16), 
    'text': 'Brooklyn, Cool Cool Cool Cool Cool.', 
    'username': 'Jake Peralta', 
    'reply': False, 
    'id': '1386817182877822997', 
    'retweet_count': 0, 
    'reply_count': 0, 
    'like_count': 0, 
    'quote_count': 0, 
    'followers_count': 292, 
    'following_count': 691, 
    'tweet_count': 2803, 
    'listed_count': 0,
    'tag': 'Tweets that mention Brooklyn in English.',
}

About

An infinite stream connected to Twitter and focusing on Retweets forecasting for River.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages