jdemaeyer / brightsky

JSON API for DWD's open weather data.
https://brightsky.dev/
MIT License
305 stars 18 forks source link

Investigate alternative response layouts #143

Open jdemaeyer opened 1 year ago

jdemaeyer commented 1 year ago

With alerts (#106) and daily aggregates (#117, #119), we'll be hitting the limits of our current response layout, where weather is an array of hourly records.

We can possibly squeeze these new data structures into the current response layout, keeping the current key weather instead of the more adequate hourly (but can we stick to sources being an array of sources, given that the sources will be different for daily and alerts?):

{
  "weather": […],
  "daily": […],
  "alerts": […],
  "sources": […],
}

But we could also seize the opportunity to start from scratch, maybe using the layout of OpenWeatherMap's One Call API:

{
  "lat": …,
  # … and other source info on top level
  "current": {…},
  "hourly": […],
  "daily": […],
  "alerts": […],
}

or Dark Sky's layout:

{
  "latitude": …,
  # … and other source info on top level
  "currently": {…},
  "hourly": {
    "summary": "…",
    "icon": "…",
    "data": […],
  },
  "daily": {
    "summary": "…",
    "icon": "…",
    "data": […],
  },
  "alerts": […],
  "flags": {
    "sources": […],
    "dwd-stations": […],
    "wmo-stations": […],
    "units": "dwd",
  }
}
AndiLeni commented 1 year ago

Hey, it might be helpful to see the layout from the bund.dev proxy: https://dwd.api.proxy.bund.dev/v30/stationOverviewExtended?stationIds=10865

AndiLeni commented 1 year ago

@jdemaeyer any news on this topic? I'd really love to see daily aggregates, because it is tedious to create the daily statistics over and over again in every project where I use brightsky 😄

tawissus commented 1 year ago

I would find aggregated values great too, but am I misunderstanding something?

First of all, this is just a loop for the included days. I just take the first 24 hours in an array and calculate min and max. Then it goes on the next 24 hours. I do this as often as the days are needed. The function can be used again and again or are the projects so different?

AndiLeni commented 1 year ago

Yes, it is not difficult to do it manually :) The codebases I have are written in different languages, so I have to adapt it for each one. The point is not the difficulty, it's for the sake of simplicity :)