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

@eliware/openweathermap

v1.1.1

Published

A simple, modern, Node.js client for the OpenWeatherMap API. Fetch current weather, 24-hour forecast, and sunrise/sunset times with a clean, promise-based API.

Downloads

94

Readme

eliware.org

@eliware/openweathermap npm versionlicensebuild status

A simple, modern, Node.js client for the OpenWeatherMap API. Fetch current weather, 24-hour forecast, and sunrise/sunset times with a clean, promise-based API.


Table of Contents

Features

  • Fetch current weather for any coordinates
  • Fetch 24-hour forecast (3-hour intervals)
  • Fetch sunrise and sunset times (adjusted to local timezone)
  • Fully typed (TypeScript definitions included)
  • Supports dependency injection for fetch and API key (easy to test/mocks)

Installation

npm install @eliware/openweathermap

Usage

import { getCurrent, get24hForecast, getSun } from '@eliware/openweathermap';

const lat = 40.7128;
const lon = -74.0060;
const apiKey = 'your_api_key_here';

(async () => {
  const current = await getCurrent(lat, lon, { apiKey, units: 'F' });
  console.log('Current:', current);

  const forecast = await get24hForecast(lat, lon, { apiKey, units: 'F' });
  console.log('24h Forecast:', forecast);

  const sun = await getSun(lat, lon, { apiKey, units: 'F' });
  console.log('Sunrise/Sunset:', sun);
})();

API

getCurrent(lat, lon, options?)

Fetches current weather for the given latitude and longitude.

  • lat (number): Latitude
  • lon (number): Longitude
  • options (object):
    • apiKey (string, required): Your OpenWeatherMap API key
    • units (string, optional): 'F' for Fahrenheit, 'C' for Celsius (default 'C')
    • fetchImpl (function, optional): Custom fetch implementation (for testing/mocks)
  • Returns: Promise resolving to the current weather object (see OpenWeatherMap docs)

get24hForecast(lat, lon, options?)

Fetches the next 24 hours of forecast data (3-hour intervals, up to 8 items).

  • Same parameters as getCurrent
  • Returns: Promise resolving to an array of forecast objects

getSun(lat, lon, options?)

Fetches sunrise and sunset times for the given coordinates, returning both UTC and local times.

  • Same parameters as getCurrent

  • Returns: Promise resolving to:

    {
      sunriseUtc: number,    // Sunrise time (UTC, Unix timestamp)
      sunsetUtc: number,     // Sunset time (UTC, Unix timestamp)
      sunriseLocal: number,  // Sunrise time (local, Unix timestamp)
      sunsetLocal: number,   // Sunset time (local, Unix timestamp)
      offset: number       // Timezone offset in seconds (from UTC)
    }

TypeScript

Type definitions are included and will be picked up automatically. Example:

import { getCurrent, get24hForecast, getSun } from '@eliware/openweathermap';

const weather = await getCurrent(40.7128, -74.0060, { apiKey: 'your_api_key_here' });
// weather: object (see OpenWeatherMap API docs)

Support

For help, questions, or to chat with the author and community, visit:

Discordeliware.org

eliware.org on Discord

License

MIT © 2025 Eli Sterling, eliware.org

Links