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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shodlik_shomuratov/openweather-sdk

v2.0.5

Published

Software Development Kit(SDK) to get weather information related to given city easily.

Downloads

5

Readme

Open Weather SDK in Node.js

Introduction

Open Weather SDK is used to work with famous weather forecaster Open Weather features using Node.js, TypeScript. The package provides method(s) to get weather condition by city name.

This page presents the installation, basic usage and examples with different type of modes.

Used technologies:

Contents

Installation

  • npm - npm install @shodlik_shomuratov/openweather-sdk
  • yarn - yarn add @shodlik_shomuratov/openweather-sdk
  • pnpm - pnpm add @shodlik_shomuratov/openweather-sdk

Configuration

  1. Obtain your API_KEY from OpenWeather to use package properly!
  2. Instantiate SDK client and pass it to KameleoonProvider
import SDK from "@shodlik_shomuratov/openweather-sdk";

const sdk = new SDK("your_api_key");

async function outputWeather() {
	const weatherData = await sdk.getCurrentWeather("Tashkent");
	console.log(weatherData);
}

outputWeather();

Modes

  1. Default mode. In this mode you every time call the getCurrentWeather() method SDK makes a new request.
import SDK from "@shodlik_shomuratov/openweather-sdk";

cosnt sdk = new SDK("your_api_key", {
    mode: "default"
});

async function outputWeather () {
    const weatherData = await sdk.getCurrentWeather("Tashkent");
    console.log(weatherData);
}

outputWeather();
  1. Polling mode. In polling mode in order to maintenance zero latency response, you get data from stored weather data and SDK makes a new request for you every 10 minutes.
import SDK from "@shodlik_shomuratov/openweather-sdk";

cosnt sdk = new SDK("your_api_key", {
    mode: "polling"
});

async function outputWeather () {
    const weatherData = await sdk.getCurrentWeather("Tashkent");
    console.log(weatherData);
}

outputWeather();

Redis Store

If you want you can save updated weather data in your redis store. Only thing you have to do is give SDK redis options in the redis field.

import SDK from "@shodlik_shomuratov/openweather-sdk";

cosnt sdk = new SDK("your_api_key", {
    mode: "polling",
    redis: {
        host: "127.0.0.1", // your redis host
        port: 6379, // your redis port
        username: "my_redis_username", // optional, if you have one
        password: "my_redis_password", // optional, if you have one
    }
});

async function outputWeather () {
    const weatherData = await sdk.getCurrentWeather("Tashkent");
    console.log(weatherData);
}

outputWeather();

Testing purposes

  1. You have to clone this repository into your local machine and install dependencies
    npm install
  1. Change .env.sample into .env and write your credentials in it.
    OPEN_WEATHER_API_KEY=my_api_key
  1. Run test command
    npm run test

Created by Shodlik Shomuratov