ClearWeather API
Clear Weather API transforms OpenWeather Map OneCall data into human-readable code so you can get to building apps faster.
I built this library to make it easier to use the ClearWeather API.
Learn more about the Clear Weather API.
Features
- Data Transformation (Premium)
- Caching (Premium)
- Cool Weather Icons
- Limit errors with types for all weather data
- This package will make it smooth and easy to develop
You do need to be a premium user to access transformed data and caching. However if you would like to do the transformations yourself feel free to use this package and take advantage of the
intelisense you will get for all the weather data. Just sign up at Clear Weather API to get your free userId to access the API
Getting Started
You need an OpenWeather Map API key to use this library, and you can get one by signing up at Open Weather Map.
You can get more information about the One Call API at Open Weather Map.
Installation
npm
npm install clearweatherapi
yarn
yarn add clearweatherapi
Usage
Instantiate Weather class and pass options to it.
const options = {
openWeatherApiKey: 'YOUR_OPENWEATHER_API_KEY',
userId: 'YOUR-CLEATHERWEATHERAPI-USERID',
cacheTime: 4800,
formated: false,
lang: 'en',
units: 'imperial',
version: '3.0'
coords: {
latitude: "",
longitude: "",
},
}
const weather = new Weather(options);
Current weather
const current = await weather.fetchCurrentWeather();
Daily weather
const daily = await weather.fetchDailyWeather();
Hourly weather
const hourly = await weather.fetchHourlyWeather();
Weather alerts
const alerts = await weather.fetchAlerts();
Icons
Icons are available for premium users and can be found
in each weather data object.
If you are not a premium user you can get more information on how to fetch the icons here.