diff --git a/README.md b/README.md index d17c384..0289676 100644 --- a/README.md +++ b/README.md @@ -77,12 +77,13 @@ You can override this behavior by adding `?u` or `?m` to a URL like this: ## Supported output formats -wttr.in currently supports three output formats: +wttr.in currently supports four output formats: * ANSI for the terminal; * ANSI for the terminal, one-line mode; * HTML for the browser; -* PNG for the graphical viewers. +* PNG for the graphical viewers; +* JSON for scripts and APIs. The ANSI and HTML formats are selected basing on the User-Agent string. The PNG format can be forced by adding `.png` to the end of the query: @@ -112,6 +113,53 @@ In this example: ![Picture with weather data](https://pbs.twimg.com/media/C69-wsIW0AAcAD5.jpg) +## 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](https://www.worldweatheronline.com/developer/api/docs/weather-icons.aspx) or [in the wttr.in source code](https://github.com/chubin/wttr.in/blob/master/lib/constants.py). + ## One-line output For one-line output format, specify additional URL parameter `format`: