kmw-sdk
Typed, zero-dependency TypeScript client for the
Kachelmannwetter / Meteologix weather API (v02).
- Covers every documented endpoint: current weather, forecasts, station observations, astronomy and weather symbols.
- The JSDoc of every value names its unit.
- Normalized responses: collections are always arrays or records (the API mixes the two), and numeric strings become numbers. Pass
{ raw: true } to get the unmodified response instead.
- Errors are typed and thrown. Optional retries, timeouts,
AbortSignal and rate-limit info.
- ESM and CommonJS, Node.js 20+, Deno, Bun and browsers. Uses the native
fetch.
This is an unofficial client. It is not affiliated with Kachelmann GmbH or Meteologix AG.
Using the API requires your own subscription and API key; their
terms of service apply.
Install
npm install kmw-sdk
Quickstart
import { Kachelmann } from "kmw-sdk";
// Reads KACHELMANN_API_KEY from the environment if `apiKey` is omitted.
const client = new Kachelmann({ apiKey: process.env.KACHELMANN_API_KEY });
const location = { lat: 52.52, lon: 13.41 };
const current = await client.current(location);
console.log(current.data.temp?.value, "°C");
const forecast = await client.forecast.threeDay(location);
for (const day of forecast.data) {
console.log(day.dateTime, day.tempMin, "–", day.tempMax, "°C", day.weatherSymbol);
}
Get an API key in the Meteologix account portal
under "Manage API Keys". The Hobby plan allows two locations, 120 requests per minute and 700 per day.
Plans and API locations
Depending on the subscription, a key works worldwide or only for the API locations set in the account portal
(Hobby / Smart-Home plans: at most two). Set them under "Manage API locations" in the
subscription list before the first request.
The API has no endpoint to read these locations, so the client cannot check a location before sending a request.
A request outside your locations, or for a station your plan does not cover, fails with a PermissionDeniedError (HTTP 403).
problem contains the API's explanation; message contains it too, followed by a hint to check the API locations:
import { PermissionDeniedError } from "kmw-sdk";
try {
await client.forecast.threeDay({ lat: 48.14, lon: 11.58 });
} catch (error) {
if (error instanceof PermissionDeniedError) {
console.log("Not covered by this key:", error.problem?.detail ?? error.message);
} else throw error;
}
Enterprise authentication (Basic / Bearer)
The API also documents HTTP Basic and Bearer authentication, but only
"for internal and enterprise use". Use it only if Meteologix told you to; everyone else uses an API key.
const client = new Kachelmann({ auth: { type: "bearer", token: "<token from Meteologix>" } });
// or: { type: "basic", username: "…", password: "…" }
With auth, the client sends an Authorization header instead of X-API-Key. Don't pass apiKey as well;
KACHELMANN_API_KEY is ignored. This SDK's tests check the headers only, not a live enterprise account.
Endpoints
| Method |
Endpoint |
Returns |
client.current(loc) |
GET /current/{lat}/{lon} |
Current values, keyed by parameter (data.temp.value) |
client.forecast.standard(loc, "1h" \| "3h" \| "6h") |
GET /forecast/…/standard/{steps} |
Standard parameter package |
client.forecast.advanced(loc, "1h" \| "3h" \| "6h") |
GET /forecast/…/advanced/{steps} |
Standard parameters plus min/max, cloud layers, radiation, snow, WMO code, symbol |
client.forecast.threeDay(loc, { minDays?, model? }) |
GET /forecast/…/3day |
Day and time-of-day summaries with risks |
client.forecast.trend14Days(loc) |
GET /forecast/…/trend14days |
14-day trend with ranges and probabilities |
client.stations.search(loc, { radius? }) |
GET /station/search/{lat}/{lon} |
Nearby stations (radius and distance in km, radius at most 25) |
client.stations.latest(id) |
GET /station/{id}/observations/latest |
Latest values, keyed by parameter |
client.stations.observations(id, "10min" \| "1h" \| "1d", { threshold? }) |
GET /station/{id}/observations/{steps} |
Raw observations (6 h) or hourly (24 h) / daily (7 d) aggregates |
client.tools.astronomy(loc) |
GET /tools/astronomy/{lat}/{lon} |
Sun and moon times for 14 days |
client.tools.weatherSymbol(symbol) |
GET /tools/weatherSymbol/{symbol}.svg |
SVG markup |
client.tools.weatherSymbolUrl(symbol) |
– |
Symbol URL for <img src> (no request) |
Every method accepts { signal, timeout } as its last options argument.
Locations
A location is an object with lat and either lon or lng, in decimal degrees (WGS 84).
Objects from Leaflet, Google Maps or Mapbox ({ lat, lng }) and from API responses ({ lat, lon }) can be passed directly:
import type { Coordinates } from "kmw-sdk";
const berlin: Coordinates = { lat: 52.52, lon: 13.41 };
await client.current({ lat: 52.52, lng: 13.41 }); // same request
const [station] = await client.stations.search(berlin);
if (station) await client.forecast.threeDay(station); // station has lat/lon
Coordinates outside −90…90 / −180…180 throw a RangeError before any request.
The types LatLon, LatLng and Coordinates (either of the two) are exported.
One location, many calls
client.location() fixes the location once. The returned object has the same methods as the client, without the location argument, and sends exactly the same requests:
const berlin = client.location({ lat: 52.52, lon: 13.41 });
const { data } = await berlin.current();
const days = await berlin.forecast.threeDay({ units: "imperial" });
const hourly = await berlin.forecast.standard("1h");
const [nearest] = await berlin.stations.search({ radius: 10 });
const sun = await berlin.tools.astronomy();
The location is validated when client.location() is called. berlin.coordinates holds it as { lat, lon }.
Raw responses
By default, responses are normalized. Pass raw: true to get the body exactly as the API sent it, typed after the OpenAPI spec:
const forecast = await client.forecast.standard(location, "1h", { raw: true });
// forecast: RawStandardForecast. `data` may be an array or an object map, as documented in the spec.
raw is available on every documented endpoint: current, forecast.*, stations.* and tools.astronomy.
Arguments are still validated, and units are still sent.
Units
Forecasts and current weather use the client's units (default "metric"). You can override them per call:
const client = new Kachelmann({ units: "imperial" });
const f = await client.forecast.standard(location, "1h"); // f.systemOfUnits: "imperial"
const m = await client.forecast.standard(location, "1h", { units: "metric" });
| Quantity |
metric |
imperial |
| Temperature |
°C |
°F |
| Wind speed and gusts (forecast, current) |
m/s, not km/h |
mph |
| Precipitation |
mm |
inch |
Snow amount (snowAmount*) |
mm water equivalent ¹ |
inch water equivalent ¹ |
| Snow height (forecast) |
m |
inch |
| Global radiation (forecast) |
Wh/m² |
Wh/m² |
Sunshine (sunHours) |
h |
h |
¹ The spec gives kg/m², which is the water equivalent and not snow depth. 1 mm of water equivalent is very roughly 1 cm of fresh snow, but the ratio varies a lot. snowAmount covers one forecast time step, i.e. the preceding 1, 3 or 6 hours. snowAmount6h/12h/24h cover their named windows. The spec does not state the window of snowAmount. Live data from November 2026 confirm it: six hourly values add up to snowAmount6h.
Station observations ignore units. They are always metric with wind in knots,
snow height in cm, and global radiation in kJ/m² (24 h: J/cm²).
Conversion helpers are included:
import { classifyWmoCode, knotsToKmh, mpsToKmh } from "kmw-sdk";
mpsToKmh(4.2, 1); // 15.1
knotsToKmh(10, 0); // 19
classifyWmoCode(63); // "rain"
Errors
Every failure throws a subclass of KachelmannError:
| Error |
When |
MissingApiKeyError |
No API key configured. Thrown before any request. |
BadRequestError (400) |
Invalid parameters |
AuthenticationError (401) |
Missing, invalid or expired key |
PermissionDeniedError (403) |
Your plan does not include the endpoint, location or station |
NotFoundError (404) |
Unknown station or resource |
RateLimitError (429) |
Rate limit hit. retryAfter holds a Date. |
ServerError (5xx) |
API failure |
ApiError |
Base class of all HTTP errors: status, url, problem (RFC 7807 body), rateLimit |
RequestTimeoutError |
No response within timeout ms |
ConnectionError |
Network failure (DNS, TLS, connection reset) |
InvalidResponseError |
Response body is not the expected JSON |
Invalid arguments (coordinates out of range, unknown time steps) throw a RangeError or TypeError before any request.
import { PermissionDeniedError, RateLimitError } from "kmw-sdk";
try {
await client.stations.observations("10637", "1h");
} catch (error) {
if (error instanceof RateLimitError) console.log("Try again at", error.retryAfter);
else if (error instanceof PermissionDeniedError) console.log("Not in your plan");
else throw error;
}
Error messages never contain your API key or enterprise credentials. They are sent only in a header (X-API-Key or Authorization), never in a URL.
Timeouts, retries and cancellation
const client = new Kachelmann({
timeout: 5_000, // per attempt, default 10 000 ms
retry: { retries: 2, minDelay: 500, maxDelay: 10_000 }, // or simply `retry: 2`
});
const controller = new AbortController();
const forecast = client.forecast.standard(location, "1h", { signal: controller.signal, timeout: 2_000 });
Retries are off by default because plans have a daily request limit. When enabled, retries apply to connection errors, timeouts,
HTTP 500/502/503/504 and HTTP 429. A 429 is retried only if x-ratelimit-retry-after lies within maxDelay.
Backoff is exponential with jitter. Aborting through your signal rejects with the signal's reason.
Rate limit
await client.current(location);
client.rateLimit; // { limit: 700, remaining: 623 } from the last response (retryAfter: Date after a 429)
Experimental: climate time series and weather photos
The client also offers two modules for endpoints that the kachelmannwetter.com website uses.
They are not part of the documented v02 API. They may change or disappear without notice,
are marked @experimental and are not covered by semver.
client.experimental.climate
This module lives under client.experimental because it does not work with regular API keys yet.
Climate stations, warming stripes, heatmaps and daily comparisons as shown on the website's climate time-series page.
Requests send your own API key. In a live test (November 2026) the API rejected a customer key with HTTP 403 (PermissionDeniedError), so this module currently only works with keys the API accepts for these endpoints.
const [hit] = await client.experimental.climate.search("Potsdam");
if (!hit) throw new Error("No climate station found");
const stripes = await client.experimental.climate.stripes(hit.name, { param: "tlmean", type: "difference", reference: "1961-1990" });
// stripes.matrix: [year, categoryIndex, value][] (tlmean °C, rrsum mm, shsum h)
await client.experimental.climate.stations("DE");
await client.experimental.climate.station(hit.name); // details, capabilities, records
await client.experimental.climate.heatmap(hit.name, { param: "rrsum", by: "byMonth", year: 2024 });
await client.experimental.climate.spaghetti(hit.name, { param: "tlmean", comparedYears: [2024, 2003] }); // at most 5 years
Responses are passed through mostly unchanged, including snake_case fields.
client.photos
Read-only access to the community weather photos. No API key is sent.
const counts = await client.photos.counts(); // { "2026-11-27": 42, … }
const photos = await client.photos.list({ from: "2026-11-27", to: "2026-11-28", units: "metric" });
const photo = photos[0] && (await client.photos.get(photos[0].id));
Photos are licensed to Kachelmann GmbH and include personal data (uploader names, locations).
Respect copyright and data-protection law; do not republish them without permission.
Liking, uploading and view counting need a user account and are not supported.
Known limitations