1.1.0 • Published 8 months ago

openweathermap-fetcher v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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 1. Go to openweathermap website. 2. Create an free account. 3. 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

  1. fetchWeatherDataByCityName(cityName:string) The method will fetch the weather data by taking cityname as an argument and returns weather data.

  2. fetchWeatherDataByCoordinates(latitude:string,longitude:string) This method will fetch the weather data by taking longitude and latitude as an argument and returns weather data.

  3. fetchForecastDataByCityName(cityName:string) The method will fetch the forecast data by taking cityname as an argument and returns weather data.

  4. 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.

1.1.0

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago