A wrapper over bets.42cc.co API
Project description
Installation
pip install bets-api==0.0.2
Basic Usage
import bets
api = bets.BetsApi('<your token>') # get token via admin UI
bets = api.get_active_bets() # list of active bets (same as on dashboard)
len(bets)
# => 70
bets[13]
# => {...} dict that represents the bet
api.get_project_slug(bets[13])
# => u'favim'
api.stakes_in(bet[13])
# => {'stakes': [{u'amount': Decimal('0.20000'),
# u'created': datetime.datetime(2014, 6, 2, 13, 36, 4, 322000),
# u'id': 3565,
# u'side': u'in',
# u'user': u'username'}],
# 'sum': Decimal('0.20000')}
api.stakes_out(bets[13])
# => {'stakes': [], 'sum': 0}
Subscribe to Event.BET_EXPIRED
import bets
import gevent
api = bets.BetsApi('<your token>')
def cb(bet):
print 'Bet changed: [%s] %s' % (bet['id'], bet['description'])
api.set_callback(bets.Event.BET_EXECUTED, cb)
api.subscribe(bets.Event.BET_EXECUTED, [1020, 1009, 1010, 11])
gevent.joinall(api.event_loop())
# => Bet changed: [1009] [42-jobs] 0 bugs (2014-05-02 18:00)
# Bet changed: [1010] [coinhand] budget <= 400.0 (2014-04-30 11:15)
# Bet changed: [11] [kavyarnya] deadline <= 2014-03-01 (2014-02-14 02:00)
For more sophisticated example see examples/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bets-api-0.0.2.tar.gz
(3.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bets-api-0.0.2.tar.gz.
File metadata
- Download URL: bets-api-0.0.2.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2264af44f231951279ccabd2e29a91cd0fe097d3752a2da3f4a87f768c5c49f4
|
|
| MD5 |
e8ef1ca3f9c1d8d4ecdf60f5751e8efe
|
|
| BLAKE2b-256 |
434d0f4b16db9b7a52cf3ab4a510e3bdcdaa366487e0923b0e2171b9442e671c
|
File details
Details for the file bets-api-0.0.2.linux-x86_64.tar.gz.
File metadata
- Download URL: bets-api-0.0.2.linux-x86_64.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00f40e2d46d006149bbb553b9208cc623d6f181bed9922cd3fe7069c7f4748f1
|
|
| MD5 |
b203646b5b82dbc3730f2e4c18cd306d
|
|
| BLAKE2b-256 |
acfcdcd14ce8a571abf65749899407572b2714a41f959e071da50c86073958fb
|