Grab the weather forecast using

I like to record the weather in my journals. For several years, I’ve used via curl. Recently, wttr has often been unreachable or would throw errors, so I took a look at

Designed for developers by developers, Weather API is the ultimate weather and geolocation API

The free account limits are generous, so I created an account. The default JSON results are very thorough. I created a little shell script that returns only the high/low temps and a text summary of the forecast:

# Jack Baty, 2023 (


curl -s "" > $weatherfile

condition=`${jq} -r .forecast.forecastday[0].day.condition.text ${weatherfile}`
high=`${jq} -r .forecast.forecastday[0].day.maxtemp_f ${weatherfile}`
low=`${jq} -r .forecast.forecastday[0].day.mintemp_f ${weatherfile}`

echo "Low ${low}, High ${high} - ${condition}"

The output looks like this:

Low 52.1, High 72.6 - Patchy rain possible

Easy enough. I wrote a small lisp function for inserting the weather in Emacs:

(defun jab/insert-forecast ()
  "Use to insert the weather forecast at point"
  (let ((w (shell-command-to-string "~/bin/getweather")))
  (insert w)))

Reply to this post
✉️  Reply by email

September 26, 2023