openapiweather-sdk
v1.0.0
Published
This SDK allows you to interact with the OpenWeatherMap API to fetch weather data.
Downloads
2
Readme
OpenWeatherMap SDK for JavaScript
This SDK allows you to interact with the OpenWeatherMap API to fetch weather data.
Installation
Install the SDK via npm:
npm install openapiweather-sdk
Usage
First, initialize the SDK with your OpenWeatherMap API key: const APIWeatherSDK = require('openapiweather-sdk'); const sdk = new APIWeatherSDK('YOUR_API_KEY'); sdk.init();
Get Weather by City Name You can retrieve weather data for a city by its name:
sdk.getWeatherByCity('London') .then(data => console.log(data)) .catch(error => console.error(error));
- Get Weather Timestamp You can retrieve weather data timestamp for a location using its latitude and longitude coordinates and time:
sdk.weatherTimestamp('lat','lon','time') For example:
sdk.weatherTimestamp('39.099724','-94.578331','1643803200') .then(data => console.log(data)) .catch(error => console.error(error));
- Get daily Aggregation You can retrieve daily aggregation for a location using its latitude and longitude coordinates, date and timezone:
sdk.dailyAggregation('lat','lon','date','tz') For example:
sdk.dailyAggregation('60.45','-38.67','2023-03-30','+03:00') .then(data => console.log(data)) .catch(error => console.error(error));
- Replace "YOUR_API_KEY_HERE" with your actual OpenWeatherMap API key.