Skip to main content

Twitter Accounts Activity API Client Library for Python

Project description


PyPI - Python Version PyPI - License

Twitter Accounts Activity API Client Library for Python

Photo by Ingo Joseph from Pexels


Refer to Twitter's Getting Started Guide to create an application. Set a dev environment label for the app.

App :arrow_right: Details :arrow_right: Keys and Tokens

Add the credentials to the environment variables.

~$ export consumer_key=API_KEY
~$ export consumer_secret=API_SECRET_KEY
~$ export access_token=ACCESS_TOKEN
~$ export access_token_secret=ACCESS_TOKEN_SECRET
~$ export env_name=APP_ENV_NAME

Install & run ngrok.

~$ ./ngrok http 5000 

Stream events in real time.


>>> from twitivity import Event
>>> import json

>>> class StreamEvent(Event):
     CALLBACK_URL: str = ""
     def on_data(self, data: json) -> None:
         # process data

>>> stream_events = StreamEvent()
>>> stream_events.listen()


To register the callback URL run the program above alongside the one below. This will register your webhook URL and subscribe to activities.


from twitivity import Activity

>>> account_activity = Activity()
>>> account_activity.register_webhook("")
>>> account_activity.subscribe()

The registration will return json response

    'id': '1198870971131686912', # webhook id
    'url': '', 
    'valid': True, 
    'created_timestamp': '2019-11-25 07:48:08 +0000'


~$ pip install twitivity

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

twitivity-0.1.0.tar.gz (3.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page