Coder Social home page Coder Social logo

chubin / wttr.in Goto Github PK

View Code? Open in Web Editor NEW
23.6K 229.0 1.1K 1.7 MB

:partly_sunny: The right way to check the weather

Home Page: https://wttr.in

License: Apache License 2.0

Python 65.76% Shell 4.92% CSS 0.14% HTML 0.59% SaltStack 0.67% Dockerfile 0.38% Go 27.50% Makefile 0.05%
weather-information weather-api curl weather weather-app terminal ascii-art

wttr.in's Introduction

wttr.in — the right way to check curl the weather!

wttr.in is a console-oriented weather forecast service that supports various information representation methods like terminal-oriented ANSI-sequences for console HTTP clients (curl, httpie, or wget), HTML for web browsers, or PNG for graphical viewers.

Originally started as a small project, a wrapper for wego, intended to demonstrate the power of the console-oriented services, wttr.in became a popular weather reporting service, handling tens of millions of queries daily.

You can see it running here: wttr.in.

Documentation | Usage | One-line output | Data-rich output format | Map view | Output formats | Moon phases | Internationalization | Installation

Usage

You can access the service from a shell or from a Web browser like this:

$ curl wttr.in
Weather for City: Paris, France

     \   /     Clear
      .-.      10 – 11 °C
   ― (   ) ―   ↑ 11 km/h
      `-’      10 km
     /   \     0.0 mm

Here is an example weather report:

Weather Report

Or in PowerShell:

Invoke-RestMethod https://wttr.in

Want to get the weather information for a specific location? You can add the desired location to the URL in your request like this:

$ curl wttr.in/London
$ curl wttr.in/Moscow
$ curl wttr.in/Salt+Lake+City

If you omit the location name, you will get the report for your current location based on your IP address.

Use 3-letter airport codes in order to get the weather information at a certain airport:

$ curl wttr.in/muc      # Weather for IATA: muc, Munich International Airport, Germany
$ curl wttr.in/ham      # Weather for IATA: ham, Hamburg Airport, Germany

Let's say you'd like to get the weather for a geographical location other than a town or city - maybe an attraction in a city, a mountain name, or some special location. Add the character ~ before the name to look up that special location name before the weather is then retrieved:

$ curl wttr.in/~Vostok+Station
$ curl wttr.in/~Eiffel+Tower
$ curl wttr.in/~Kilimanjaro

For these examples, you'll see a line below the weather forecast output that shows the geolocation results of looking up the location:

Location: Vostok Station, станция Восток, AAT, Antarctica [-78.4642714,106.8364678]
Location: Tour Eiffel, 5, Avenue Anatole France, Gros-Caillou, 7e, Paris, Île-de-France, 75007, France [48.8582602,2.29449905432]
Location: Kilimanjaro, Northern, Tanzania [-3.4762789,37.3872648]

You can also use IP-addresses (direct) or domain names (prefixed with @) to specify a location:

$ curl wttr.in/@github.com
$ curl wttr.in/@msu.ru

To get detailed information online, you can access the /:help page:

$ curl wttr.in/:help

Weather Units

By default the USCS units are used for the queries from the USA and the metric system for the rest of the world. You can override this behavior by adding ?u, ?m or ?M to a URL like this:

$ curl wttr.in/Amsterdam?u  # USCS (used by default in US)
$ curl wttr.in/Amsterdam?m  # metric (SI) (used by default everywhere except US)
$ curl wttr.in/Amsterdam?M  # metric (SI), but show wind speed in m/s

If you have several options to pass, write them without delimiters in between for the one-letter options, and use & as a delimiter for the long options with values:

$ curl 'wttr.in/Amsterdam?m2&lang=nl'

It would be a rough equivalent of -m2 --lang nl for the GNU CLI syntax.

Supported output formats and views

wttr.in currently supports five output formats:

  • ANSI for the terminal;
  • Plain-text for the terminal and scripts;
  • HTML for the browser;
  • PNG for the graphical viewers;
  • JSON for scripts and APIs;
  • Prometheus metrics for scripts and APIs.

The ANSI and HTML formats are selected based on the User-Agent string.

To force plain text, which disables colors:

$ curl wttr.in/?T

To restrict output to glyphs available in standard console fonts (e.g. Consolas and Lucida Console):

$ curl wttr.in/?d

The PNG format can be forced by adding .png to the end of the query:

$ wget wttr.in/Paris.png

You can use all of the options with the PNG-format like in an URL, but you have to separate them with _ instead of ? and &:

$ wget wttr.in/Paris_0tqp_lang=fr.png

Useful options for the PNG format:

  • t for transparency (transparency=150);
  • transparency=0..255 for a custom transparency level.

Transparency is a useful feature when weather PNGs are used to add weather data to pictures:

$ convert source.jpg <( curl wttr.in/Oymyakon_tqp0.png ) -geometry +50+50 -composite target.jpg

In this example:

  • source.jpg - source file;
  • target.jpg - target file;
  • Oymyakon - name of the location;
  • tqp0 - options (recommended).

Picture with weather data

You can embed a special wttr.in widget, that displays the weather condition for the current or a selected location, into a HTML page using the wttr-switcher. That is how it looks like: wttr-switcher-example or on a real world web site: https://feuerwehr-eisolzried.de/.

Embedded wttr.in example at feuerwehr-eisolzried.de

One-line output

One-line output format is convenient to be used to show weather info in status bar of different programs, such as tmux, weechat, etc.

For one-line output format, specify additional URL parameter format:

$ curl wttr.in/Nuremberg?format=3
Nuremberg: 🌦 +11⁰C

Available preconfigured formats: 1, 2, 3, 4 and the custom format using the percent notation (see below).

You can specify multiple locations separated with : (for repeating queries):

$ curl wttr.in/Nuremberg:Hamburg:Berlin?format=3
Nuremberg: 🌦 +11⁰C

Or to process all this queries at once:

$ curl -s 'wttr.in/{Nuremberg,Hamburg,Berlin}?format=3'
Nuremberg: 🌦 +11⁰C
Hamburg: 🌦 +8⁰C
Berlin: 🌦 +8⁰C

To specify your own custom output format, use the special %-notation:

    c    Weather condition,
    C    Weather condition textual name,
    x    Weather condition, plain-text symbol,
    h    Humidity,
    t    Temperature (Actual),
    f    Temperature (Feels Like),
    w    Wind,
    l    Location,
    m    Moon phase 🌑🌒🌓🌔🌕🌖🌗🌘,
    M    Moon day,
    p    Precipitation (mm/3 hours),
    P    Pressure (hPa),
    u    UV index (1-12),

    D    Dawn*,
    S    Sunrise*,
    z    Zenith*,
    s    Sunset*,
    d    Dusk*,
    T    Current time*,
    Z    Local timezone.

(*times are shown in the local timezone)

So, these two calls are the same:

    $ curl wttr.in/London?format=3
    London: ⛅️ +7⁰C
    $ curl wttr.in/London?format="%l:+%c+%t\n"
    London: ⛅️ +7⁰C

tmux

When using in tmux.conf, you have to escape % with %, i.e. write there %% instead of %.

The output does not contain new line by default, when the %-notation is used, but it does contain it when preconfigured format (1,2,3 etc.) are used. To have the new line in the output when the %-notation is used, use '\n' and single quotes when doing a query from the shell.

In programs, that are querying the service automatically (such as tmux), it is better to use some reasonable update interval. In tmux, you can configure it with status-interval.

If several, : separated locations, are specified in the query, specify update period as an additional query parameter period=:

set -g status-interval 60
WEATHER='#(curl -s wttr.in/London:Stockholm:Moscow\?format\="%%l:+%%c%%20%%t%%60%%w&period=60")'
set -g status-right "$WEATHER ..."

wttr.in in tmux status bar

WeeChat

To embed in to an IRC (WeeChat) client's existing status bar:

/alias add wttr /exec -pipe "/mute /set plugins.var.wttr" url:wttr.in/Montreal?format=%l:+%c+%f+%h+%p+%P+%m+%w+%S+%s;/wait 3 /item refresh wttr
/trigger add wttr timer 60000;0;0 "" "" "/wttr"
/item add wttr "" "${plugins.var.wttr}"
/eval /set weechat.bar.status.items ${weechat.bar.status.items},spacer,wttr
/eval /set weechat.startup.command_after_plugins ${weechat.startup.command_after_plugins};/wttr
/wttr

wttr.in in WeeChat status bar

conky

Conky usage example:

${texeci 1800 curl wttr.in/kyiv_0pq_lang=uk.png
  | convert - -transparent black $HOME/.config/conky/out.png}
${image $HOME/.config/conky/out.png -p 0,0}

wttr.in in conky

Emojis support

To see emojis in terminal, you need:

  1. Terminal support for emojis (was added to Cairo 1.15.8);
  2. Font with emojis support.

For the emoji font, we recommend Noto Color Emoji, and a good alternative option would be the Emoji One font; both of them support all necessary emoji glyphs.

Font configuration:

$ cat ~/.config/fontconfig/fonts.conf
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias>
    <family>serif</family>
    <prefer>
      <family>Noto Color Emoji</family>
    </prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Noto Color Emoji</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>Noto Color Emoji</family>
    </prefer>
  </alias>
</fontconfig>

(to apply the configuration, run fc-cache -f -v).

In some cases, tmux and the terminal understanding of some emoji characters may differ, which may cause strange effects similar to that described in #579.

Data-rich output format (v2)

In the experimental data-rich output format, that is available under the view code v2, a lot of additional weather and astronomical information is available:

  • Temperature, and precipitation changes forecast throughout the days;
  • Moonphase 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.
  $ curl v2.wttr.in/München

or

  $ curl wttr.in/München?format=v2

or, if you prefer Nerd Fonts instead of Emoji, v2d (day) or v2n (night):

  $ curl v2d.wttr.in/München

data-reach output format

(The mode is experimental, and it has several limitations currently:

  • It works only in terminal;
  • Only English is supported).

Currently, you need some tweaks for some terminals, to get the best possible visualization.

URXVT

Depending on your configuration you might be taking all steps, or only a few. URXVT currently doesn't support emoji related fonts, but we can get almost the same effect using Font-Symbola. So add to your .Xresources file the following line:

    xft:symbola:size=10:minspace=False

You can add it after your preferred font and it will only show up when required. Then, if you see or feel like you're having spacing issues, add this: URxvt.letterSpace: 0 For some reason URXVT sometimes stops deciding right the word spacing and we need to force it this way.

The result, should look like:

URXVT Emoji line

Map view (v3)

In the experimental map view, that is available under the view code v3, weather information about a geographical region is available:

    $ curl v3.wttr.in/Bayern.sxl

v3.wttr.in/Bayern

or directly in browser:

The map view currently supports three formats:

  • PNG (for browser and messengers);
  • Sixel (terminal inline images support);
  • IIP (terminal with iterm2 inline images protocol support).

Terminal with inline images protocols support:

Detailed article: Images in terminal

Terminal Environment Images support Protocol
uxterm X11 yes Sixel
mlterm X11 yes Sixel
kitty X11 yes Kitty
wezterm X11 yes IIP
Darktile X11 yes Sixel
Jexer X11 yes Sixel
GNOME Terminal X11 in-progress Sixel
alacritty X11 in-progress Sixel
foot Wayland yes Sixel
DomTerm Web yes Sixel
Yaft FB yes Sixel
iTerm2 Mac OS X yes IIP
mintty Windows yes Sixel
Windows Terminal Windows in-progress Sixel
RLogin Windows yes Sixel

Different output formats

JSON output

The JSON format is a feature providing access to wttr.in data through an easy-to-parse format, without requiring the user to create a complex script to reinterpret wttr.in's graphical output.

To fetch information in JSON format, use the following syntax:

$ curl wttr.in/Detroit?format=j1

This will fetch information on the Detroit region in JSON format. The j1 format code is used to allow for the use of other layouts for the JSON output.

The result will look something like the following:

{
	"current_condition": [
		{
		    "FeelsLikeC": "25",
		    "FeelsLikeF": "76",
		    "cloudcover": "100",
		    "humidity": "76",
		    "observation_time": "04:08 PM",
		    "precipMM": "0.2",
		    "pressure": "1019",
		    "temp_C": "22",
		    "temp_F": "72",
		    "uvIndex": 5,
		    "visibility": "16",
		    "weatherCode": "122",
		    "weatherDesc": [
			{
			    "value": "Overcast"
			}
		    ],
		    "weatherIconUrl": [
			{
			    "value": ""
			}
		    ],
		    "winddir16Point": "NNE",
		    "winddirDegree": "20",
		    "windspeedKmph": "7",
		    "windspeedMiles": "4"
		}
	],
...

Most of these values are self-explanatory, aside from weatherCode. The weatherCode is an enumeration which you can find at either the WorldWeatherOnline website or in the wttr.in source code.

Prometheus Metrics Output

The Prometheus Metrics format is a feature providing access to wttr.in data through an easy-to-parse format for monitoring systems, without requiring the user to create a complex script to reinterpret wttr.in's graphical output.

To fetch information in Prometheus format, use the following syntax:

$ curl wttr.in/Detroit?format=p1

This will fetch information on the Detroit region in Prometheus Metrics format. The p1 format code is used to allow for the use of other layouts for the Prometheus Metrics output.

A possible configuration for Prometheus could look like this:

    - job_name: 'wttr_in_detroit'
        static_configs:
            - targets: ['wttr.in']
        metrics_path: '/Detroit'
        params:
            format: ['p1']

The result will look something like the following:

# HELP temperature_feels_like_celsius Feels Like Temperature in Celsius
temperature_feels_like_celsius{forecast="current"} 7
# HELP temperature_feels_like_fahrenheit Feels Like Temperature in Fahrenheit
temperature_feels_like_fahrenheit{forecast="current"} 45
[truncated]

...

Moon phases

wttr.in can also be used to check the phase of the Moon. This example shows how to see the current Moon phase in the full-output mode:

$ curl wttr.in/Moon

Get the moon phase for a particular date by adding @YYYY-MM-DD:

$ curl wttr.in/Moon@2016-12-25

The moon phase information uses pyphoon as its backend.

To get the moon phase information in the online mode, use %m:

$ curl wttr.in/London?format=%m
🌖

Keep in mind that the Unicode representation of moon phases suffers 2 caveats:

  • With some fonts, the representation 🌘 is ambiguous, for it either seem almost-shadowed or almost-lit, depending on whether your terminal is in light mode or dark mode. Relying on colored fonts like noto-fonts works around this problem.

  • The representation 🌘 is also ambiguous, for it means "last quarter" in northern hemisphere, but "first quarter" in souther hemisphere. It also means nothing in tropical zones. This is a limitation that Unicode is aware about. But it has not been worked around at wttr.in yet.

See #247, #364 for the corresponding tracking issues, and pyphoon#1 for pyphoon. Any help is welcome.

Internationalization and localization

wttr.in supports multilingual locations names that can be specified in any language in the world (it may be surprising, but many locations in the world don't have an English name).

The query string should be specified in Unicode (hex-encoded or not). Spaces in the query string must be replaced with +:

$ curl wttr.in/станция+Восток
Weather report: станция Восток

               Overcast
      .--.     -65 – -47 °C
   .-(    ).   ↑ 23 km/h
  (___.__)__)  15 km
               0.0 mm

The language used for the output (except the location name) does not depend on the input language and it is either English (by default) or the preferred language of the browser (if the query was issued from a browser) that is specified in the query headers (Accept-Language).

The language can be set explicitly when using console clients by using command-line options like this:

curl -H "Accept-Language: fr" wttr.in
http GET wttr.in Accept-Language:ru

The preferred language can be forced using the lang option:

$ curl wttr.in/Berlin?lang=de

The third option is to choose the language using the DNS name used in the query:

$ curl de.wttr.in/Berlin

wttr.in is currently translated into 54 languages, and the number of supported languages is constantly growing.

See /:translation to learn more about the translation process, to see the list of supported languages and contributors, or to know how you can help to translate wttr.in in your language.

Queries to wttr.in in various languages

Installation

To install the application:

  1. Install external dependencies
  2. Install Python dependencies used by the service
  3. Configure IP2Location (optional)
  4. Get a WorldWeatherOnline API and configure wego
  5. Configure wttr.in
  6. Configure the HTTP-frontend service

Install external dependencies

wttr.in has the following external dependencies:

  • golang, wego dependency
  • wego, weather client for terminal

After you install golang, install wego:

go install github.com/schachmat/wego@latest

Install Python dependencies

Python requirements:

  • Flask
  • geoip2
  • geopy
  • requests
  • gevent

If you want to get weather reports as PNG files, you'll also need to install:

  • PIL
  • pyte (>=0.6)
  • necessary fonts

You can install most of them using pip.

Some python package use LLVM, so install it first:

apt-get install llvm-7 llvm-7-dev

If virtualenv is used:

virtualenv -p python3 ve
ve/bin/pip3 install -r requirements.txt
ve/bin/python3 bin/srv.py

Also, you need to install the geoip2 database. You can use a free database GeoLite2 that can be downloaded from (http://dev.maxmind.com/geoip/geoip2/geolite2/).

Configure IP2Location (optional)

If you want to use the IP2location service for IP-addresses that are not covered by GeoLite2, you have to obtain a API key of that service, and after that save into the ~/.ip2location.key file:

$ echo 'YOUR_IP2LOCATION_KEY' > ~/.ip2location.key

If you don't have this file, the service will be silently skipped (it is not a big problem, because the MaxMind database is pretty good).

Installation with Docker

  • Install Docker
  • Build Docker Image
  • These files should be mounted by the user at runtime:
/root/.wegorc
/root/.ip2location.key (optional)
/app/airports.dat
/app/GeoLite2-City.mmdb

Get a WorldWeatherOnline key and configure wego

To get a WorldWeatherOnline API key, you must register here:

https://developer.worldweatheronline.com/auth/register

After you have a WorldWeatherOnline key, you can save it into the WWO key file: ~/.wwo.key

Also, you have to specify the key in the wego configuration:

$ cat ~/.wegorc
{
	"APIKey": "00XXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"City": "London",
	"Numdays": 3,
	"Imperial": false,
	"Lang": "en"
}

The City parameter in ~/.wegorc is ignored.

Configure wttr.in

Configure the following environment variables that define the path to the local wttr.in installation, to the GeoLite database, and to the wego installation. For example:

export WTTR_MYDIR="/home/igor/wttr.in"
export WTTR_GEOLITE="/home/igor/wttr.in/GeoLite2-City.mmdb"
export WTTR_WEGO="/home/igor/go/bin/wego"
export WTTR_LISTEN_HOST="0.0.0.0"
export WTTR_LISTEN_PORT="8002"

Configure the HTTP-frontend service

It's recommended that you also configure the web server that will be used to access the service:

server {
	listen [::]:80;
	server_name  wttr.in *.wttr.in;
	access_log  /var/log/nginx/wttr.in-access.log  main;
	error_log  /var/log/nginx/wttr.in-error.log;

	location / {
	    proxy_pass         http://127.0.0.1:8002;

	    proxy_set_header   Host             $host;
	    proxy_set_header   X-Real-IP        $remote_addr;
	    proxy_set_header   X-Forwarded-For  $remote_addr;

	    client_max_body_size       10m;
	    client_body_buffer_size    128k;

	    proxy_connect_timeout      90;
	    proxy_send_timeout         90;
	    proxy_read_timeout         90;

	    proxy_buffer_size          4k;
	    proxy_buffers              4 32k;
	    proxy_busy_buffers_size    64k;
	    proxy_temp_file_write_size 64k;

	    expires                    off;
	}
}

wttr.in's People

Contributors

akai54 avatar amadeogarcia avatar appledora avatar casperl avatar chubin avatar dvergur avatar fbitti avatar fredrikfjeld avatar gregdan3 avatar janesmae avatar jinnatar avatar jmcastagnetto avatar kainengr avatar layerex avatar magiccc avatar mpetruska avatar mrfrosty avatar mrueg avatar mufasa71 avatar nakanakaii avatar oxbar avatar pavse avatar petewg avatar quenty-tolosan avatar rootkit7628 avatar ryunix avatar sanketgarade avatar supersandro2000 avatar tupanegreiros avatar volkanto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wttr.in's Issues

Option for shorter output.

It would be great to have options for shorter/longer output. Like:

$ curl 'http://wttr.in/?now'
               Overcast 
      .--.     64 °F          
   .-(    ).   ↑ 18 mph       
  (___.__)__)  9 mi           
               0.0 in   

Another one I would use is curl http://wttr.in/?week, where just a 5 day forecast it shown with only one row of output.

I'm sorry I don't have a pull request to go with this. I just wanted to put the idea out there.

Looks badly proportioned in browser(Chrome).

overview

When I access using browser, the layout is badly proportioned, like this capture.
(even pre tag and font-family:monospacehas been already enable.)

fireshot capture 5 - - http___wttr in_

env

[OS] OS X Yosemite v10.10.2
[browser] Google Chrome v48

Negative test. Failed to substitute unknown location as Oymyakon.

Hello, i was looking into code and decided to perform some tests :)

Test command:
$ curl wttr.in/SomeVillage
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5 100 5 0 0 15 0 --:--:-- --:--:-- --:--:-- 15ERROR

Expected result:
It seems from code that in case of unknown location service should return following text:
"""
We were unable to find your location,
so we have brought you to Oymyakon,
one of the coldest permanently inhabited locales on the planet.
"""

Actual result:
$ curl wttr.in/SomeVillage
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5 100 5 0 0 15 0 --:--:-- --:--:-- --:--:-- 15ERROR

But I see weather report for Oymyakon if i type "$ curl wttr.in/NOT_FOUND"

Environment: Windows 10 x64, mintty 2.0.3 (x86_64-pc-msys)

Misaligned HTML and badly formed HTML

Suggestion: Why not use custom tags for the color, easier to write and read.
<c1b33> or <yellow>
The stylesheet will become more readable too:
yellow { color: yellow; }

No further styling or tricks would be needed and you don't have to set fonts, you can simply wrap it all in a <pre> tag.

wttr misalignment

wttr.in has no AAAA record

Your example http config suggests you're listening externally on IPv6 and IPv4, but wttr.in only has an A record. I can only reach it from some of my machines.

sds@stkilda:~$ host -t aaaa wttr.in
wttr.in has no AAAA record
sds@stkilda:~$ host -t a wttr.in
wttr.in has address 5.9.243.177

Dark background color

Any chance of explicitly setting background color of output to dark background color? Visuals can be unreadable on light terminal themes.

screen shot 2016-02-20 at 12 38 17

keep it running

making donation through bountysource

thanks for correcting autolocation problems

wttr.in site in imperial units?

I've checked the docs and tried a few things but still get Celcius temperatures. Is there a flag to pass in the URL to switch to Fahrenheit?

Wind speed formatting issue

When the min and max wind speeds are both 2 digits, the line formatting becomes pushed to the right and causes mismatched ASCII images.

wttr_wind_speed

[ISSUE]Macedonian is made in Bulgarian

I got data for my city Skopje which is in the Republic of Macedonia but the website gives the text in Bulgarian.

Bulgarian and Macedonian may have the same roots but we have different letters and it's a different language and as younger people try to look at sites they don't understand Bulgarian.

You can add an option to choose the language it'd be really nice

and probably try translating it to Macedonian. If you need help DM me on Twitter or i'll submit them here

Location problem

Hello,

I really like the ascii weather and i typed "curl wttr.in" at terminal.

Unfortunately the output is;

Weather for City: Kartal, Hungary (I reside in Istanbul)

I know curl wttr.in/Istanbul returns the correct result but what is the reason for the hungary result?
First I think the reason arises from zenmate but they did not have correlation between them.

This is amazing

Sorry for filing a non-issue but I think it needs to be said, this application is amazing and you are amazing developers for sharing it with the world. I dream of a world wide web that is browsable from curl.

Thank you!

Fahrenheit?

Is there any option to have all temps displayed in Fahrenheit, instead of Celsius? Or possibly added in the future?

boarder shifting problem

Weather for City: Kiel, Germany

     \   /     Sunny
      .-.      21 – 22 °C     
   ― (   ) ―   ↖ 11 km/h      
      `-’      10 km          
     /   \     0.0 mm         
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Thu 23. Jun ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│     \   /     Sunny          │  _`/"".-.     Patchy rain ne…│  _`/"".-.     Moderate or he…│  _`/"".-.     Moderate or he…│
│      .-.      21 – 22 °C     │   ,\_(   ).   28 – 30 °C     │   ,\_(   ).   27 – 28 °C     │   ,\_(   ).   24 – 25 °C     │
│   ― (   ) ―   ↖ 11 – 19 km/h │    /(___(__)  ↖ 24 – 25 km/h │    /(___(__)  ↑ 11 – 26 km/h │    /(___(__)  ↖ 14 – 31 km/h │
│      `-’      10 km          │      ‘ ‘ ‘ ‘  10 km          │    ‚‘‚‘‚‘‚‘   7 km           │    ‚‘‚‘‚‘‚‘   7 km           │
│     /   \     0.0 mm | 0%    │     ‘ ‘ ‘ ‘   0.1 mm | 83%   │    ‚’‚’‚’‚’   4.1 mm | 92%   │    ‚’‚’‚’‚’   2.8 mm | 91%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Fri 24. Jun ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│  _`/"".-.     Patchy light r…│      .-.      Moderate or he…│  _`/"".-.     Thundery outbr…│  _`/"".-.     Patchy rain ne…│
│   ,\_(   ).   23 – 24 °C     │     (   ).    26 – 27 °C     │   ,\_(   ).   23 – 24 °C     │   ,\_(   ).   21 °C          │
│    /(___(__)  ↑ 8 – 15 km/h  │    (___(__)   ↑ 14 – 17 km/h │    /(___(__)  ↖ 9 km/h       │    /(___(__)  → 12 – 23 km/h │
│     ⚡‘ ‘⚡‘ ‘  10 km          │   ‚‘⚡‘‚⚡‚‘    9 km           │     ⚡‘ ‘⚡‘ ‘  9 km           │      ‘ ‘ ‘ ‘  9 km           │
│     ‘ ‘ ‘ ‘   1.9 mm | 62%   │   ‚’‚’⚡’‚’    1.0 mm | 100%  │     ‘ ‘ ‘ ‘   0.1 mm | 63%   │     ‘ ‘ ‘ ‘   0.6 mm | 19%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Sat 25. Jun ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│  _`/"".-.     Patchy rain ne…│      .-.      Patchy light r…│      .-.      Light rain     │  _`/"".-.     Patchy rain ne…│
│   ,\_(   ).   20 °C          │     (   ).    18 – 19 °C     │     (   ).    18 – 19 °C     │   ,\_(   ).   12 °C          │
│    /(___(__)  ↘ 12 – 14 km/h │    (___(__)   ↘ 13 – 18 km/h │    (___(__)   ↘ 14 – 18 km/h │    /(___(__)  ↘ 13 – 25 km/h HERE THE BOARDER SHIFTS RIGHT│
│      ‘ ‘ ‘ ‘  10 km          │     ‘ ‘ ‘ ‘   10 km          │     ‘ ‘ ‘ ‘   10 km          │      ‘ ‘ ‘ ‘  10 km          │
│     ‘ ‘ ‘ ‘   0.1 mm | 78%   │    ‘ ‘ ‘ ‘    1.0 mm | 100%  │    ‘ ‘ ‘ ‘    1.0 mm | 100%  │     ‘ ‘ ‘ ‘   0.1 mm | 74%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
      ```

Simple caching

If you are running into the 1M query limit, why not implement some sort of caching?

Maybe something like

weather = {
        {'city': 'Halifax', weather_info: ..., 'cached': datestamp}
        , ... 
        }

Only requery if the info is 30 minutes old - or even then are you seeing issues?

mimetype is always html

The server always sends "Content-Type: text/html; charset=utf-8", even when the content clearly is not HTML. See curl -I wttr.in.

It works, but wouldn't it be nicer to send "text/plain" when it's just text, not HTML?

504 Timeout

curl wttr.in/nuremberg

<title>504 Gateway Time-out</title>

504 Gateway Time-out


nginx/1.2.6

State should be mentioned

Weather for City: Portola Valley, United States of America should probably be Weather for City: Portola Valley, CA, United States of America

wttr.in out of datasource capacity

Love the service and the text weather!
Just found this project after installing LXLE.

I'm not sure what the datasource capacity is. Based on the error message on your webpage, it sounds like it could be 1M queries per day.

Doing some quick math, you can serve up

  • 11 different locations once per second for 24 hours
  • 57 different locations once per 5 seconds for 24 hours

I'd be curious to see the traffic log and see how many different locations are being served and at what rate. If a lot of traffic comes from a few locations, caching either using srv.py or at the client could help. Weather doesn't change by the second usually, so it might be useful to cache weather for between 5 seconds and 5 minutes to reduce the number of queries sent to your datasource.

I may try to implement something like that given some time free after my day job :)

Bug when requesting Sao Paulo

When I make a request for Sao Paulo city, it says the following:

$ curl wttr.in/Sao%20Paulo
  'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

But when I ask for Ribeirao Preto, it works:

curl wttr.in/Ribeirao%20Preto
Weather for City: Ribeirao Preto, Brazil

    \  /       Partly Cloudy
  _ /"".-.     23 – 25 °C
    \_(   ).   ↓ 19 km/h
    /(___(__)  10 km
               0.6 mm

Unable to show weather data on Windows console

The console is not able to display data returned by curl wttr.in. It's all garbled. I know it's a Windows problem but do you have any suggestions on how can I make it work.

I even tried an external console emulator, ConEmu. No luck there too.

[Feature Request] tide level

First of all this is amazing! Thank you so much :)
I just thought it would be awesome to have tide levels showing as well, given their relation to the moon phases. Thanks again

Sunny night?

I just get the following forecast:

                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Wed 05. Oct ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│      .-.      Light rain     │      .-.      Light drizzle  │  _`/"".-.     Patchy rain po…│     \   /     Clear          │
│     (   ).    15 °C          │     (   ).    17 °C          │   ,\_(   ).   18 °C          │      .-.      13 – 14 °C     │
│    (___(__)   ↗ 32 – 43 km/h │    (___(__)   ↑ 40 – 51 km/h │    /(___(__)  ↑ 26 – 37 km/h │   ― (   ) ―   ↑ 15 – 29 km/h │
│     ‘ ‘ ‘ ‘   9 km           │     ‘ ‘ ‘ ‘   2 km           │      ‘ ‘ ‘ ‘  9 km           │      `-’      10 km          │
│    ‘ ‘ ‘ ‘    0.8 mm | 84%   │    ‘ ‘ ‘ ‘    0.3 mm | 85%   │     ‘ ‘ ‘ ‘   0.2 mm | 71%   │     /   \     0.0 mm | 1%    │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘

If the night will be "clear", shouldn't it show a moon instead of a sun?

Localized weather data

Is it possible? Perharbs as auto detection/ "-locale_code" argument?

If weather server does not provide it, we can translate it manually I think.

darksky.net

With the original backend making api's pay only I feel throwing the suggesting of implementing dark sky would be a good option.

The only thing that would be needed is to have it push coords instead of a city name, but will prove unreliable when it comes to accurate locations

"ERROR" response when featching weather for Warsaw

I got "ERROR" in response when calling weather for Warsaw. Other cities works fine.

curl -i wttr.in/Warsaw                                                     
HTTP/1.1 200 OK
Server: nginx/1.9.14
Date: Wed, 12 Oct 2016 11:43:36 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 5
Connection: keep-alive

ERROR⏎  

JSON frontend support

Hi, i love wttr.in and have been using it for a lot of personal projects lately. I believe wego supports JSON as an output (specified as a "frontend", though I haven't tested this personally). It would be awesome if wttr.in could support JSON output (or specifying any arbitrary frontend I suppose)... maybe something like:

  • GET /Buffalo - buffalo ny weather
  • GET /Buffalo?frontend=json - buffalo ny weather with -f json passed to the wego command

There might need to be some extra processing by wttr.in to specify the appropriate headers to the requesting client to let it know the response is JSON.

If there is interest in this I can take a look at the code and see what I can do

Support different terminal widths

I wonder if you could add an option to specify the width of your terminal so that the tables are always pretty printed. Something like:

$ curl "wttr.in/?w=WIDTH"

This would make it possible to use tput cols or the COLUMNS environment variable to always have pretty printed tables!

With different WIDTHs we would have:

WIDTH >= 125:

                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Wed 25. Jan ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│     \   /     Sunny          │     \   /     Sunny          │               Cloudy         │      .-.      Light drizzle  │
│      .-.      10 – 11 °C     │      .-.      15 °C          │      .--.     11 – 12 °C     │     (   ).    10 – 12 °C     │
│   ― (   ) ―   ↖ 7 – 9 km/h   │   ― (   ) ―   ↑ 13 – 14 km/h │   .-(    ).   ↑ 14 – 22 km/h │    (___(__)   ↑ 15 – 24 km/h │
│      `-’      10 km          │      `-’      10 km          │  (___.__)__)  10 km          │     ‘ ‘ ‘ ‘   2 km           │
│     /   \     0.0 mm | 0%    │     /   \     0.0 mm | 0%    │               0.0 mm | 0%    │    ‘ ‘ ‘ ‘    0.5 mm | 95%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘

63 <= WIDTH < 125:

                        ┌─────────────┐
┌───────────────────────┤ Wed 25. Jan ├───────────────────────┐
│           Morning     └──────┬──────┘      Noon             │
├──────────────────────────────┼──────────────────────────────┤
│     \   /     Sunny          │     \   /     Sunny          │
│      .-.      10 – 11 °C     │      .-.      15 °C          │
│   ― (   ) ―   ↖ 7 – 9 km/h   │   ― (   ) ―   ↑ 13 – 14 km/h │
│      `-’      10 km          │      `-’      10 km          │
│     /   \     0.0 mm | 0%    │     /   \     0.0 mm | 0%    │
├──────────────────────────────┼──────────────────────────────┤
│           Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┤
│               Cloudy         │      .-.      Light drizzle  │
│      .--.     11 – 12 °C     │     (   ).    10 – 12 °C     │
│   .-(    ).   ↑ 14 – 22 km/h │    (___(__)   ↑ 15 – 24 km/h │
│  (___.__)__)  10 km          │     ‘ ‘ ‘ ‘   2 km           │
│               0.0 mm | 0%    │    ‘ ‘ ‘ ‘    0.5 mm | 95%   │
└──────────────────────────────┴──────────────────────────────┘

WIDTH < 63 (only looks good if WIDTH >= 32):

┌─────────────┐
│ Wed 25. Jan │
├─────────────┴────────────────┐
│           Morning            │
├──────────────────────────────┤
│     \   /     Sunny          │
│      .-.      10 – 11 °C     │
│   ― (   ) ―   ↖ 7 – 9 km/h   │
│      `-’      10 km          │
│     /   \     0.0 mm | 0%    │
├──────────────────────────────┤
│             Noon             │
├──────────────────────────────┤
│     \   /     Sunny          │
│      .-.      15 °C          │
│   ― (   ) ―   ↑ 13 – 14 km/h │
│      `-’      10 km          │
│     /   \     0.0 mm | 0%    │
├──────────────────────────────┤
│           Evening            │
├──────────────────────────────┤
│               Cloudy         │
│      .--.     11 – 12 °C     │
│   .-(    ).   ↑ 14 – 22 km/h │
│  (___.__)__)  10 km          │
│               0.0 mm | 0%    │
├──────────────────────────────┤
│            Night             │
├──────────────────────────────┤
│      .-.      Light drizzle  │
│     (   ).    10 – 12 °C     │
│    (___(__)   ↑ 15 – 24 km/h │
│     ‘ ‘ ‘ ‘   2 km           │
│    ‘ ‘ ‘ ‘    0.5 mm | 95%   │
└──────────────────────────────┘

Note: I aligned the date in this last example to the left, but maybe try something else! :-D

What are your thoughts on this?

Location problem, Isfahan is a city of Iran not Afghanistan

Hi,
When I try to see Isfahan weather, the output return Afghanistan country instead of Iran.

hypermit@hp ~> curl wttr.in/isfahan
Weather for City: Isfahan, Afghanistan

           Blowing Widespread Dust
  .--.     10 – 13 °C     

.-( ). → 43 km/h
(.)_) 3 km
0.0 mm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.