Giter VIP home page Giter VIP logo

weather-cli's Introduction

Weather-CLI

A small tool to get the current weather, using the API provided by openweathermap.org

Requirements

In order to use the tool, you need:

  • ruby v2.3.3+
  • An API key from openweathermap.org

Usage

The script will work when called in two ways. You can supply either a latitude and longitude combo, or a city_id supported by openweathermap.org. The city_id is more precise, whereas the latitude and longitude can give you approximate results. In both case, it is mandatory to supply a working API key provided by openweathermap.org.

If a city_id and a latitude and longitude pair are provided to the script, the city_id has priority.

Command line options

Usage: weather.rb [options]
    -k, --key APIKEY                 API key for the web service at api.openweathermap.org
    -c, --city CITYID                City_Id for the weather request
    -l, --latitude VAL               Latitude for the requested city
    -g, --longitude VAL              Longitude for the requested city
    -h, --help                       Displays Help

Examples

With a city_id (6077243 is Montreal)

ruby weather.rb -k 1377756ac67ca111111111fd0c44caa -c 6077243

Would output

Weather report for Montreal (45.51,-73.59)
Weather: Snow (light snow)
Temperature: -0.02 ℃
Humidity: 81%
Wind: 5.7 km/h

Data generated by api.openweathermap.org on 2017-11-23T22:28:00-05:00

With a latitude and longitude (51.51 / -0.13 is London, UK)

ruby weather.rb -k 1377756ac67ca111111111fd0c44caa -l 51.51 -g -0.13

Would output

Weather report for London (51.51,-0.13)
Weather: Rain (light rain)
Temperature: 5.5 ℃
Humidity: 87%
Wind: 2.1 km/h

Data generated by api.openweathermap.org on 2017-11-23T22:20:00-05:00

City IDs and Latitude/Longitude

You can get a complete list of city ids and their coordinates in json format with this link.

You can also try the following few provided below

Montreal

  • ID: 6077243
  • Lat: 45.508839
  • Lon: -73.587807

London, UK

  • ID: 2643743
  • Lat: 51.50853
  • Lon: -0.12574

Wellington, NZ

  • ID: 2179538
  • Lat: -41.283329
  • Lon: 174.766663

Moscow, RU

  • ID: 524901
  • Lat: 55.75222
  • Lon: 37.615555

weather-cli's People

Contributors

psionikangel avatar

Watchers

 avatar James Cloos avatar  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.