-
Notifications
You must be signed in to change notification settings - Fork 1
/
RippleDataAPI.py
61 lines (30 loc) · 1.28 KB
/
RippleDataAPI.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
import urequests
class RippleDataAPI:
def __init__(self):
self.node = 'https://data.ripple.com'
self.apiVersion = 'v2'
def call(self, urlParams, queryParams):
endpoint = [self.node, self.apiVersion]
endpoint.extend(urlParams)
endpoint = '/'.join(endpoint)
parameters = '&'.join([qp + '=' + queryParams[qp] for qp in queryParams])
try:
result = urequests.get(endpoint + '?' + parameters).json()
except:
result = {'result': 'error'}
finally:
return result
def getExchangeVolume(self, queryParams={}):
return self.call(['network', 'exchange_volume'], queryParams)
def getPaymentVolume(self, queryParams={}):
return self.call(['network', 'payment_volume'], queryParams)
def getExternalMarkets(self, queryParams={}):
return self.call(['network', 'external_markets'], queryParams)
def getExchanges(self, params, queryParams={}):
urlParams = ['exchanges']
urlParams.extend(params)
return self.call(urlParams, queryParams)
def getExchangeRates(self, params, queryParams={}):
urlParams = ['exchange_rates']
urlParams.extend(params)
return self.call(urlParams, queryParams)