Inspired by this wrapper written by 'oipminer'
- The first 2 args in the
poloniex.Poloniex
object (Key
andSecret
) are optional when used for public api commands. - Api commands have been 'mapped' into methods within the
Poloniex
class for your convenience. - Raises
poloniex.PoloniexError
if the command supplied does not exist, if the api keys are not defined and attempting to access a private api command, or if Poloniex.com returns an api error. - The
poloniex.Poloniex(timeout=1)
attribute/arg adjusts the number of seconds to wait for a response from poloniex, elserequests.exceptions.Timeout
is raised. - If a
requests
exception is raised (includingTimeout
s), signaling that the api call did not go through, the wrapper will attempt to try the call again. The wait pattern between retrys are as follows (in seconds): (0, 2, 5, 30). Once the retry delay list is exausted and the call still throws an error, the list of captured exceptions is raised. - A call restrictor (
coach
) is enabled by default, limiting the api wrapper to 6 calls per second. If you wish, you can deactivate the coach usingPoloniex(coach=False)
or use an 'external' coach. - By default, json floats are parsed as strings (ints are ints), you can define
Poloniex(jsonNums=float)
to have all numbers (floats and ints) parsed as floats (or import and usedecimal.Decimal
). poloniex.coach
,poloniex.retry
, andpoloniex
have self named loggers.
Python 2:
pip install git+https://github.com/s4w3d0ff/python-poloniex.git
Python 3:
pip3 install git+https://github.com/s4w3d0ff/python-poloniex.git
Python 2:
pip uninstall poloniex
Python 3:
pip3 uninstall poloniex
from poloniex import Poloniex
polo = Poloniex()
Ticker
print(polo('returnTicker')['BTC_ETH'])
# or
print(polo.returnTicker()['BTC_ETH'])
Public trade history:
print(polo.marketTradeHist('BTC_ETH'))
import poloniex
polo = poloniex.Poloniex('your-Api-Key-Here-xxxx','yourSecretKeyHere123456789')
# or
polo.Key = 'your-Api-Key-Here-xxxx'
polo.Secret = 'yourSecretKeyHere123456789'
Get all your balances
balance = polo.returnBalances()
print("I have %s ETH!" % balance['ETH'])
# or
balance = polo('returnBalances')
print("I have %s BTC!" % balance['BTC'])
from poloniex import Poloniex, Coach
myCoach = Coach()
public = Poloniex(coach=myCoach)
private = Poloniex(Key, Secret, coach=myCoach)
# now make calls using both 'private' and 'public' and myCoach will handle both
Examples of WAMP applications using the websocket push API can be found here.