Skip to main content

Asynchronous, concurrent requests to the Twitter REST API, that respect Twitter's rate limits, using gevent and requests.

Project description

# Twitterspawn

Asynchronous, concurrent requests to the Twitter REST API, that respect Twitter's rate limits, using [gevent](http://www.gevent.org/) and [requests](http://docs.python-requests.org/).

See [example.py](https://github.com/swinton/twitterspawn/blob/develop/example.py) for a working example.

## Usage
Basically:

```python
import twitterspawn

# Define callback (can define 1 per request)
def callback(response, worker):
print "Got", response, "from", worker

# Add requests + callbacks
twitterspawn.add_request("https://api.twitter.com/1/users/show.json",
dict(params=dict(screen_name="steveWINton")),
callback)
twitterspawn.add_request("https://api.twitter.com/1/users/show.json",
dict(params=dict(screen_name="twitter")),
callback)
twitterspawn.add_request("https://api.twitter.com/1/users/show.json",
dict(params=dict(screen_name="catbinlady")),
callback)

# Add workers
twitterspawn.add_worker(access_token="YOUR_FIRST_ACCESS_TOKEN",
access_token_secret="YOUR_FIRST_ACCESS_TOKEN_SECRET",
consumer_key="YOUR_CONSUMER_KEY",
consumer_secret="YOUR_CONSUMER_SECRET")
twitterspawn.add_worker(access_token="YOUR_NEXT_ACCESS_TOKEN",
access_token_secret="YOUR_NEXT_ACCESS_TOKEN_SECRET",
consumer_key="YOUR_CONSUMER_KEY",
consumer_secret="YOUR_CONSUMER_SECRET")
# ...add as many more workers as required...
twitterspawn.add_worker(access_token="YOUR_LAST_ACCESS_TOKEN",
access_token_secret="YOUR_LAST_ACCESS_TOKEN_SECRET",
consumer_key="YOUR_CONSUMER_KEY",
consumer_secret="YOUR_CONSUMER_SECRET")

# Go!
twitterspawn.go()
```

See also [example.py](https://github.com/swinton/twitterspawn/blob/develop/example.py) for a working example.

## Installation
Simply:

$ pip install twitterspawn

## Contact

@[steveWINton](https://twitter.com/steveWINton).

Project details


Download files

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

Files for twitterspawn, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size twitterspawn-0.2.0.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page