tsc-openweather
v0.2.3
Published
open weather map wrapper written in typescript
Downloads
5
Readme
OpenWeather Typescript
Free Feel to contact me if there any bugs or issues that occur.
Wrapper around openweather map made using typescript
Usage
Instantiate the OpenWeatherMapHelper class
const {OpenWeather} = require('tsc-openweather')
Set your API Key (Required)
const weather = new OpenWeather("1243ceb413c799ddad21527b0e41a23e")
Unit Options(Optional, Kelvin by default) :
imperial
metric
Features
(1) Current Weather
Get current weather by City Name:
weather.getCurrentWeatherByCityName("Accra", (err, currentWeather) => {
if(err){
console.log(err);
}
else{
console.log(currentWeather);
}
});
Get current weather by City ID:
weather.getCurrentWeatherByCityID("524901", (err, currentWeather) => {
if(err){
console.log(err);
}
else{
console.log(currentWeather);
}
});
Get current weather by Geographic Coordinates:
weather.getCurrentWeatherByGeoCoordinates(5.6037, 0.1870, (err, currentWeather) => {
if(err){
console.log(err);
}
else{
console.log(currentWeather);
}
});
Get current weather by Zip Code:
weather.getCurrentWeatherByZipCode("90003", (err, currentWeather) => {
if(err){
console.log(err);
}
else{
console.log(currentWeather);
}
});
(2) 5 day / 3 hour forecast
Get three hour forecast by City Name:
weather.getThreeHourForecastByCityName("Pretoria", (err, threeHourForecast) => {
if(err){
console.log(err);
}
else{
console.log(threeHourForecast);
}
});
Get three hour forecast by City ID:
weather.getThreeHourForecastByCityID("524901", (err, threeHourForecast) => {
if(err){
console.log(err);
}
else{
console.log(threeHourForecast);
}
});
Get three hour forecast by Geographic Coordinates:
weather.getThreeHourForecastByGeoCoordinates(6.5244,3.3792, (err, threeHourForecast) => {
if(err){
console.log(err);
}
else{
console.log(threeHourForecast);
}
});
Get three hour forecast by Zip Code:
weather.getThreeHourForecastByZipCode("94040", (err, threeHourForecast) => {
if(err){
console.log(err);
}
else{
console.log(threeHourForecast);
}
});