-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfinexapi.py
168 lines (126 loc) · 5.4 KB
/
infinexapi.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/python3
import requests, time, traceback, hashlib
import json
class infinex:
def __init__(self, apiKey):
self.apiKey = apiKey
self.urls = {
"assets": "https://api.infinex.cc/wallet/assets",
"networks": "https://api.infinex.cc/wallet/networks",
"balance": "https://api.infinex.cc/wallet/balances",
"transactions": "https://api.infinex.cc/wallet/transactions",
"deposit": "https://api.infinex.cc/wallet/deposit",
"withdrawInfo": "https://api.infinex.cc/wallet/withdraw/info",
"withdrawValidate": "https://api.infinex.cc/wallet/withdraw/validate",
"withdraw": "https://api.infinex.cc/wallet/withdraw",
"withdrawCancel": "https://api.infinex.cc/wallet/withdraw/cancel",
"addressBook": "https://api.infinex.cc/wallet/addressbook",
"addressBookRename": "https://api.infinex.cc/wallet/addressbook/rename",
"orderBook": "https://api.infinex.cc/spot/orderbook",
"openOrders": "https://api.infinex.cc/spot/open_orders",
"open": "https://api.infinex.cc/spot/open_orders/new",
"cancel": "https://api.infinex.cc/spot/open_orders/cancel"
}
def assets(self, symbols = '', search = '', offset = 0):
data = {}
if symbols != '': data['symbol'] = symbols
if search != '': data['search'] = search
data['offset'] = offset
req = requests.post(self.urls['assets'], json=data).json()
return req
def networks(self, asset):
data = {}
data['asset'] = asset
print (data)
req = requests.post(self.urls['networks'], json=data).json()
return req
def balance(self, symbols = '', search = '', offset = 0):
data = {}
data['api_key'] = self.apiKey
if symbols != '': data['symbol'] = symbols
if search != '': data['search'] = search
data['offset'] = offset
req = requests.post(self.urls['balance'], json=data).json()
return req
def transactions(self, asset = '', type = '', status = '', offset = 0):
data = {}
data['api_key'] = self.apiKey
if asset != '': data['asset'] = asset
if type != '': data['type'] = type
if status != '': data['status'] = status
data['offset'] = offset
req = requests.post(self.urls['transactions'], json=data).json()
return req
def deposit(self, asset, network):
data = {}
data['api_key'] = self.apiKey
data['asset'] = asset
data['network'] = network
req = requests.post(self.urls['deposit'], json=data).json()
return req
def WithdrawInfo(self, asset, network):
data = {}
data['api_key'] = self.apiKey
data['asset'] = asset
data['network'] = network
req = requests.post(self.urls['withdrawInfo'], json=data).json()
return req
def WithdrawValidation(self, asset, network, address='', memo=''):
data = {}
data['api_key'] = self.apiKey
data['asset'] = asset
data['network'] = network
if address != '': data['address'] = address
if memo != '': data['memo'] = memo
req = requests.post(self.urls['withdrawValidation'], json=data).json()
return req
def Withdraw(self, asset, network, address, amount, fee, memo = '', adbl_name = ''):
data = {}
data['api_key'] = self.apiKey
data['asset'] = asset
data['network'] = network
data['address'] = address
data['amount'] = amount
data['fee'] = fee
if memo != '': data['memo'] = memo
if adbl_name != '': data['adbl_name'] = adbl_name
req = requests.post(self.urls['withdraw'], json=data).json()
return req
def WithdrawCancel(self, xid):
data = {}
data['api_key'] = self.apiKey
data['xid'] = xid
req = requests.post(self.urls['withdrawCancel'], json=data).json()
return req
def addressBook(self, asset='', network=''):
data = {}
data['api_key'] = self.apiKey
if asset != '': data['asset'] = asset
if network != '': data['network'] = network
req = requests.post(self.urls['addressBook'], json=data).json()
return req
def addressBookRename(self, adbkid, new_name):
data = {}
data['api_key'] = self.apiKey
data['adbkid'] = adbkid
data['new_name'] = new_name
req = requests.post(self.urls['addressBookRename'], json=data).json()
return req
def OrderBook(self, market):
data = {'pair': market}
req = requests.post(self.urls['orderBook'], json=data).json()
return req
def OpenOrders(self, market, offset = 0):
data = {'api_key': self.apiKey, 'offset': offset, 'filter_pair': market}
req = requests.post(self.urls['openOrders'], json=data).json()
return req
def openOrder(self, market, side, type, tif, price, amount):
data = {'api_key': self.apiKey, 'pair': market, 'side': side, 'type': type, 'time_in_force': tif, 'price': price, 'amount': amount}
req = requests.post(self.urls['open'], json=data).json()
return req
def cancelOrder(self, obid):
data = {}
data['api_key'] = self.apiKey
data['obid'] = int(obid)
req = requests.post(self.urls['cancel'], json=data).json()
return req