-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapi_functions.py
More file actions
36 lines (31 loc) · 1.12 KB
/
api_functions.py
File metadata and controls
36 lines (31 loc) · 1.12 KB
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
import json
import requests
from settings import api_exchange_address
def get_volatility_index_data(currency, start_timestamp, end_timestamp, resolution):
url = "/api/v2/public/get_volatility_index_data"
parameters = {
'currency': currency,
'start_timestamp': start_timestamp,
'end_timestamp': end_timestamp,
'resolution': resolution,
}
# send HTTPS GET request
# print(parameters)
json_response = requests.get((api_exchange_address + url + "?"), params=parameters)
response_dict = json.loads(json_response.content)
vol_index_data = response_dict["result"]
# print(vol_index_data)
return vol_index_data
def get_book_summary_by_currency(currency, kind):
url = "/api/v2/public/get_book_summary_by_currency"
parameters = {
'currency': currency,
'kind': kind,
}
# send HTTPS GET request
# print(parameters)
json_response = requests.get((api_exchange_address + url + "?"), params=parameters)
response_dict = json.loads(json_response.content)
book_summary = response_dict["result"]
# print(book_summary)
return book_summary