An Openweathermap wrapper for nodejs
You need an API Key to use the OpenWeatherMap API. Head on over to their website if you don't already have one.
npm install openweathermap-node
const OpenWeatherMapHelper = require("openweathermap-node");
const helper = new OpenWeatherMapHelper(
{
APPID: 'YOUR_OPENWEATHERMAP_API_KEY_GOES_HERE',
units: "imperial"
}
);
-
imperial
-
metric
helper.getCurrentWeatherByCityName("Accra", (err, currentWeather) => {
if(err){
console.log(err);
}
else{
console.log(currentWeather);
}
});
helper.getCurrentWeatherByCityID("524901", (err, currentWeather) => {
if(err){
console.log(err);
}
else{
console.log(currentWeather);
}
});
helper.getCurrentWeatherByGeoCoordinates(5.6037, 0.1870, (err, currentWeather) => {
if(err){
console.log(err);
}
else{
console.log(currentWeather);
}
});
helper.getCurrentWeatherByZipCode("90003", (err, currentWeather) => {
if(err){
console.log(err);
}
else{
console.log(currentWeather);
}
});
helper.getThreeHourForecastByCityName("Pretoria", (err, threeHourForecast) => {
if(err){
console.log(err);
}
else{
console.log(threeHourForecast);
}
});
helper.getThreeHourForecastByCityID("524901", (err, threeHourForecast) => {
if(err){
console.log(err);
}
else{
console.log(threeHourForecast);
}
});
helper.getThreeHourForecastByGeoCoordinates(6.5244,3.3792, (err, threeHourForecast) => {
if(err){
console.log(err);
}
else{
console.log(threeHourForecast);
}
});
helper.getThreeHourForecastByZipCode("94040", (err, threeHourForecast) => {
if(err){
console.log(err);
}
else{
console.log(threeHourForecast);
}
});
- 16 day / daily forecast