Hacker News new | ask | show | jobs
by taylor-tg 3822 days ago
You could use OpenWeatherMap's API. Something like this is pure (remove the `&units=imperial` if you prefer Celsius):

    curl -s "http://api.openweathermap.org/data/2.5/weather?zip=$(curl -s ipinfo.io/postal),us&appid=2de143494c0b295cca9337e1e96b00e0&units=imperial" \
      | sed -e 's/\(.*\)temp":\([0-9.]*\),\(.*\)/\2/'
or you could replace the `sed` pipe with a call to `jq`:

    curl really_long_url | jq '.main.temp'
1 comments

> remove the `&units=imperial` if you prefer Celsius

That would get you Kelvin, use `&units=metric` for Celsius

Good call! I completely forgot the default units were in Kelvin, and not Celsius.