Skip to content

OpenWeatherMap

github-actions[bot] edited this page Oct 4, 2026 · 2 revisions

OpenWeatherMap

Typed OpenWeatherMap API client for Deno, Bun, Node.js and Cloudflare Workers. Current weather and 5-day / 3-hour forecasts by city name or coordinates.

JSR JSR Score

Overview

OpenWeatherMap provides validated current weather and 5-day/3-hour forecast responses from the free-tier data/2.5 endpoints. It uses RESTler for transport and Guardian for runtime response validation.

Testing your code

Your tests don't need to fake HTTP. Have your code take an OpenWeatherMap instance and pass in a stand-in that returns the shapes from @tundraconnect/openweathermap/schemas or throws a real OpenWeatherMapError:

import { OpenWeatherMapError } from '@tundraconnect/openweathermap/errors';

const outage = new OpenWeatherMapError('SERVICE_UNAVAILABLE', { status: 503 });
console.log(outage.code);

To exercise the client itself against a fake transport, subclass it and reassign the protected _fetch.

Documentation

Topic Description
API Client configuration and endpoint methods
Errors Error codes and diagnostic metadata
Schemas Public Guardian schemas and inferred types

Upstream

Installation

Deno:

deno add jsr:@tundraconnect/openweathermap

Bun:

bunx jsr add @tundraconnect/openweathermap

Node.js:

npx jsr add @tundraconnect/openweathermap

Quick Start

import { OpenWeatherMap } from '@tundraconnect/openweathermap';

const client = new OpenWeatherMap({
  auth: { type: 'CUSTOM', apiKey: 'your-api-key' },
});

const weather = await client.getCurrentWeather({
  lat: 51.51,
  lon: -0.13,
  units: 'metric',
});
console.log(weather.main.temp);

const forecast = await client.getForecast({ q: 'London,GB', cnt: 8 });
console.log(forecast.list[0]?.main.temp);

License

MIT. Part of Tundra Connect, typed vendor API clients for Deno, Bun, Node.js and Cloudflare Workers.

Clone this wiki locally