Git Product home page Git Product logo

weather-go's Introduction

Weather-Go!

Weather-Go is wrapper for OpenWeatherMap API. This project is inspired by wttr. 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!

weather-go's People

Contributors

jvillegasd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.