Washington

wttr.in – curl the weather

Most people think of weather in terms of temperature, humidity, precipitation, cloudiness, brightness, visibility, wind, and atmospheric pressure, as in high and low pressure. In most places, weather changes from minute-to-minute, hour-to-hour, day-to-day, and season-to-season.

wttr.in is a console-based weather forecast service that offers lots of options including various information representation methods. These include terminal-oriented ANSI-sequences for console HTTP clients, HTML for web browsers, or PNG for graphical viewers.

This is free and open source software.

Installation

All your system needs is a console HTTP client such as curl, wget or HTTPie. One or all of them is probably already present on your Linux machine.

However, you can also locally host the software. The project’s GitHub page explains the installation process. Basically, you need to install the program’s external dependencies (golang and Wego), and various Python dependencies. You’ll also need a WorldWeatherOnline key and optionally an API key for IP2Location. But, if you just want to access weather forecasts, you can use curl.

In Operation

To grab a 3 day forecast for London, we can simply type the command:

$ curl wttr.in/London

3 day weather forecast
Click image for full size

As the image shows, the forecast for each day is divided into morning, noon, evening, and night segments. We can see the forecasted temperature, wind speed and direction, amount of precipitation and its probability.

If you want to use wget instead of curl, replace $ curl with $ wget -O- -q

Replace London with any location of your choice. Or you can use special location names by adding the ~/code> character.

Besides specifying a location using the city name, we can also use the 3-letter airport code, area code, GPS coordinates, IP address, or domain name.

There’s also a data rich output format available. Let’s look up the forecast again for London with this different output format.

$ curl v2.wttr.in/London

Data-rich output format (v2)

As you can see, there’s a whole raft of additional weather and astronomical information provided:

  • Temperature, and precipitation changes forecast throughout the days.
  • Moon phase for today and the next three days.
  • The current weather condition, temperature, humidity, wind speed and direction, pressure.
  • Timezone.
  • Dawn, sunrise, noon, sunset, dusk time for he selected location.
  • Precise geographical coordinates for the selected location.

There’s also an experimental v3 map view forecast available which works with many terminal emulators, but this is currently not working as the service is running out of queries.

What else is available?

  • 5 output formats: ANSI for the terminal, plain-text, HTML for the browser, JSON for scripts and APIs, and PNG.
  • One-line output.
  • Emoji support.
  • Choose the weather units: USCS units for the USA and the metric system for elsewhere but this can be overridden.
  • Internationalization support with support for 54 languages.

Summary

wttr.in is a popular weather reporting service, handling millions of queries daily. But what many users of the service don’t realize is that as it’s open source software, you can self-host the software.

The software is powered by Wego, a very handy utility for accessing weather information from the terminal. If you need a quick weather forecast and prefer to avoid web-based services, give it a whirl.

For other useful terminal-based weather tools, check out our roundup.

Website: github.com/chubin/wttr.in
Support:
Developer: Igor Chubin
License: Apache License 2.0

wttr.in is written in Python and Go. Learn Python with our recommended free books and free tutorials. Learn Go with our recommended free books and free tutorials.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Please read our Comment FAQ before posting a comment.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments