""" File to get all the routes of the api """
import json
# returns JSON object as
# a dictionary
with open(
"prod-insol-insights-api.json",
) as f:
data = json.load(f)
all_paths = data["paths"]
all_paths = list(all_paths.keys())
# sort paths
all_paths = sorted(all_paths)
# save to csv
with open("prod-insol-insights-api.csv", "w") as f:
for path in all_paths:
f.write(f"{path}\n")
paths = all_paths
for s in [
"/all",
"/stream",
"/events",
"/latest",
"/rates",
"/daily",
"/weekly",
"/day-ahead",
"/yearly",
"/total",
"/summary",
]:
paths = [path.replace(s, "") for path in paths]
# remove any paramters
paths = [path.split("/{")[0] for path in paths]
# remove last parameter
paths = ["/".join(path.split("/")[:-1]) for path in paths]
# take unique
paths = sorted(list(set(paths)))
I did a bit of code
and came up with this folder and file structure