Giter Club home page Giter Club logo

weather's Introduction

Weather

NPM Build Status Coverage

Weather is a module for obtaining weather information.

Installation

npm install weather-js

Usage

var weather = require('weather-js');

// Options:
// search:     location name or zipcode
// degreeType: F or C

weather.find({search: 'San Francisco, CA', degreeType: 'F'}, function(err, result) {
  if(err) console.log(err);

  console.log(JSON.stringify(result, null, 2));
});
[
  {
    "location": {
      "name": "San Francisco, CA",
      "lat": "37.777",
      "long": "-122.42",
      "timezone": "-7",
      "alert": "",
      "degreetype": "F",
      "imagerelativeurl": "http://blob.weather.microsoft.com/static/weather4/en-us/"
    },
    "current": {
      "temperature": "70",
      "skycode": "32",
      "skytext": "Sunny",
      "date": "2017-03-14",
      "observationtime": "13:15:00",
      "observationpoint": "San Francisco, California",
      "feelslike": "70",
      "humidity": "59",
      "winddisplay": "3 mph West",
      "day": "Tuesday",
      "shortday": "Tue",
      "windspeed": "3 mph",
      "imageUrl": "http://blob.weather.microsoft.com/static/weather4/en-us/law/32.gif"
    },
    "forecast": [
      {
        "low": "52",
        "high": "69",
        "skycodeday": "31",
        "skytextday": "Clear",
        "date": "2017-03-13",
        "day": "Monday",
        "shortday": "Mon",
        "precip": ""
      },
      {
        "low": "52",
        "high": "70",
        "skycodeday": "34",
        "skytextday": "Mostly Sunny",
        "date": "2017-03-14",
        "day": "Tuesday",
        "shortday": "Tue",
        "precip": "10"
      },
      {
        "low": "56",
        "high": "63",
        "skycodeday": "26",
        "skytextday": "Cloudy",
        "date": "2017-03-15",
        "day": "Wednesday",
        "shortday": "Wed",
        "precip": "20"
      },
      {
        "low": "50",
        "high": "64",
        "skycodeday": "28",
        "skytextday": "Mostly Cloudy",
        "date": "2017-03-16",
        "day": "Thursday",
        "shortday": "Thu",
        "precip": "10"
      },
      {
        "low": "53",
        "high": "67",
        "skycodeday": "32",
        "skytextday": "Sunny",
        "date": "2017-03-17",
        "day": "Friday",
        "shortday": "Fri",
        "precip": "10"
      }
    ]
  }
]

Notes

  • It uses weather.service.msn.com

License

Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.

weather's People

Contributors

devfacet 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

Watchers

 avatar  avatar

weather's Issues

Returning empty results

Getting an empty array as a response. Is this because they have finally shut it down for good? I know Microsoft have made an announcement to discontinue weather.service.msn.com services back in April of 2016. But I have been using this module for Jan. 2017. Here is snippet of my code:

app.get('/weather', function(req, res) {
var zipCode = "43606";
var type = "F";

if((zipCode !== null) && (type !== null)){
	weather.find({search: zipCode, degreeType: type}, function(err, result) {
		if(err) console.log(err);
		res.send(JSON.stringify(result, null, 2));
	});
}

});

https://support.microsoft.com/en-us/help/3210143/msn-weather-service-api-has-been-retired

Precip Error

Hi,
I have a problem with Forecast Precip. I'm using this module to make a command on my Discord Bot which it'll display Weather when I tried to show todays current precip it had an empty value why's that?

let newprecip = content[0].forecast[0].precip.length <= 0 ? "0" : content[0].forecast[0].precip

Language

Is it possible to add and set languages to this?

Fatal crash

When searching something that throws an error, and then searching . or *, the package crashes

events.js:141
throw er; // Unhandled 'error' event
^

TypeError: Cannot read property 'weatherdata' of null
at C:\node\node_modules\weather-js\lib\weather.js:50:23
at Parser. (C:\node\node_modules\weather-js\node_modules\xml2js\l
ib\xml2js.js:489:18)
at emitOne (events.js:77:13)
at Parser.emit (events.js:169:7)
at Object.onend (C:\node\node_modules\weather-js\node_modules\xml2js\lib\xml
2js.js:319:26)
at emit (C:\node\node_modules\weather-js\node_modules\xml2js\node_modules\sa
x\lib\sax.js:640:35)
at end (C:\node\node_modules\weather-js\node_modules\xml2js\node_modules\sax
\lib\sax.js:683:5)
at Object.write (C:\node\node_modules\weather-js\node_modules\xml2js\node_mo
dules\sax\lib\sax.js:991:14)
at Object.SAXParser.close (C:\node\node_modules\weather-js\node_modules\xml2
js\node_modules\sax\lib\sax.js:157:38)
at Parser.exports.Parser.Parser.parseString (C:\node\node_modules\weather-js
\node_modules\xml2js\lib\xml2js.js:508:42)

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.