1.9.0 • Published 7 years ago
node-openweathermap v1.9.0
node-openweathermap
This npm is for OpenWeatherMap
API key can be obtain from https://openweathermap.org/appid
Input Structure as JSON object:
{
location : <String>, // City/Town/County or State or Postal code/ZIP code
temp_unit : <String> // Temperature units: C - Celsius or F - Fahrenheit(Default)
}
Sample code
var WeatherAPI = require('node-openweathermap');
// API key can be obtain from https://openweathermap.org/appid
var apiKey = 'xxxxxxxxxxxxxxxx';
// Input
var opts = {
location : 'Bangalore',
temp_unit : 'F'
};
var weather = new WeatherAPI(apiKey);
weather.getWeather(opts)
.then(response => {
console.log("response....."+JSON.stringify(response));
}
);
Output: response in JSON object
{
"coord":{
"lon":77.6,
"lat":12.98
},
"weather":[
{
"id":800,
"main":"Clear",
"description":"clear sky",
"icon":"01d"
}
],
"base":"stations",
"main":{
"temp":86,
"pressure":1013,
"humidity":16,
"temp_min":86,
"temp_max":86,
"temp_unit":"F",
"pressure_unit":"mb"
},
"visibility":10000,
"wind":{
"speed":4.1,
"deg":70
},
"clouds":{
"all":0
},
"dt":1480066200,
"sys":{
"type":1,
"id":7823,
"message":0.0113,
"country":"IN",
"sunrise":1480035192,
"sunset":1480076416
},
"id":1277333,
"name":"Bangalore",
"cod":200
}