An open API service indexing awesome lists of open source software.

https://github.com/jvillegasd/weather-go

Check the weather easily with emojis and moon phase!
https://github.com/jvillegasd/weather-go

express-js moon-phase node-emoji node-js openweathermap openweathermap-api wrapper-api

Last synced: 21 days ago
JSON representation

Check the weather easily with emojis and moon phase!

Awesome Lists containing this project

README

        

# Weather-Go!

Weather-Go is wrapper for OpenWeatherMap API. This project is inspired by [wttr](https://github.com/chubin/wttr.in).
Weather-Go supports various information representation like JSON and emojified JSON weather.

## Running it in local

This project is dockerized. Run the project with the following command:\
`docker-compose up -d`\
PS: A Nginx container is used for deploy the dockerized project.

## Setting Environment

This project uses two `ENV` variables:
* Project exposed port: `NODEJS_PORT`
* OpenWeatherMap API key: `WEATHER_API_KEY`

## Usage

Weather-Go current endpoints:
* Current weather
* By city: `/:city`
* By zipcode: `/country/:country/zip/:zip`
* By coordinates: `/latitude/:latitude/longitude/:longitude`
* Moon phase is available as custom parameter
* 7 days Forecasting endpoint:
* By coordinates: `forecast/latitude/:latitude/longitude/:longitude`

## Supported output formats

Weather-Go currently supports these formats:
* JSON
* Emojified JSON

For receive the desired format, you have to add the `format` query parameter.

The JSON format was re-format from original OpenWeatherMap response.\
*JSON format input:* `?format=json`.\
**Example:**

{
"currentWeather": {
"coord": {
"lon": "-0.13",
"lat": "51.51"
},
"weather": {
"main": "Clear",
"description": "clear sky"
},
...,
"visibility": "6.00 Km/h",
"wind": {
"speed": "7.56 Km/h",
"degree": "60ยฐ"
},
"country": "GB",
"city": "London",
"timezone": "1 UTC",
"sunrise": "4/16/2020, 06:01 AM",
"sunset": "4/16/2020, 07:58 PM"
}
}

You can use the emojified JSON format feature:
* Format 1:
* Format input: `?format=1`.
* Response: `{ "currentWeather": "๐ŸŒ‘ 4.43ยฐC" }`
* Format 2:
* Format input: `?format=2`.
* Response: `{ "currentWeather": "๐ŸŒ‘ ๐ŸŒก๏ธ4.43ยฐC ๐ŸŒฌ๏ธโ†—7.56 Km/h" }`
* Format 3:
* Format input: `?format=3`.
* Response: `{ "currentWeather": "London: ๐ŸŒ‘ 4.28ยฐC" }`
* Format 4:
* Format input: `?format=4`.
* Response: `{ "currentWeather": "Detroit: โ›… ๐ŸŒก๏ธ-1.00ยฐC ๐ŸŒฌ๏ธโ†“11.16 Km/h" }`

## Custom parameters

Custom parameters can be used if the response format is emojified JSON.

h ๐Ÿ’ง Humidity
p โคต๏ธ Pressure in hPa
w ๐ŸŒฌ๏ธ Wind speed in Km/h
wd โ†™ Wind direction
t ๐ŸŒก๏ธ Temperature in Celsius
l City name
c Country code
sr ๐ŸŒ‡ Sunrise
ss ๐ŸŒ† Sunset
mp ๐ŸŒ˜ Moon phase
The `custom` query parameter has to be provided. You can concatenate them!\
**Example:**

Request: /London?format=1&custom=h,sr,ss,t,mp
Response:
{
"currentWeather": "โ›… 2.41ยฐC",
"custom": {
"humidity": "๐Ÿ’ง37%",
"sunrise": "๐ŸŒ‡06:48 AM",
"sunset": "๐ŸŒ†08:14 PM",
"temperature": "๐ŸŒก๏ธ2.41ยฐC",
"moonPhase": {
"emoji": "๐ŸŒ˜",
"name": "Waning crescent",
"ilumination": "14.91%"
}
}
}

## 7 days Forecasting

Weather-Go provides forecasting by Coordinates. All output formats and custom parameters are are available!