0.1.2 • Published 6 years ago

owmjs v0.1.2

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

Build Status Coverage Status Known Vulnerabilities

owmjs

A small Nodejs wrapper for some OpenWeatherMap APIs. For more information about the OpenWeatherMap and their APIs, please visit the OpenWeatherMap.

Installation

npm i owmjs --save

Covered OpenWeatherMap APIs

Usage

const owmjs  = require('owmjs');

// once imported you need to create the owmjs instance
const owmjsInstance = new owmjs("OpenWeatherMap apiKey", "unit format");

Current weather data

To use the current weather module use

owmjsInstance.current

ByCityName

ParameterTypeDescription
nameStringe.g. Cologne, London, New York, Tokyo
countryStringoptional; ISO 3166 country codes. e.g. uk

Example:

owmjsInstance.current.ByCityName("Cologne").then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ByCityID

ParameterTypeDescription
idNumbervisit http://bulk.openweathermap.org/sample/ for all city ids

Example:

owmjsInstance.current.ByCityID(2172797).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ByGeographicCoordinates

ParameterTypeDescription
latNumberlatitude
lonNumberlongitude

Example:

owmjsInstance.current.ByGeographicCoordinates(35, 139).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ByZipCode

ParameterTypeDescription
zipNumber
countryStringoptional; ISO 3166 country codes. e.g. uk

Example:

owmjsInstance.current.ByZipCode(94040).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ByRectangleZone

ParameterTypeDescription
lonleftNumberlongitude Left
latbottomNumberlatitude Bottom
lonrightNumberlongitude Right
lattopNumberlatitude Top
zoomNumber
clusterStringoptional

Example:

owmjsInstance.current.ByRectangleZone(12,32,15,37,10).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ByCircle

ParameterTypeDescription
latNumberlatitude
longNumberlongitude
cntNumberoptional
clusterStringoptional

Example:

owmjsInstance.current.ByCircle(55.5, 37.5).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

MultipleCity

ParameterTypeDescription
citiesNumber[]list of city ids

Example:

owmjsInstance.current.MultipleCity([524901,703448,2643743]).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

forecast

To use the forecast module use

owmjsInstance.forecast

ByCityName

ParameterTypeDescription
nameStringe.g. Cologne, London, New York, Tokyo
countryStringoptional; ISO 3166 country codes. e.g. uk
cntNumberoptional; Number of days

Example:

owmjsInstance.forecast.ByCityName('London', 'uk', 2).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ByCityID

ParameterTypeDescription
idNumbervisit http://bulk.openweathermap.org/sample/ for all city ids
cntNumberoptional; Number of days

Example:

owmjsInstance.forecast.ByCityID(2172797, 2).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ByGeographicCoordinates

ParameterTypeDescription
latNumberlatitude
lonNumberlongitude
cntNumberoptional; Number of days

Example:

owmjsInstance.forecast.ByGeographicCoordinates(35, 139, 2).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ByZipCode

ParameterTypeDescription
zipNumber
countryStringoptional; ISO 3166 country codes. e.g. uk
cntNumberoptional; Number of days

Example:

owmjsInstance.forecast.ByZipCode(94040, 'us', 2).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

UV Index

To use the UV Index module use

owmjsInstance.uv

CurrentByGeographicCoordinates

Gives the current UV Index of the given Geographic Coordinates back

ParameterTypeDescription
latNumberlatitude
lonNumberlongitude

Example:

owmjsInstance.uv.CurrentByGeographicCoordinates(37.75, -122.37).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

ForecastByGeographicCoordinates

Gives UV Index forecast of the given Geographic Coordinates back

ParameterTypeDescription
latNumberlatitude
lonNumberlongitude
cntNumberoptional; Number of days

Example:

owmjsInstance.uv.ForecastByGeographicCoordinates(37.75, -122.37, 2).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

HistoricleByGeographicCoordinates

Gives historcle UV Index date of the given Geographic Coordinates back

ParameterTypeDescription
latNumberlatitude
lonNumberlongitude
startNumberstart point as Unix Time
endNumberend point as Unix Time
cntNumberoptional; Number of days

Example:

owmjsInstance.uv.HistoricleByGeographicCoordinates(37.75, -122.37, 1498049953, 1498481991, 2).then(function (data) {
    // do stuff here
}).catch(function (err) {
    // handle error
});

More information related to the OpenWeatherMap APIs can be seen here

0.1.2

6 years ago

0.1.1

6 years ago