-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_module.py
45 lines (37 loc) · 1.26 KB
/
api_module.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
import requests
import pandas as pd
import time
import datetime
def rawdata(time_from, time_to):
api_endpoint1 = 'none'
r = requests.get(api_endpoint1 + f'?type=raw_data&time_from={time_from}&time_to={time_to}')
try:
data = pd.DataFrame(r.json()["values"], columns = r.json()["fields"])
return data
except:
print("데이터 다운로드 실패")
data = pd.DataFrame()
return data
def operation(time_from):
api_endpoint1 = 'none'
r = requests.get(api_endpoint1 + f'?type=all&time_from={time_from}&time_to={(time_from + 60 * 60)}')
try:
data = pd.DataFrame(r.json()["values"], columns=r.json()["fields"])
return data
except:
print("데이터 다운로드 실패")
data = pd.DataFrame()
return data
def min_data(time_from):
api_endpoint2 = 'none'
r = requests.get(api_endpoint2 + f'?type=mindex&time_from={time_from}&time_to={time_from + 60*60}')
try:
data = pd.DataFrame(r.json()["values"], columns = r.json()["fields"])
data['sumData'] = data["cycleIndex"]+data["contiIndex"]
return data
except:
print("데이터 다운로드 실패")
data = pd.DataFrame()
return data
if __name__ == "__main__":
pass