openweather-api-node is a lightweight JavaScript/TypeScript wrapper that simplifies interaction with various OpenWeather API endpoints, including Current Weather, Forecast, OneCall (version 3.0), Geocoding, Historical data, and Air Pollution data. Currently at version 3.1.5, it provides a stable and actively maintained interface for integrating weather data into Node.js applications. The package has undergone significant refactoring, including a full TypeScript rewrite in v2.0.0 and the removal of Axios in v3.1.0, making it more self-contained. While there isn't a strict release schedule, the library sees regular updates for new API features and improvements. Its primary differentiator is its comprehensive support for multiple OpenWeather APIs and full TypeScript typings out-of-the-box.
npm install openweather-api-nodeVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing the OpenWeatherAPI client with an API key and location, then fetching current weather and forecast data.
Review any code that might have indirectly relied on `axios` or its specific response/error formats. The library now uses native `fetch` or a lightweight alternative.
For the old OneCall API, downgrade to `openweather-api-node@2.1.2`. Review the documentation for v3.x's `getHistory` method for updated return types and adapt your code accordingly.
Update all property access to use `camelCase` (e.g., `temp_cur` becomes `temp.cur`). Refactor any logic that used `mergeWeathers`.
For ESM/TypeScript, use `import OpenWeatherAPI from 'openweather-api-node'`. For CommonJS, use `const { OpenWeatherAPI } = require('openweather-api-node')`.Ensure you have obtained an API key from OpenWeatherMap and pass it correctly during initialization via the `key` option or `setKey` method. Always protect your API keys.
For ESM/TypeScript, use `import OpenWeatherAPI from 'openweather-api-node'; new OpenWeatherAPI(...)`. For CommonJS, use `const { OpenWeatherAPI } = require('openweather-api-node'); new OpenWeatherAPI(...)`.Ensure the `key` property is set in the constructor options, e.g., `new OpenWeatherAPI({ key: 'YOUR_API_KEY', ... })`, or by using `weather.setKey('YOUR_API_KEY')`.If targeting ESM, ensure `tsconfig.json` has `"module": "ESNext"` or similar. If targeting CommonJS, use `import * as OpenWeatherAPI from 'openweather-api-node'` and then `new OpenWeatherAPI.OpenWeatherAPI(...)` or adjust `allowSyntheticDefaultImports` in `tsconfig.json`.
Consult the current documentation for the exact response structure of the method you are calling. Ensure property names are `camelCase` and adjust nested accessors if the object shape has changed.
No dependency data recorded yet.