import requests api_key = 'your_key' site_id = 'your_id' solaredge = 'https://monitoringapi.solaredge.com/%20site/'+ site_id + '/overview.json?api_key=' +api_key json_data = requests.get(solaredge).json() class solaredge(): @staticmethod def solardata(): lastupdatetime = json_data['overview']['lastUpdateTime'] totalenergythisyear = json_data['overview']['lifeTimeData']['energy']/1000 lastyearenergy = json_data['overview']['lastYearData']['energy']/1000 lastmonthenergy = json_data['overview']['lastMonthData']['energy']/1000 lastdayenergy = json_data['overview']['lastDayData']['energy']/1000 currentpower = json_data['overview']['currentPower']['power'] return {'lastupdatetime':lastupdatetime,'totalenergythisyear': totalenergythisyear,'lastyearenergy': lastyearenergy,'lastmonthenergy': lastmonthenergy,'lastdayenergy': lastdayenergy,'currentpower':currentpower} result = solaredge.solardata() print(result['lastmonthenergy'])