Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ifraan_/weatherbit.js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ifraan_/weatherbit.js

Wrapper of WeatherBit API

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

weatherbit.js

This a wrapper of the WeatherBit weather API

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');
...
await api.search('Los Angeles, US', {
	units: UNITS.Metric,
	lang: LANG.English,
})

Official Documentation

Disclaimer

This project is fully for educational purposes.

Keywords

FAQs

Package last updated on 27 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc