Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/openweather_apis_wrapper/src/mod.ts>OpenWeatherClient

A wrapper for the APIs provided by OpenWeather
Latest
class OpenWeatherClient
import { OpenWeatherClient } from "https://deno.land/x/openweather_apis_wrapper@v0.4.4/src/mod.ts";

OpenWeather APIs wrapper client.

Constructors

new
OpenWeatherClient(options: OpenWeatherClientOptions)

OpenWeather APIs wrapper client.

Properties

apiKey: string

Your OpenWeather API key.

apiUrl

The url to use for the OpenWeather API.

By default it uses OpenWeatherClient.baseAPIUrl (https://api.openweathermap.org), but you can customize it using OpenWeatherClientOptions.apiUrl

cacheHandler: CacheHandler
defaults: { units?: Units; lang?: Lang; coordinates?: Coordinates; }

Methods

getCoordinatesByLocationName(query: string, limit?: number): Promise<CoordinatesByLocationName[]>

Gives you the coordinates of a location by its name.

Gives you the coordinates of a place by its zip or post code.

getCurrentWeather(
coordinates?: Coordinates,
units?: Units,
lang?: Lang,
): Promise<CurrentWeather>

Gives you the current weather data for the given coordinates.

getForecast5days3hours(
coordinates?: Coordinates,
cnt?: number,
units?: Units,
lang?: Lang,
): Promise<Forecast5days3hours>
getLocationNameByCoordinates(coordinates?: Coordinates, limit?: number): Promise<LocationNameByCoordinates[]>
sendRequest(api: APIS, endpoint: string): Promise<unknown>

Use it only if really needed.

Check first if there is not already a method that suits your needs.

setDefaultCoordinates(coordinates?: Coordinates): this

Set the default coordinates to use in certain methods.

Set to undefined or null if you want to remove the default coordinates.

setDefaultLang(lang?: Lang): this

Set the default language to use in certain methods.

Set to undefined or null if you want to remove the default language.

setDefaultUnits(units?: Units): this

Set the default units to use in certain methods.

Set to undefined or null if you want to remove the default units.

Static Properties

baseAPIUrl: string

The default url for the OpenWeather API.