Repository navigation
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.
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.
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.
| Topic | Description |
|---|---|
| API | Client configuration and endpoint methods |
| Errors | Error codes and diagnostic metadata |
| Schemas | Public Guardian schemas and inferred types |
Deno:
deno add jsr:@tundraconnect/openweathermapBun:
bunx jsr add @tundraconnect/openweathermapNode.js:
npx jsr add @tundraconnect/openweathermapimport { 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);MIT. Part of Tundra Connect, typed vendor API clients for Deno, Bun, Node.js and Cloudflare Workers.
- Algolia
- AzureBlob
- CloudflareDNS
- CloudflareEmail
- CloudflareSaaS
- CloudflareTurnstile
- CoinGecko
- Discord
- DodoPayments
- GCS
- GoogleAnalytics
- GoogleCertificateManager
- GoogleWebRisk
- Kalshi
- ntfy
- OpenExchange
- OpenWeatherMap
- PayPal
- Polymarket
- Razorpay
- Resend
- S3
- SendGrid
- Sentry
- Slack
- Stripe
- Telegram
- Twilio
- UpstashRedis
- URLhaus