In the next article we are going to take a look at wttr.in. This is a weather forecast service which is going to offer us some cool features. It will allow us to consult the weather from the command line in a simple and fast way.
The program can automatically detect our location (according to our IP address), we will also be able to specify the location or search for a geographic location (cLike a monument, a mountain, etc.) and much more. But best of all, is that we will not have to install it. All we are going to need is cURL or Wget.
General features of wttr.in
- This program we displays current weather and a 3-day weather forecast. This is divided into morning, noon, afternoon and night. Also included are the temperature range, wind speed and direction, amount of precipitation and its probability.
- On the GitHub page they tell us that we can see the lunar phases of each of the days.
- We can use the automatic detection of a location based on IP address.
- We will be able to specify a location using the city name, 3-letter airport code, area code, GPS coordinates, IP address or domain name. We will also have the ability to specify a geographic location like a lake, a mountain or a landmark.
- Admits multilingual location names. In this case, the query string must be specified in Unicode.
- Another feature available will be the ability to specify the language in which the weather forecast should be displayed. Supports more than 50 languages.
- Use units USCS for US inquiries and the metric system for the rest of the world. This can be changed by adding ? u for USCS y ? m for the metric system.
- We will have 3 output formats: ANSI for the terminal, HTML for the browser and PNG.
Using Wttr.in
As mentioned at the beginning of the post, to use wttr.in, all we need is cURL or Wget, but we will also be able to install it on our own server to perform inquiries from the web.
Before using wttr.in, we will have to make sure that cURL is installed on our computer. In Debian, Ubuntu or Linux Mint, we will be able to install cURL using this command in the terminal (Ctrl + Alt + T):
sudo apt install curl
Some examples of wttr.in
Shows the weather according to our IP
The program shows us the weather for our location. Try to guess our location based on the IP address. In my case I have to say that due to the location of my internet provider, it has failed for a few kilometers.
curl wttr.in
Wget It can also help us, instead of cURL, if we want to check the current weather:
wget -O- -q wttr.in
In all the commands that will be shown below, we will be able to replace curl with wget -O- -q if we prefer Wget over cURL.
The time of a location
We can ask the program to show us the weather of a certain location by passing it the name of this in the command:
curl wttr.in/lepe
The time of a landmark
Displays the weather information for a landmark or monument. For this example we will see the time that we will find ourselves in the Aqueduct of Segovia with the following command:
curl wttr.in/~Acueducto+Segovia
The time of a location according to its IP
We will have the option of obtaining the weather information for the location of an IP address. The IP used in this example belongs to Google:
curl wttr.in/@216.58.211.35
The time saved in a .png image
We can use Wget to download Current weather and 3-day forecast as a PNG image. We can also specify the transparency level PNG. For this example, curl won't work.
wget wttr.in/Madrid.png
Other examples
To know other examples, we can go to the GitHub page of the wttr.in project. We will also have useful information by typing the following in a terminal (Ctrl + Alt + T):
curl wttr.in/:help