weatherapi-sdk
v1.0.0
Published
This SDK allows you to interact with the OpenWeatherMap API to fetch weather data.
Downloads
4
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 apiweather-sdk
Usage
First, initialize the SDK with your OpenWeatherMap API key: const APIWeatherSDK = require('apiweather-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') .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') .then(data => console.log(data)) .catch(error => console.error(error));
- Replace "YOUR_API_KEY_HERE" with your actual OpenWeatherMap API key.