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

openweather-api-wrapper

v0.0.1

Published

A test solution from DCCPL team member, given by LTTS

Readme

OpenWeatherAPI Wrapper

This git repository should be used for reviewing code for the test given by LTTS.

How to Use

Install the package with npm, import with the require statement in the app, and start to use the apis. First step is set the params for the request (request the api-key at http://openweathermap.org/register ):

	var weather = require('openweather-apis');

	weather.setLang('en');

// set city by name
	weather.setCity('Bengaluru');
 	// or set the coordinates (latitude,longitude)
	weather.setCoordinate(12.9762, 77.6033);
	// or set city by ID (recommended by OpenWeatherMap)
	weather.setCityId(1277333);

    // or set zip code
	weather.setZipCode(560079);

	// 'metric'  'internal'  'imperial'
 	weather.setUnits('metric');

	// check http://openweathermap.org/appid#get for get the APPID
 	weather.setAPPID(_Your_APP_KEY_>);

Current Weather Data

Using the following requests to API, Weather data is available in JSON.

Methods

Import the module and start to use the functions :


	// get the Temperature  
	weather.getTemperature(function(err, temp){
		console.log(temp);
	});

	// get the Atm Pressure
	weather.getPressure(function(err, pres){
		console.log(pres);
	});

	// get the Humidity
	weather.getHumidity(function(err, hum){
		console.log(hum);
	});

	// get the Description of the weather condition
	weather.getDescription(function(err, desc){
		console.log(desc);
	});

	// get all the JSON file returned from server (rich of info)
	weather.getAllWeather(function(err, JSONObj){
		console.log(JSONObj);
	});

	// Adds support for the onecall api endpoint.
	weather.getWeatherOneCall = function(err, data){
		
  };

Example of a simple JSON Object with temperature, humidity, pressure and description


	// get a simple JSON Object with temperature, humidity, pressure and description
	weather.getSmartJSON(function(err, smart){
		console.log(smart);
	});

This is the simple JSON object returned by the getSmartJSON(), pretty useful ! The rain value can be zero if not measured or a mesured value.

		{
			temp : 25,
			humidity : 88,
			pressure : 101325,
			description : 'sun',
			rain: 4,
			weathercode : 200
		}

this JSON object is easy to use and is enough for a lot of possible use of the weather data, for example the weathercode is easy to use for build check function, draw the icons etc.

Geographic location

Yes, of course you can set the location to get info by the coordinates, first the latitude, second the longitude. Sometimes use the coordinates are worse than the city name !

	weather.setCoordinate(12.9762, 77.6033);

Error

Use the callback to check if an error is raised on the request (HTTP server unreachable or other connection, request problem), you need to handle the error on the request, for example :

		weather.getTemperature(function(err, temp){
			if(err) console.log(err);

			// normal execution with no error
			});

Test

The package is tested with mocha and chai. You can find the tests in the /test folder.