Skip to main content

Python Client For Twitter Streaming API v2

Project description

twitter-stream.py

v2

Sampled Stream

Construct cleaner and concise queries. Subclass SampledStream, name your desired query parameters, and assign their values in a list. twitter-stream.py will take care of the rest. Here are the list of query parameters

Recent Stream

Get Recent Stream Based on your queries. Checkout the list of query parameters for Recent Stream

Filtered Stream

Bearer Token

~$ export BEARER_TOKEN=BEARER TOKEN

Adding Rules

>>> import json
>>> from twitter_stream.twitter_stream import FilteredStream

>>> stream = FilteredStream()
>>> rules = {"add": [{'value': 'from: twitivitydev'}]}
>>> print(json.dumps(stream.add_rule(data=rules), indent=4))

Deleting Rules

>>> import json
>>> from twitter_stream.twitter_stream import FilteredStream

>>> stream = FilteredStream()
>>> response = stream.delete_rule({"delete": {"ids": ['1331486534579589120']}})
>>> print(response)

Get Rules

>>> import json
>>> from twitter_stream.twitter_stream import FilteredStream

>>> stream = FilteredStream()
>>> print(json.dumps(stream.get_rules(), indent=4, sort_keys=True))

Stream

>>> import json
>>> from twitter_stream.twitter_stream import FilteredStream

>>> stream = FilteredStream()
>>> for tweet in stream.connect():
       print(json.dumps(tweet, indent=4))

Installation

~$ pip3 install twitter-stream.py

Documentation

Read the documentation at twitivity.dev/docs


Support

Please consider supporting this repository. 

BTC: bc1q2t4zv83g20u8gt2ly2cquwr57eawqxus092jwu
ETH: 0xf6169c013ac11eEFD5e87A60F8ED31AA75D874a7 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twitter-stream.py-0.4.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page