3 ms·
Hey, I was literally just writing up this example for a DSL I'm working on: GET /:city/weather.svg |> fetch("https://geocoding-api.open-meteo.com/v1/sear
by williamcotton 9mo ago
Hey, I was literally just writing up this example for a DSL I'm working on:
GET /:city/weather.svg
|> fetch("https://geocoding-api.open-meteo.com/v1/search?name=" + .params.city + "&count=10&language=en&format=json", {method: "GET"})
|> jq: `{
latitude: .data.response.results[0].latitude | tostring,
longitude: .data.response.results[0].longitude | tostring
}`
|> fetch("https://api.open-meteo.com/v1/forecast?latitude=" + .latitude + "&longitude=" + .longitude + "&hourly=temperature_2m", {method: "GET"})
|> jq: `
.data.response.hourly as $h |
[$h.time, $h.temperature_2m] | transpose | map({time: .[0], temp: .[1]})
`
|> gg({ "type": "svg", "width": 800, "height": 400} ): `
aes(x: time, y: temp)
| line()
| point()
`
Thanks for the service, I use it for demos all the time!