1.1.1 • Published 1 year ago

@ifraan_/weatherbit.js v1.1.1

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
1 year ago

Instalation

Needs an API key, you can choose a free plan here

Needs Node v14+

Dependencies

axios

To install use:

npm i @ifraan_/weatherbit.js

Usage

You need to initialize the class first with the API key

const { API } = require('@ifraan_/weatherbit.js')
const api = new API(process.env.TOKEN);

Then you can query citys with the function search:

await api.search('New York')

Cache

This library cache results to reduce API usage, so if you keep doing the same query it should return the same result without calling the api again (if the time limit is not exceeded)

If you do not want to cache results, you must specify the option cache_time to be something like 0 ms.

Extra

You can pass options to the search function to tweak the settings as you like

OptionDescriptionDefault
langThe language codeen
unitsM (Metric), S (Scientific) or I (Fahrenheit)M
debugPrint extra statementsfalse
timeoutTimeout in ms10_000 (10 seconds)
cache_timeCache time in ms45 * 60_000 (45 minutes)

You can also import types directly from the library and use it as options

const { API, UNITS, LANG } = require('@ifraan_/weatherbit.js');
const api = new API('TOKEN', {
	units: UNITS.Metric,
	lang: LANG.English,
})

Official Documentation

Disclaimer

This project is fully for educational purposes.