If you are traveling somewhere and want to find out how the weather will be but can’t get your head out of your Linux terminal, if you want to know the forecast for your location, the current temperature, or just if it’s raining and you don’t want to look out the window, we have the perfect solution for you!

All you have to do is perform a curl. curl is a command used to transfer data, mostly to get data from web servers (websites).

By curling wttr.in/city, you will get all the weather data you need for today and the next 2 days in that city. The name of the city is not case sensitive, meaning you can use /NewYork, /NEWYORK, /newyork etc.

Let’s try New York:

# curl wttr.in/newyork

A lot of great information, neatly grouped together, right?

As you can see, the report is for 3 days, starting from the current one. The first info represents the current weather status.

The day is divided into 4 periods, Morning, Noon, Evening, and Night. For each period you can see the general status, temperature, wind direction and speed, visibility, expected precipitations volume (mm/3 hours), and precipitation chances.

If you do not specify a city and you just use curl wttr.in, you will get the report and forecast for the region closest to your detected IP address.
Based on the same location, you will get the metrics in either USCS (Fahrenheit and miles, used by default in the US) or metric SI (Celsius ad kilometers, used outside the US).
You can modify the report as you wish using ?u and ?m.

# curl wttr.in?u # for USCS
# curl wttr.in?m # for metric SI
# curl wttr.in/london?u # London forecast in USCS metrics 

You’re flying from Rome to Los Angeles and want to compare weather data? Absolutely no problem! You just need to use this one-line command:

# diff -Naur <(curl -s http://wttr.in/rome ) <(curl -s http://wttr.in/losangeles )
The first city mentioned in the command, Rome, is on top, and the second city, Los Angeles, is on the bottom.

You can get the forecast in another language in two ways: using ?lang=it at the end or by querying the it subdomain.

# curl wttr.in/milano?lang=it

or

# curl it.wttr.in/milano

will generate the same output:

Weather info for Milano in Italian language

wttr.in is currently translated in 70 languages:
am ar af be ca da de el et fr fa hi hu ia id it lt nb nl oc pl pt-br ro ru tr th uk vi zh-cn zh-tw az bg bs cy cs eo es eu fi ga hi hr hy is ja jv ka kk ko ky lv mk ml mr nl fy nn pt pt-br sk sl sr sr-lat sv sw te uz zh zu he.

Maybe you want or need to use a JSON (JavaScript Object Notation). The JSON format is useful when you want to use the data in a script, software, or maybe to create a custom widget. Adding ?format=j1 at the end will get you just that:

# curl wttr.in/london?format=j1
{
    "current_condition": [
        {
            "FeelsLikeC": "12",
            "FeelsLikeF": "53",
            "cloudcover": "75",
            "humidity": "88",
            "localObsDateTime": "2021-10-15 04:36 AM",
            "observation_time": "03:36 AM",
            "precipInches": "0.0",
            "precipMM": "0.0",
            "pressure": "1017",
            "pressureInches": "30",
            "temp_C": "13",
            "temp_F": "55",
            "uvIndex": "1",
            "visibility": "10",
            "visibilityMiles": "6",
            "weatherCode": "116",
            "weatherDesc": [
                {
                    "value": "Partly cloudy"
                }
            ],
            "weatherIconUrl": [
                {
                    "value": ""
                }
            ],
            "winddir16Point": "W",
            "winddirDegree": "260",
            "windspeedKmph": "19",
            "windspeedMiles": "12"
        }
    ],

If you are a fan of graphs and more data, good news, there is version 2 of the report available at v2.wttr.in. It is used the same, with curl:

# curl v2.wttr.in/newyork

Along with the temperature graph, you get the precipitation expectancy graph, weather general status, wind speed and direction, atmospheric pressure, moon phase, sunrise, and sunset.

A nice trick to get the weather info with just one letter is to run the following command:

echo "W(){ curl -sk wttr.in/madrid; }" >> ~/.bashrc && source ~/.bashrc

Just replace “madrid” with the city of your choice. After running the above command, you will get the weather data just by running W (capital w).

Another ways of getting weather info:

1. ansiweather

In Ubuntu you can install ansiweather:

$ sudo apt-get update
$ sudo apt-get install ansiweather -y

After ansiweather is installed you can type ansiweather -l location:

ansiweather -l London

2. weather-util

$ sudo apt-get update
$ sudo apt-get install weather-util -y

For this package you need to know the weather station ID.

$ weather BKPR
Searching via station...
[caching result Pristina, YG]
Current conditions at <UNKNOWN>
Last updated Oct 15, 2021 - 04:00 AM EDT / 2021.10.15 0800 UTC
   Temperature: 41 F (5 C)
   Relative Humidity: 100%
   Wind: from the N (010 degrees) at 14 MPH (12 KT)
   Weather: light rain
   Sky conditions: overcast

May the weather be with you!