Code: Alles auswählen
import requests
import json
from json_excel_converter import Converter
from json_excel_converter.xlsx import Writer
networkIDUG = "kGUzZ57nbsFLe2ZxCMB7ybmO0LEaQsXXX"
networkIDOG = "r9rXox4Zn0wzRLLkcsq6bBczsKfaaXXX"
url = "XXXXX"
geturl1_1 = "XXXXX"
geturlDatapoints = "/datapoints"
geturlUnits = "/units"
filter1 = "?dataType=sensors&from=2022" + startdate + "&to=2022" + enddate + "&tzOffset=%2B1"
startdate = input("Enter startdate(MMDD):")
enddate = input("Enter enddate(MMDD):")
headers = {"Key": "2u5NSHLDMFG3WL6sE3GEcB5FFwSunEGXcMASZSdSeKzeWY9xj46xNRym8XXXXXX"}
request_data = {"email": "", "password": ""}
response = requests.post(url, headers = headers, json=request_data)
print(response.status_code)
sessionIDUG = request.json()[networkIDUG]["sessionId"]
sessionIDOG = request.json()[networkIDOG]["sessionId"]
headers = {"Key": "2u5NSHLDMFG3WL6sE3GEcB5FFwSunEGXcMASZSdSeKzeWY9xj46xNRym8XXXXXX",
"Session": }
response = requests.get(geturl, headers = headers)
print(response.status_code)
data = [
{'a': [1], 'b': 'hello'},
{'a': [1, 2, 3], 'b': 'world'}
]
print("Data Type data:" + str(type(data)))
print("Data Type Json load" + str(type(response.json)))
conv = Converter()
conv.convert(response.json(), Writer(file='./apipull.xlsx'))
Die ist nochmal eine komplette Antwort, da die andere zu lange wäre.
Code: Alles auswählen
{
"1": {
"name": "Test low",
"id": 1,
"position": 0,
"icon": 0,
"color": "#FFFFFF",
"type": "REGULAR",
"hidden": false,
"units": {
"4": {
"id": 4
},
"5": {
"id": 5
},
"6": {
"id": 6
},
"8": {
"id": 8
},
"9": {
"id": 9
},
"11": {
"id": 11
},
"13": {
"id": 13
},
"14": {
"id": 14
},
"16": {
"id": 16
}
}
},
"2": {
"name": "Test",
"id": 2,
"position": 1,
"icon": 0,
"color": "#FFFFFF",
"type": "REGULAR",
"hidden": false,
"units": {
"4": {
"id": 4
},
"5": {
"id": 5
},
"6": {
"id": 6
},
"8": {
"id": 8
},
"9": {
"id": 9
},
"11": {
"id": 11
},
"13": {
"id": 13
},
"14": {
"id": 14
},
"16": {
"id": 16
}
}
},
"3": {
"name": "Liquidationsraum",
"id": 3,
"position": 2,
"icon": 0,
"color": "#FFFFFF",
"type": "REGULAR",
"hidden": false,
"units": {
"4": {
"id": 4
},
"5": {
"id": 5
},
"6": {
"id": 6
},
"8": {
"id": 8
},
"9": {
"id": 9
}
}
},
"4": {
"name": "Schachtellager",
"id": 4,
"position": 3,
"icon": 0,
"color": "#FFFFFF",
"type": "REGULAR",
"hidden": false,
"units": {
"11": {
"id": 11
},
"13": {
"id": 13
},
"14": {
"id": 14
},
"16": {
"id": 16
}
}
},
"5": {
"name": "Büromaterial",
"id": 5,
"position": 4,
"icon": 0,
"color": "#FFFFFF",
"type": "REGULAR",
"hidden": false,
"units": {
"11": {
"id": 11
}
}
},
"6": {
"name": "AN",
"id": 6,
"position": 5,
"icon": 0,
"color": "#FFFFFF",
"type": "REGULAR",
"hidden": false,
"units": {
"4": {
"id": 4
},
"5": {
"id": 5
},
"6": {
"id": 6
},
"8": {
"id": 8
},
"9": {
"id": 9
},
"11": {
"id": 11
},
"13": {
"id": 13
},
"14": {
"id": 14
},
"16": {
"id": 16
}
}
},
"7": {
"name": "AUS",
"id": 7,
"position": 6,
"icon": 0,
"color": "#FFFFFF",
"type": "REGULAR",
"hidden": false,
"units": {
"4": {
"id": 4
},
"5": {
"id": 5
},
"6": {
"id": 6
},
"8": {
"id": 8
},
"9": {
"id": 9
},
"11": {
"id": 11
},
"13": {
"id": 13
},
"14": {
"id": 14
},
"16": {
"id": 16
}
}
}
}