1.1.0 • Published 2 years ago

@ifraan_/weather.js v1.1.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 years ago

Instalattion

No apiKey, its free.

Dependencies

axios fast-xml-parser

To install use:

npm i @ifraan_/weather.js

You must use API.search before using any other method

search can take options parameters

await search('Location', {
	degree: 'C', // Either C for Celcius or F for Fahrenheit, default is F
	lang: 'en-UK', // Language code for the results, default is en-US
	timeout: 5_000 // Timeout in miliseconds, default is 10_000
})
MethodsDescription
infoGenerical info
currentCurrent weather
forecastForecast for the next 5 days

Example code:

const { API } = require('@ifraan_/weather.js');

try {
    const city = await API.search('Broklyn, NY', {degree: 'F', lang: 'es-ES'})
    console.log('Info: ', city.info())
	/*
	Info:  {
		location_code: 'wc:USNY0996',
		location_name: 'Brooklyn, Estados Unidos',
		degree: 'F',
		provider: { name: 'Foreca', url: 'http://www.foreca.com/' },
		coords: { latitude: '40,693', longitude: '-73,991' },
		timezone: '-4'
	}
	*/
    console.log('Current: ', city.current())
	/*
	Current:  {
		temperature: '83',
		skycode: '34',
		skytext: 'Muy soleado',
		date: '2022-07-21',
		observationtime: '08:15:00',
		observationpoint: 'Brooklyn, NY',
		feelslike: '88',
		humidity: '77',
		winddisplay: '8 mph Sur',
		day: 'jueves',
		shortday: 'ju.',
		windspeed: '8 mph'
	}
	*/
    console.log('Forecast: ', city.forecast())
	/*
	Forecast:  [
		{
			low: '77',
			high: '91',
			skycodeday: '31',
			skytextday: 'Despejado',
			date: '2022-07-20',
			day: 'miércoles',
			shortday: 'mi.',
			precip: ''
		},
		...
	]
	*/
} catch (err) {
    console.log(err)
}

Disclaimer

This project is fully for educational purposes.