npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@essamonline/weather-visualcrossing

v1.0.0

Published

JavaScript Library To Access Weather Data from Visual Crossing Weather API.

Readme

weather-visualcrossing

A JavaScript library to access weather Data from Visual Crossing Weather API. The library defines a single class Weather for fetching and managing weather data. It encapsulates all related weather parameters, stores JSON responses from the Weather API, and provides methods to retrieve and manipulate this data.

Coverage Status

References

Installation

npm install [-g] @essamonline/weather-visualcrossing

Usage

With ESM or TypeScript:

import { Weather } from '@essamonline/weather-visualcrossing';

Sign up for a Visual Crossing free account to obtain an API key and include in a file called '.api-key' located at the package root directory.

Weather class

class Weather{

	#weatherData;

	constructor(apiKey = '', baseUrl = BASE_URL)

	/*** Static Methods [7] ***/

	static filterItemByDatetimeVal (src, datetimeVal)         // throws
	static setItemByDatetimeVal    (src, datetimeVal, data)   // throws
	static updateItemByDatetimeVal (src, datetimeVal, data)   // throws

	static validateParamDate      (param)                     // throws
	static validateParamUnitGroup (param)                     // throws
	static validateParamInclude   (...param)                  // throws
	static validateParamElements  (...param)                  // throws

	/*** Instance Method - fetchWeatherData [1] ***/

	async fetchWeatherData(
		location,
		fromDate = '', toDate = '',
		unitGroup = 'metric', include = '', elements = '')    // throws

	/*** Instance Methods - Data Elements [17] ***/

	clearWeatherData()
	getWeatherData(elements = [])
	setWeatherData(data)

	getWeatherDailyData(elements = [])
	setWeatherDailyData(dailyData)

	getWeatherHourlyData(elements = [])

	getDataOnDay(dayInfo, elements = [])
	setDataOnDay(dayInfo, data)                            // throws

	getHourlyDataOnDay(dayInfo, elements = [])             // throws
	setHourlyDataOnDay(dayInfo, data)                      // throws

	getDataAtDatetime(dayInfo, timeInfo, elements = [])    // throws
	setDataAtDatetime(dayInfo, timeInfo, data)             // throws
	updateDataAtDatetime(dayInfo, timeInfo, data)          // throws

	getDatetimeEpochAtDatetime(dayInfo, timeInfo)          // throws
	setDatetimeEpochAtDatetime(dayInfo, timeInfo, value)   // throws

	getDailyDatetimes()
	getHourlyDatetimes()

	/*** Instance Methods - Location Elements [12] ***/

	getLatitude()
	setLatitude(value)                                     // throws

	getLongitude()
	setLongitude(value)                                    // throws

	getResolvedAddress()
	setResolvedAddress(value)

	getAddress()
	setAddress(value)

	getTimezone()
	setTimezone(value)

	getTzoffset()
	setTzoffset(value)

	/*** Instance Methods - Request Elements [4] ***/

	getQueryCost()
	setQueryCost(value)

	getStations()
	setStations(value)

	/*** Instance Methods - Core Weather Elements [50] ***/

	getTempOnDay(dayInfo)
	setTempOnDay(dayInfo, value)                           // throws

	getTempmaxOnDay(dayInfo)
	setTempmaxOnDay(dayInfo, value)                        // throws

	getTempminOnDay(dayInfo)
	setTempminOnDay(dayInfo, value)                        // throws

	getFeelslikeOnDay(dayInfo)
	setFeelslikeDay(dayInfo, value)                        // throws

	getFeelslikemaxOnDay(dayInfo)
	setFeelslikemaxDay(dayInfo, value)                     // throws

	getFeelslikeminOnDay(dayInfo)
	setFeelslikeminDay(dayInfo, value)                     // throws

	getDewOnDay(dayInfo)
	setDewOnDay(dayInfo, value)                            // throws

	getHumidityOnDay(dayInfo)
	setHumidityOnDay(dayInfo, value)                       // throws

	getPrecipOnDay(dayInfo)
	setPrecipOnDay(dayInfo, value)                         // throws

	getPrecipprobOnDay(dayInfo)
	setPrecipprobOnDay(dayInfo, value)                     // throws

	getPrecipcoverOnDay(dayInfo)
	setPrecipcoverOnDay(dayInfo, value)                    // throws

	getPreciptypeOnDay(dayInfo)
	setPreciptypeOnDay(dayInfo, value)                     // throws

	getSnowOnDay(dayInfo)
	setSnowOnDay(dayInfo, value)                           // throws

	getSnowdepthOnDay(dayInfo)
	setSnowdepthOnDay(dayInfo, value)                      // throws

	getWindgustOnDay(dayInfo)
	setTWindgustOnDay(dayInfo, value)                      // throws

	getWindspeedOnDay(dayInfo)
	setTWindspeedOnDay(dayInfo, value)                     // throws

	getWinddirOnDay(dayInfo)
	setTWinddirOnDay(dayInfo, value)                       // throws

	getPressureOnDay(dayInfo)
	setPressueOnDay(dayInfo, value)                        // throws

	getCloudcoverOnDay(dayInfo)
	setCloudcoverOnDay(dayInfo, value)                     // throws

	getVisibilityOnDay(dayInfo)
	setVisibilityOnDay(dayInfo, value)                     // throws

	getSolarradiationOnDay(dayInfo)
	setSolarradiationOnDay(dayInfo, value)                 // throws

	getSolarenergyOnDay(dayInfo)
	setSolarenergyOnDay(dayInfo, value)                    // throws

	getUvindexOnDay(dayInfo)
	setUvindexOnDay(dayInfo, value)                        // throws

	getSevereriskOnDay(dayInfo)
	setSevereriskOnDay(dayInfo, value)                     // throws

	getStationsOnDay(dayInfo)
	setStationsOnDay(dayInfo, value)                       // throws

	/*** Instance Methods - Astronomy Elements [10] ***/

	getSunriseOnDay(dayInfo)
	setSunriseOnDay(dayInfo, value)                         // throws

	getSunriseEpochOnDay(dayInfo)
	setSunriseEpochOnDay(dayInfo, value)                    // throws

	getSunsetOnDay(dayInfo)
	setSunsetOnDay(dayInfo, value)                          // throws

	getSunsetEpochOnDay(dayInfo)
	setSunsetEpochOnDay(dayInfo, value)                     // throws

	getMoonphaseOnDay(dayInfo)
	setMoonphaseOnDay(dayInfo, value)                       // throws

	/*** Instance Methods - Description Elements [6] ***/

	getConditionsOnDay(dayInfo)
	setConditionsOnDay(dayInfo, value)                      // throws

	getDescriptionOnDay(dayInfo)
	setDescriptionOnDay(dayInfo, value)                     // throws

	getIconOnDay(dayInfo)
	setIconOnDay(dayInfo, value)                            // throws

	/*** Instance Methods - Core Weather Elements at datetime [42] ***/

	getTempAtDatetime(dayInfo, timeInfo)
	setTempAtDatetime(dayInfo, timeInfo, value)             // throws

	getFeelslikeAtDatetime(dayInfo, timeInfo)
	setFeelslikeDay(dayInfo, timeInfo, value)               // throws

	getDewAtDatetime(dayInfo, timeInfo)
	setDewAtDatetime(dayInfo, timeInfo, value)              // throws

	getHumidityAtDatetime(dayInfo, timeInfo)
	setHumidityAtDatetime(dayInfo, timeInfo, value)         // throws

	getPrecipAtDatetime(dayInfo, timeInfo)
	setPrecipAtDatetime(dayInfo, timeInfo, value)           // throws

	getPrecipprobAtDatetime(dayInfo, timeInfo)
	setPrecipprobAtDatetime(dayInfo, timeInfo, value)       // throws

	getPreciptypeAtDatetime(dayInfo, timeInfo)
	setPreciptypeAtDatetime(dayInfo, timeInfo, value)       // throws

	getSnowAtDatetime(dayInfo, timeInfo)
	setSnowAtDatetime(dayInfo, timeInfo, value)             // throws

	getSnowdepthAtDatetime(dayInfo, timeInfo)
	setSnowdepthAtDatetime(dayInfo, timeInfo, value)        // throws

	getWindgustAtDatetime(dayInfo, timeInfo)
	setTWindgustAtDatetime(dayInfo, timeInfo, value)        // throws

	getWindspeedAtDatetime(dayInfo, timeInfo)
	setTWindspeedAtDatetime(dayInfo, timeInfo, value)       // throws

	getWinddirAtDatetime(dayInfo, timeInfo)
	setTWinddirAtDatetime(dayInfo, timeInfo, value)         // throws

	getPressureAtDatetime(dayInfo, timeInfo)
	setPressueAtDatetime(dayInfo, timeInfo, value)          // throws

	getCloudcoverAtDatetime(dayInfo, timeInfo)
	setCloudcoverAtDatetime(dayInfo, timeInfo, value)       // throws

	getVisibilityAtDatetime(dayInfo, timeInfo)
	setVisibilityAtDatetime(dayInfo, timeInfo, value)       // throws

	getSolarradiationAtDatetime(dayInfo, timeInfo)
	setSolarradiationAtDatetime(dayInfo, timeInfo, value)   // throws

	getSolarenergyAtDatetime(dayInfo, timeInfo)
	setSolarenergyAtDatetime(dayInfo, timeInfo, value)      // throws

	getUvindexAtDatetime(dayInfo, timeInfo)
	setUvindexAtDatetime(dayInfo, timeInfo, value)          // throws

	getSevereriskAtDatetime(dayInfo, timeInfo)
	setSevereriskAtDatetime(dayInfo, timeInfo, value)       // throws

	getStationsAtDatetime(dayInfo, timeInfo)
	setStationsAtDatetime(dayInfo, timeInfo, value)         // throws

	getSourceAtDatetime(dayInfo, timeInfo)
	setSourceAtDatetime(dayInfo, timeInfo, value)           // throws

	/*** Instance Methods - Description Elements at datetime [4] ***/

	getConditionsAtDatetime(dayInfo, timeInfo)
	setConditionsAtDatetime(dayInfo, timeInfo, value)       // throws

	getIconAtDatetime(dayInfo, timeInfo)
	setIconAtDatetime(dayInfo, timeInfo, value)             // throws
}

Testing

weather-visualcrossing was tested using node:test module facilitates.

Documentation

Source code documentation, along with a test coverage report are both included under Documentation.

License

This software is licensed under the MIT license, see the LICENSE file.