accuweather-api v1.0.2
Accuweather API
Introduction
This package provides a TypeScript-based API for interacting with Accuweather, allowing developers to fetch various weather-related data.
Installation
To install the package, use the following command:
npm install accuweather-apiUsage
First, import the Accuweather class from the package:
import { Accuweather } from 'accuweather-api';Then, initialize the class with your API keys:
const accuweather = new Accuweather('YOUR_API_KEY', 'YOUR_SECOND_API_KEY', 'YOUR_PREFERRED_LANGUAGE');Available Methods
Here are the available methods for fetching weather data:
fetchAdminAreas
Fetch administrative areas based on a country code.
accuweather.fetchAdminAreas('US').then(data => console.log(data));fetchDailyForecast
Fetch daily forecast data for a specific location.
accuweather.fetchDailyForecast('YOUR_LOCATION_KEY', 5).then(data => console.log(data));fetchHourlyForecast
Fetch hourly forecast data for a specific location.
accuweather.fetchHourlyForecast('YOUR_LOCATION_KEY', 24).then(data => console.log(data));fetchCurrentConditions
Fetch the current weather conditions for a specific location.
accuweather.fetchCurrentConditions('YOUR_LOCATION_KEY').then(data => console.log(data));fetchHistoricalCurrentConditions
Fetch historical current conditions for a specific location.
accuweather.fetchHistoricalCurrentConditions('YOUR_LOCATION_KEY', 6).then(data => console.log(data));fetchOneDayIndexForAllIndices
Fetch daily index data for all indices for a specific location.
accuweather.fetchOneDayIndexForAllIndices('YOUR_LOCATION_KEY').then(data => console.log(data));fetchOneDayIndexForSpecificIndex
Fetch daily index data for a specific index.
accuweather.fetchOneDayIndexForSpecificIndex('YOUR_LOCATION_KEY', 'YOUR_INDEX_ID').then(data => console.log(data));fetchOneDayIndexForSpecificGroup
Fetch daily index data for a specific group.
accuweather.fetchOneDayIndexForSpecificGroup('YOUR_LOCATION_KEY', 'YOUR_GROUP_ID').then(data => console.log(data));Types
The package provides several TypeScript types for representing different weather-related data. Some of the main types include AdminAreaType, WeatherUnitType, SunMoon, Temperature, Wind, Precipitation, DailyForecast, and CurrentConditions.