wttr.in
wttr.in copied to clipboard
Oneline output mode?
I'd like to use this for my status bars (dvtm and bar) but there doesn't seem to be a clean oneline output mode. Maybe we could specify a format in the header and get data returned back?
Yes, it is planned, I wanted to implement it, but now after this request I'll do it even faster. What data would you like to have first?
If you want some help I'd be happy to oblige.
I'd like to be able to send a header field like {city} {weather} {temperature} and get a response with the localized data.
Yes, it was exactly the plan, but I see one small problem here: what about forecast? I mean how do you want to code forecast period that you want to get?
Probably something like de.wttr.in/Berlin?line_current="weather temp wind"
and instead of line_current, you can write line_spark4h, {{line_spark1d, line_spark3d`
(spark for sparklines similar to the sparklines in rate.sx; curl rate.sx to see what I mean)
But I'm not sure. It's not really nice. Do you have other ideas may be?
(and thank you very much for your help offer)
out of curiosity, is there an update for this? I would like to add it to my bash shell so it outputs the line to my bash terminal when i login to my computer
@poserman Not yet, but it will be released soon and even better, if you are a tmux user, you can add it to your tmux status line
Not a tmux user myself, but that would help people. Thank you for the update.
I just wanted to open the exact same issue. I would be interested in using this in my i3 status bar. Combined with UTF8 characters this could look really great and still be simple:
Berlin: party sunny, 1 hour of sun, between 5-12°, windy, 10% chance of rain
or with UTF8 characters:
Berlin: :partly_sunny: 1h, :thermometer:5-12°, :wind_face: 8-9km/h, ☔10%
Thanks for your work on this in general!
@poserman Not yet, but it will be released soon and even better, if you are a tmux user, you can add it to your tmux status line
Hi chubin ! I would like very much to integrate it in my tmux bar, really excited about this feature :)
Hi everybody! Sorry for the silence, I will implement it on this weekend.
I've added initial support of oneline output mode.
Please test it:
$ curl wttr.in/Berlin?format=1
⛅ +5⁰C
$ curl wttr.in/Berlin?format=4
Berlin: ⛅ 🌡️+5⁰C 🌬️↓9 km/h
$ curl wttr.in/Berlin?format=%l:+%t
berlin: +5⁰C
How does it work?
To use the oneline mode, specify a special URL parameter format.
It can have parameters of two types:
- number of predefined format string;
- format string.
Format string is a normal string, where all characters (including Unicode symbols) have their literal meaning, except special sequences starting with %. This sequences are interpreted as special weather data placeholders.
Currently 4 format symbols are supported:
t— temperature;w— wind;l— location;c— weather condition symbol.
Format sequences are always starting with % and ending with one of the special characters:
%w%2=t
(currently all characters between them are ignored; but they will be used as data symbol options in future).
Example of format strings:
It is %c in %l now.%t %w%l: %c %t
There are several preconfigured formats now, but there will be more (feel free to add you own, here or with pull requests):
PRECONFIGURED_FORMAT = {
'1': u'%c %t',
'2': u'%c 🌡️%t 🌬️%w',
'3': u'%l: %c %t',
'4': u'%l: %c 🌡️%t 🌬️%w',
}
It is just an initial implementation, and many things are to be implemented yet, but you already can start playing and experimenting with it.
- Do you like this one line formatter?
- What features are you missing?
@h-2 Can you please try to integrate it in your i3 status bar? @patrickelectric Can you please try to integrate it in your tmux status line?
Looks nice already! Thanks!
I was trying to test it here, but curl wttr.in/Berlin\?line\=1 returns the wttr normal output for me.
@patrickelectric It is format=, not line=; excuse me for the confusion.
Perfect ! ty very much !

@patrickelectric It looks megacool! But we should extend it. For example, currently it shows only current weather, but not weather forecast. Another cool thing to have would be to have weather report for several locations.
Could you please share your code with us? (I mean the wttr.in related part)
@h-2 Hannes, could you please share your config (wttr.in related part) with us too? Let us make a small collection for the documentation.
Thank you, I'll try to share my setup soon.
# curl -s wttr.in/Florianopolis\?format\="%c%20%t%20%w"
WEATHER='#(curl -s wttr.in/Florianopolis\?format\="%%c%%20%%t%%20%%w")'
set -g status-right "$WEATHER #[bg=colour239]#[fg=white] %a %b %-d#[fg=colour14] | #[fg=white]%H:%M #[fg=black,bg=colour14] #h "
For a first version, it's awesome already ! Of course que some advanced users will want forecast for the next days, but for a first version is perfect !
@patrickelectric Thank you for sharing your config.
Several questions:
- Should we use
{}instead of%maybe? (or support moth of them?) - Why you use
%%20instead of+? - What do you think about colors in the wttr.in output? I would like to add them.
Now you can specify several locations in one query,
they will be rotating in the output (with specified period, 1 sec by default):
wttr.in/London:Berlin:Moscow?format=3&period=20
To use this feature tmux.conf, status-interval should be set:
set -g status-interval 20
It is ok to use 20 sec to test, but for real life it can be set 60 or even more
But we should extend it. For example, currently it shows only current weather, but not weather forecast.
Absolutely, that's what I wanted to propose next, as well! maybe current(day-min/day-max) would be a good default format!
Should we use {} instead of % maybe? (or support moth of them?)
I don't care either way
What do you think about colors in the wttr.in output? I would like to add them.
Would be cool!
Now you can specify several locations in one query,
I am not too interested in specifying multiple at once, but did you consider the possibility that one does not give any location and your server resolves the GeoIP to the nearest location? That would be awesome for notebooks!
@h-2 Hannes, could you please share your config (wttr.in related part) with us too? Let us make a small collection for the documentation.
i3status.conf does not support running external command directly so you have to do the following:
First create ~/bin/my_i3status and make it executable:
#!/bin/sh
i3status | while :
do
read line
# musicpd
time=$(mpc status | awk 'NR==2 { print $3 }')
playing=$(ncmpcpp --current-song="%a - %n - %t (${time})")
# wttr.in
weather=$(curl wttr.in/Berlin?format=4)
# generate actual status bar content by prefixing the above
echo "$weather | 🎶 $playing | $line" || exit 1
done
And then edit your .config/i3/config:
# ....
bar {
# run your custom command instead of i3status
status_command my_i3status
tray_output primary
# choose a fallback font that has emojis
font pango:Fira Code 13, Droid Sans 13
}
# ...
Hi @chubin,
Here is the full script to install and setup my tmux: link
I'm ok with %, but it can add some problem with bash~, some users will need to search for problems related to %->% and ' ' to %20 or +. I manually add the colors in my toolbar so I don't know if a color feature is necessary. And I'm using cron to setup the curl script timer :) I prefer to control each information timer by it.
I haven't checked, but is {} actually much better than %? % seems more conventional. Also { and } are actually Bash syntax chars, so I'm not sure they are safer. (I do agree the URL encoding makes the format string with %'s ugly, but can you really avoid it if the field is free-form?)
Just my $0.02...
On 13. Dec 2018 09:42, Patrick José Pereira wrote:
@chubin the inline output is not working anymore ?
@patrickelectric
It should work. Why?
-- Igor Chubin
Is there a way to get the temperature in dirty American units? I don't have the head for metric temperatures.
@robojeb For the one-line mode?
For the normal mode you just add ?u to the end of query:
curl wttr.in/?u
@chubin Yes for the one-line mode. Sorry I should have been more specific.
It appears one line mode doesn't take into account location or the ?u specifier.
@robojeb
If it does not work automatically, just add &u to the list of the parameters, like here:
$ curl 'wttr.in/Nuremberg?format=3&u'
Nuremberg: 🌦 +39⁰F
Interesting, I thought I tried that earlier but it didn't seem to work for me.
@robojeb Yes, it did not work before indeed. I've just implemented it. It should work without &u also by the way (if you are located in the US)
Thanks very much!
I don't think this warrants making another thread but there is an issue with one-line mode. It returns the query instead of the location name. That is, if you query wttr.in like so: wttr.in/jacksonville?format=4
You get output, e.g. jacksonville: ☁️ 🌡️+15⁰C 🌬️↙22 km/h, whereas with the other format modes you would get "Jacksonville, United States of America". This is important because sometimes there is ambiguity with cities having the same name. Perhaps showing state (e.g. Florida) might also be useful.
Out of curiosity I queried wttr.in with wttr.in/etc?format=4 and got the response etc: ⛅️ 🌡️+17⁰C 🌬️↑4 km/h. If your query instead looks like this wttr.in/etc?0, it turns out there is a city called Etchojoa, Mexico.
Cheers.
@jherrera It is actually intentionally. The problem is that contrary to the normal output, with the line output you often want to embed the output information somewhere (say, tmux status bar); and you want to keep it short. So the idea was to have the same location name in the output as it was specified. And to check, if it is being resolved correctly you can always use the full version.
I understand the reasoning behind it. May I suggest adding a way to retrieve the "good" location name? Perhaps with %L (capital L).
Format doesn't respect "M" option. For example, curl 'wttr.in/?format=2&M' still shows wind speed in km/h instead of m/s.
@gitvb Thank you for reporting! It should work now:
~$ curl 'wttr.in/London?format=4&M'
London: ⛅️ 🌡️+14°C 🌬️→8.3 m/s
~$ curl 'wttr.in/London?format=4'
London: ⛅️ 🌡️+14°C 🌬️→30 km/h
Today I found this while setting up conky. I would prefer to be able to utilize the one-liners for forecast data too. Is this still in the works?
Thanks for this @chubin, it will be great if we get the rain info too if possible at least the percentage of having rain maybe as %r or something
@dubl3a Yes, it is a very useful feature, and it will be added soon @ahmedelgabri Ahmed, accepted!
I've a couple issues that I'd like to see rectified:
- The emoji output is fine, but it'd be better if we could disable the variation sequence (converts the text-font version to the icon version).
- Colorized one-line output. While most folks will override the colors in a status line, I like the colorization already employed for blue for cold and red for hot, and don't want to implement my own system of interpreting the temperatures/speeds/rain chance to colors.
Any way to show 3 days forecast in one line ?
Same here, it would be nice to generate in one line something like: Kazan Sep 18: 9/2C - Sep 19: 10/0C - Sep 20: 9/0C
With day and night temp.
Yes, it is #329 It will be added