feat(reading data from finot)
This commit is contained in:
39
finot_reading.py
Normal file
39
finot_reading.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import requests
|
||||
import pandas as pd
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
|
||||
token: str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
entity_id: str = "a2538791-5723-42f2-af2a-a134c95ecba1"
|
||||
attr_name: str = "SolarPanel1"
|
||||
attr_type: str = "Number"
|
||||
|
||||
from_date: str = "2024-12-19T15:44:34Z"
|
||||
to_date: str = "2024-12-20T15:44:34Z"
|
||||
|
||||
limit: int = 100
|
||||
|
||||
config = Settings()
|
||||
|
||||
url = f'https://api.panoptis.finot.cloud/historical/v1/entities/{config.entity_id}/attrs/{config.attr_name}?fromDate={config.from_date}&toDate={config.to_date}&lastN={config.limit}'
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'Apidog/1.0.0 (https://apidog.com)',
|
||||
'X-Tenant': 'tenant1',
|
||||
'Authorization': f'Bearer {config.token}'
|
||||
}
|
||||
|
||||
json_response = requests.request("GET", url, headers=headers).json()
|
||||
|
||||
if json_response.get("status") != 200:
|
||||
print(json_response)
|
||||
else:
|
||||
try:
|
||||
data = {'dates': json_response.get("result").get("index"), 'values': json_response.get("result").get("values")}
|
||||
print(pd.DataFrame(data))
|
||||
except ValueError:
|
||||
print(json_response)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user