def ticker(self): opts = { 'url': self.PublicApiUrl, 'params': { 'command': 'returnTicker' } } return jsonfetch(opts)
def fetchPub(self, callUrl, qsParams): qs = urllib.urlencode(qsParams) url = self.ApiBaseUrl + callUrl + '?' + qs opts = { 'url': url, } jval = jsonfetch(opts) return jval['result']
def fetchPriv(self, callUrl, qsParams): qsParams['apikey'] = self.apikey qsParams['nonce'] = int(time.time()) qs = urllib.urlencode(qsParams) url = self.ApiBaseUrl + callUrl + '?' + qs mac = hmac.new(str(self.secret), str(url), digestmod=hashlib.sha512) opts = { 'url': url, 'headers': { 'apisign': mac.hexdigest(), }, } jval = jsonfetch(opts) return jval['result']
def balance(self, address, apikey): opts = { 'url': self.ApiUrl, 'params': { 'module': 'account', 'action': 'balance', 'address': address, 'tag': 'latest', 'apikey': apikey, } } jval = jsonfetch(opts) wei = jval['result'] retobj = { 'ether': toEther(wei), 'wei': wei, } return retobj
def nhfetch(opts): sleep(2) # API rate limit is "approx 2s" return jsonfetch(opts)
def account(self, id): opts = { 'url': self.ApiBaseUrl + 'account/' + id } return jsonfetch(opts)
def basic_stats(self): opts = { 'url': self.ApiBaseUrl + 'basic_stats' } return jsonfetch(opts)
def balance(self, address): opts = { 'url': self.ApiBaseUrl + '/v1/eth/balance/' + address, } return jsonfetch(opts)