Skip to main content

Automate Twitter Stream data collection

Project description

Twistream: Twitter Stream API data collection

CircleCI PyPI version

Twistream helps you automatically collect and store data from Twitter Stream API.

Installation

Latest stable release:

pip install twistream

From source:

git clone https://github.com/guillermo-carrasco/twistream.git
cd twistream
pip install .

Setting up

Twitter credentials

You need your twitter credentials in order to be able to use Twitter API. For that, create an application here. Once created, save the credentials to configure twistream

Create a configuration file

You can use the command twistream init to help you create a correctly formatted configuration file for your collections.

Once created, you will have a file that will luke like this:

~> cat ~/.twistream/twistream.yml      

twitter:                  
  consumer_key: your_consumer_key                   
  consumer_secret: your_consumer_secret             
  access_token_key: your_access_token_key             
  access_token_secret: your_access_token_secret       
      

backend: backend_name                  

backend_params:
    username: db_username
    password: db_password

Usage

Remember that --help is always an available option

Once created a configuration file, start collecting tweets!

twistream collect --tracks tracks,to,follow

Refer to the twitter documentation to know what tracks are, in short:

A comma-separated list of phrases which will be used to determine what Tweets will be delivered on the stream. A phrase may be one or more terms separated by spaces, and a phrase will match if all of the terms in the phrase are present in the Tweet, regardless of order and ignoring case. By this model, you can think of commas as logical ORs, while spaces are equivalent to logical ANDs (e.g. ‘the twitter’ is the AND twitter, and ‘the,twitter’ is the OR twitter).

If what you want is to follow hashtags, don't forget to include the # character.

Supported backends

Right now twistream only supports sqlite, the backend and backend_params sections in your configuration file should look like this:

backend: sqlite

backend_params:
    db: /path/to/your/db

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

twistream-0.1.1.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file twistream-0.1.1.tar.gz.

File metadata

  • Download URL: twistream-0.1.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for twistream-0.1.1.tar.gz
Algorithm Hash digest
SHA256 00aada1e51241d4c3d46250315b2385fd37679434681ea9297498fae4e022771
MD5 f6399c1355f65585079fba92988b8146
BLAKE2b-256 1dc5881ef06d20faa3c13c020c7340b4a42f830ab86e35f4ac3a9ff829f7f915

See more details on using hashes here.

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