Skip to main content

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 config.yaml

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

From version 0.1.3, twistream supports two backends. A relational database (SQLite) and a no-sql database (MongoDB).

NOTE that the SQLite backend will only save a couple of tweet fields, whilst the MongoDB backend will save the whole blob. It is a trade off between information and storage space.

Backend params format

SQLite
backend: sqlite

backend_params:
    db_path: /path/to/your/db
MongoDB
backend: mongodb

backend_params:
    db_string: database_connection_string

(See database connection string documentation)

Metadata

Release files for twistream 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for twistream 0.1.4
File Size Uploaded Provenance
twistream-0.1.4.tar.gz 8.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for twistream 0.1.4
File Interpreter ABI Platform
twistream-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 19.5 kB

Release files / twistream-0.1.4.tar.gz

Download URL twistream-0.1.4.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5aa177d3c9a508c922bb93088acc73fa36e21da363bf52a4c4452c3fee3ccbdc
BLAKE2b-256 checksum
How to use checksums
14532974f1b78a605a87aa61ca953e672736776f585d592f7f4a42a9db35304f
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / twistream-0.1.4-py3-none-any.whl

Download URL twistream-0.1.4-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa51902641bd6aa7b896e71dba7c689e938f9b772b238a2087acc338a88832e2
BLAKE2b-256 checksum
How to use checksums
471da0d43e5563b64cc168be439917117df5040dea0242939bc7cdcc2bbae9c2
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for twistream 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page