Home » Showing current weather info on posts

Beto Dealmeida's avatar

Showing current weather info on posts

Using the wttr.in API to display current weather information on posts

Current weather: 21°C (Haze, smoke)

I created a new assistant for my blog that fetches the current weather information, and stores it together with the post in a file called weather.json. The JSON file can then be used by the template that generates each post.

I'm fetching weather from wttr.in[archived], which is a fantastic website that provides weather data programmatically. It figures out your location based on the IP address, and can be used with curl to provide a nice login message on your computer — try it out:

$ curl wttr.in

The fact that it automatically detects the location makes it perfect for my needs.

Comments

You can engage with this post on Twitter or Webmention.