Openweathermap-fetcher
A fetcher for openweathermap api.Currently in initial stage.
Prerequisite
To use this package API key of openweathermap is needed. To get this you need to
- Go to openweathermap website.
- Create an free account.
- Login wto your account and get the API Key.
currently tested on free account openweather API.
Installation
you can install this package using below npm command
npm install openweathermap-fetcher
or
yarn add openweathermap-fetcher
Usage
import { OpenWeatherMap } from 'openweathermap-fetcher';
const apiKey='your_api_key';
const openweathermap = new OpenWeatherMap({apiKey});
async function run() {
try {
const data = await openweathermap.fetchWeatherDataByCityName("Delhi");
console.log("API Result:", data);
} catch (error) {
console.error("API Error:", error.message);
}
}
run();
Method
-
fetchWeatherDataByCityName(cityName:string)
The method will fetch the weather data by taking cityname as an argument and returns weather data.
-
fetchWeatherDataByCoordinates(latitude:string,longitude:string)
This method will fetch the weather data by taking longitude and latitude as an argument and returns weather data.
-
fetchForecastDataByCityName(cityName:string)
The method will fetch the forecast data by taking cityname as an argument and returns weather data.
-
fetchForecastDataByCoordinates(latitude:string,longitude:string)
This method will fetch the forecast data by taking longitude and latitude as an argument and returns weather data.
Contribution
We welcome contributions! If you'd like to contribute to openweathermap-wrapper, please follow our Contribution Guidelines.
Author
Subramanya KS
License
This project is licensed under the MIT License - see the LICENSE file for details.