0.2.3 • Published 5 years ago

tsc-openweather v0.2.3

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

npm version Build Status

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) :
  1. imperial

  2. 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);
	}
});
0.2.3

5 years ago

0.2.2

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago