# Creating a new workbook for requests

import requests
import json
#import xlwt
#import xlsxwriter
#from xlwt import *


#url = "https://reports.sem-o.com/api/v1/documents/static-reports"
url= "https://reports.sem-o.com/api/v1/documents/static-reports?ReportName=Balancing%20and%20Imbalance%20Market%20Cost%20View&Date=>2019-11-10"
response = requests.get(url)
data = response.json()

listOfReports = []
#output to console
#print (data)
for item in data["items"]:
    #print(item["ResourceName"])
    listOfReports.append(item["ResourceName"])


# Iterate through all the reports:
for ReportName in listOfReports:
    #print(ReportName)
    url ="https://reports.sem-o.com/api/v1/documents/"+ReportName
    print(url)
    # Go to URL and retrieve the report:
    response= requests.get(url)
    
    aReport= response.json()

#w.save('balance.xls')
#other code
#save this to a file
filename = 'allreports.json'
# Writing JSON data
f =  open(filename, 'w')
json.dump(data, f, indent=4)
# Creating a new workbook for requests

import requests
import json
#import xlwt
#import xlsxwriter
#from xlwt import *


#url = "https://reports.sem-o.com/api/v1/documents/static-reports"
url= "https://reports.sem-o.com/api/v1/documents/static-reports?ReportName=Balancing%20and%20Imbalance%20Market%20Cost%20View&Date=>2019-11-10"
response = requests.get(url)
data = response.json()

listOfReports = []
#output to console
#print (data)
for item in data["items"]:
    #print(item["ResourceName"])
    listOfReports.append(item["ResourceName"])


# Iterate through all the reports:
for ReportName in listOfReports:
    #print(ReportName)
    url ="https://reports.sem-o.com/api/v1/documents/"+ReportName
    print(url)
    # Go to URL and retrieve the report:
    response= requests.get(url)
    
    aReport= response.json()

#w.save('balance.xls')
#other code
#save this to a file
filename = 'allreports.json'
# Writing JSON data
f =  open(filename, 'w')
json.dump(data, f, indent=4)
# Creating a new workbook for requests #import xlwt #import xlsxwriter #from xlwt import * #url = "https://reports.sem-o.com/api/v1/documents/static-reports" #output to console #print (data) #print(item["ResourceName"]) # Iterate through all the reports: #print(ReportName) # Go to URL and retrieve the report: #w.save('balance.xls') #other code #save this to a file # Writing JSON data