-
Notifications
You must be signed in to change notification settings - Fork 3
/
bttAPI.py
73 lines (58 loc) · 2.14 KB
/
bttAPI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import requests
import os
from getToken import getPort, grabToken
base = 'http://127.0.0.1'
port = getPort()
token = grabToken()
exchangeWalletBTT = 'TA1EHWb1PymZ1qpBNfNj9uTaxd18ubrC7a' # Do Not Change This Unless You Know What You're Doing
def getEnv(base=base, token=token, port=port):
url = "{}:{}/api/env?t={}".format(base, port, token)
data = requests.get(url).json()
return data
# EARNINGS API
def getUpdates(base=base, token=token, port=port):
url = "{}:{}/api/status?t={}".format(base, port, token)
data = requests.get(url).json()
return data
def getHourlyUpdate(base=base, token=token, port=port):
url = "{}:{}/api/revenue/hourly?t={}&revenue_type=earning".format(base, port, token)
data = requests.get(url).json()
return data
def getTotalUpdate(base=base, token=token, port=port):
url = "{}:{}/api/revenue/total?t={}".format(base, port, token)
data = requests.get(url).json()
return data
#WALLET API
def getPublicAddress(base=base, token=token, port=port):
url = "{}:{}/api/public_address?t={}".format(base, port, token)
pubAddr = requests.get(url).content.decode('UTF-8')
return pubAddr
def getPublicKey(base=base, token=token, port=port):
url = "{}:{}/api/public_key?t={}".format(base, port, token)
pubKey = requests.get(url).content.decode('UTF-8')
return pubKey
def getWalletTransactions(base=base, token=token, port=port):
url = "{}:{}/api/exchange/transactions?t={}&count=100".format(base, port, token)
data = requests.get(url).json()
return data
def refreshBalance(base=base, token=token, port=port):
url = "{}:{}/api/refresh_balance?t={}".format(base, port, token)
try:
data = requests.get(url)
if data.status_code == 200:
return
else:
print("Error: {}".format(data.status_code))
return False
except:
return False
# BTT TOKEN EXCHANGE API
def checkBTTExchange():
exchangeWallet = 'https://apilist.tronscan.org/api/account?address={}'.format(exchangeWalletBTT)
data = requests.get(exchangeWallet).json()
bttBalance = data['tokenBalances'][1]
if bttBalance['tokenAbbr'] == 'BTT':
walletBal = float(bttBalance['balance'].replace(',',''))/1000000
return walletBal
else:
print("Error: BTT index incorrect")