-
Notifications
You must be signed in to change notification settings - Fork 0
/
oneforge.py
35 lines (26 loc) · 1 KB
/
oneforge.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
import requests
class Client:
def __init__(self, api_key):
self.api_key = api_key
self.base_uri = 'https://api.1forge.com/' # New API
def fetch(self, uri):
fetch_uri = self.base_uri + uri + '&api_key=' + self.api_key
# print(fetch_uri)
response = requests.get(fetch_uri)
return response.json()
def getQuota(self):
return self.fetch('quota?cache=false')
def getSymbols(self):
return self.fetch('symbols?cache=false')
def getQuotes(self, pairs):
return self.fetch('quotes?pairs=' + ','.join(pairs))
def marketIsOpen(self):
data = self.fetch('market_status?cache=false')
try:
return data['market_is_open']
except:
print(data)
def convert(self, currency_from, currency_to, quantity):
return self.fetch('convert?from=' + currency_from + '&to=' +
currency_to + '&quantity=' + str(quantity))
# End of file