Home

Awesome

twick (Twitter, quick.)

twick is a command-line tool for fetching and storing tweets on short notice.

twick fetches tweets that match a given search query, and stores them in any SQLAlchemy-supported database (SQLite, PostgreSQL, MySQL, and more).

Developed at BuzzFeed.

Installation

pip install twick

Setup

To authenticate its API requests, twick requires the standard set of Twitter credentials: API key, API secret, access token, and access token secret. (For instructions on how to obtain these credentials, read this StackOverflow answer or follow Dan Nguyen's guide.) You can either supply them via the --credentials command-line argument (as four, space-separated strings), or by setting the following environment variables in your shell:

export TWICK_API_KEY="[replace me]"
export TWICK_API_SECRET="[replace me]"
export TWICK_ACCESS_TOKEN="[replace me]"
export TWICK_ACCESS_TOKEN_SECRET="[replace me]"

Usage

twick has two subcommands:

Both store basic data on each tweet (id, text, created_at, user_name, screen_name, and user_location) and each API response (query, count, completed_in, max_id, since_id, refresh_url, next_results).

Your search query will be the first argument after each subcommand. You can also supply any of these optional arguments:

Examples

twick fetch "harlem building collapse" --db sqlite:///tweets.db
twick fetch "drone from:buzzfeedben" --db sqlite:///ben-drone-tweets.sqlite --throttle 60
twick backfill "to:davidplotz pandas" --store-raw --throttle 5