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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bencevans/weatherkit

v1.2.0

Published

WeatherKit API

Readme

WeatherKit

A lightweight TypeScript client for the Apple WeatherKit REST API, with Zod-powered request and response models.

Features

  • Typed client for live weather and availability endpoints
  • Built-in request validation with Zod schemas
  • Rich response schemas for:
    • current weather
    • daily forecast
    • hourly forecast
    • next-hour forecast
  • Integration tests against the real WeatherKit API

Installation

npm install @bencevans/weatherkit

If you are developing this repository locally:

npm install

Authentication

Create a valid Apple WeatherKit JWT and pass it to the client:

Note: The apiKey in this library is your encoded JWT token. Instructions for creating it are in Apple's WeatherKit REST API docs: https://developer.apple.com/documentation/weatherkitrestapi/request-authentication-for-weatherkit-rest-api

import { WeatherKit } from "@bencevans/weatherkit";

const apiKey = process.env.APPLE_WEATHERKIT_API_KEY;
if (!apiKey) {
  throw new Error("APPLE_WEATHERKIT_API_KEY is required");
}

const client = new WeatherKit(apiKey);

Quick Start

Get available datasets for a location

const available = await client.getAvailability({
  latitude: 37.7749,
  longitude: -122.4194,
  country: "US",
});

console.log(available);
// Example: ["currentWeather", "forecastDaily", "forecastHourly", "forecastNextHour", "weatherAlerts"]

Fetch weather data

const weather = await client.getWeather({
  language: "en",
  latitude: 37.7749,
  longitude: -122.4194,
  countryCode: "US",
  timezone: "America/Los_Angeles",
  dataSets: ["currentWeather", "forecastDaily"],
});

console.log(weather);

API

new WeatherKit(apiKey, options?)

  • apiKey: string
  • options.validateParameters: boolean (default: true)

When validateParameters is true, input payloads are validated with Zod before requests are sent.

getAvailability(request)

Returns available datasets for a location.

Request fields:

  • latitude (required)
  • longitude (required)
  • country (optional, ISO Alpha-2)

getWeather(request)

Fetches weather payloads for one or more datasets.

Request fields:

  • language (required)
  • latitude (required)
  • longitude (required)
  • timezone (required)
  • dataSets (required)
  • countryCode (optional)
  • currentAsOf (optional)
  • dailyStart (optional)
  • dailyEnd (optional)
  • hourlyStart (optional)
  • hourlyEnd (optional)

Supported dataSets values:

  • currentWeather
  • forecastDaily
  • forecastHourly
  • forecastNextHour
  • weatherAlerts

Validation Models

Zod schemas and inferred types are available in src/models.ts, including:

  • request schemas
  • dataset enums
  • weather response models
  • forecast metadata and nested forecast structures

Testing

Run tests:

npm test

Integration tests use APPLE_WEATHERKIT_API_KEY. If the variable is not set, integration tests are skipped.

Set the variable and run:

export APPLE_WEATHERKIT_API_KEY="your_jwt_here"
npm test

Notes

  • This package uses the global fetch API available in modern Node.js runtimes.
  • API responses can vary by geography and provider.