tsc-openweather
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

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);
    }
});
 

Package Sidebar

Install

npm i tsc-openweather

Weekly Downloads

2

Version

0.2.3

License

ISC

Unpacked Size

18.2 kB

Total Files

9

Last publish

Collaborators

  • grandfleet