openclimatefix / Elexonpy

Python package wrapper around Elexon api
MIT License
12 stars 4 forks source link

Think about package layout, perhaps theres sub good subfolders that fit with the api routes #2

Closed peterdudfield closed 5 months ago

peterdudfield commented 5 months ago

I did a bit of code

""" 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)))

and came up with this folder and file structure

 '/balancing',
 '/balancing/nonbm',
 '/balancing/nonbm/disbsad',
 '/balancing/pricing',
 '/balancing/settlement',
 '/balancing/settlement/acceptance',
 '/balancing/settlement/indicative',
 '/datasets',
 '/demand',
 '/demand/peak',
 '/demand/peak/indicative',
 '/forecast',
 '/forecast/availability',
 '/forecast/demand',
 '/forecast/generation',
 '/forecast/generation/wind',
 '/forecast/indicated',
 '/forecast/margin',
 '/forecast/surplus',
 '/forecast/system',
 '/generation',
 '/generation/actual',
 '/generation/actual/per-type',
 '/generation/availability',
 '/generation/outturn',
 '/lolpdrm/forecast',
 '/reference',
 '/reference/remit',
 '/remit',
 '/remit/list',
 '/soso',
 '/system']
peterdudfield commented 5 months ago

Next perhaps, is to write a operation-id to file name function

peterdudfield commented 5 months ago

Ive given this go and commit the file structure, comments are very welomce