Class OpenWeatherAPI

Hierarchy

  • OpenWeatherAPI

Constructors

  • Constructor of the class. You can specify global options here

    Returns

    OpenWeatherAPI object

    Parameters

    • globalOptions: Options = {}

      object that defines global options

    Returns OpenWeatherAPI

Properties

globalOptions: Options

Methods

  • Parameters

    • options: Options
    • path: string = ""
    • additionalParams: Record<string, string> = {}

    Returns string

  • Parameters

    • lang: unknown

    Returns "id" | "hr" | "th" | "tr" | "af" | "al" | "ar" | "az" | "bg" | "ca" | "cz" | "da" | "de" | "el" | "en" | "eu" | "fa" | "fi" | "fr" | "gl" | "he" | "hi" | "hu" | "it" | "ja" | "kr" | "la" | "lt" | "mk" | "no" | "nl" | "pl" | "pt" | "pt_br" | "ro" | "ru" | "sv" | "se" | "sk" | "sl" | "sp" | "es" | "sr" | "ua" | "uk" | "vi" | "zh_cn" | "zh_tw" | "zu"

  • Parameters

    • name: unknown
    • key: string

    Returns Promise<{
        lat: any;
        lon: any;
    }>

  • Parameters

    • zipCode: unknown
    • key: string

    Returns Promise<{
        lat: any;
        lon: any;
    }>

  • Parameters

    • units: unknown

    Returns "standard" | "metric" | "imperial"

  • Parameters

    • url: string

    Returns Promise<Resp>

  • Getter for alerts
    Note: some agencies provide the alert’s description only in a local language.

    Returns

    alerts

    Parameters

    • options: Options = {}

      options used only for this call

    Returns Promise<Alert[]>

  • Getter for locations from query

    Returns

    all found locations

    Parameters

    • query: string

      query used to search the locations (q parameter here)

    • options: Options = {}

      options used only for this call

    Returns Promise<Location[]>

  • Getter for current weather

    Returns

    weather object of current weather

    Parameters

    • options: Options = {}

      options used only for this call

    Returns Promise<CurrentWeather>

  • Getter for current data about air pollution

    Returns

    Air Pollution Object with data about current pollution

    Parameters

    • options: Options = {}

      options used only for this call

    Returns Promise<AirPollution>

  • Getter for daily weather

    Returns

    array of Weather objects, one for every next day (Empty if API returned no info about daily weather)

    Parameters

    • limit: number = Number.POSITIVE_INFINITY

      maximum length of returned array

    • includeToday: boolean = false

      boolean indicating whether to include today's weather in returned array

    • options: Options = {}

      options used only for this call

    Returns Promise<DailyWeather[]>

  • Getter for every type of weather call and alerts

    Returns

    object that contains everything

    Parameters

    • options: Options = {}

      options used only for this call

    Returns Promise<Everything>

  • Getter for forecasted weather

    Returns

    array of Weather objects, one for every 3 hours, up to 5 days

    Parameters

    • limit: number = Number.POSITIVE_INFINITY

      maximum length of returned array

    • options: Options = {}

      options used only for this call

    Returns Promise<ForecastWeather[]>

  • Getter for future data about air pollution

    Returns

    Array of Air Pollution Objects with data about future pollution

    Parameters

    • limit: number = Number.POSITIVE_INFINITY

      maximum length of returned array

    • options: Options = {}

      options used only for this call

    Returns Promise<AirPollution[]>

  • Getter for historical data about weather

    Parameters

    • dt: string | number | Date

      Date from the previous five days (Unix time, UTC time zone)

    • options: Options = {}

      options used only for this call

    Returns Promise<HistoricalWeather>

  • Getter for historical data about air pollution WARNING: Historical data is accessible from 27th November 2020

    Returns

    Array of Air Pollution Objects with data about historical pollution

    Parameters

    • from: string | number | Date

      Start date (unix time, UTC time zone)

    • to: string | number | Date

      End date (unix time, UTC time zone)

    • options: Options = {}

      options used only for this call

    Returns Promise<AirPollution[]>

  • Getter for hourly weather

    Returns

    array of Weather objects, one for every next hour (Empty if API returned no info about hourly weather)

    Parameters

    • limit: number = Number.POSITIVE_INFINITY

      maximum length of returned array

    • options: Options = {}

      options used only for this call

    Returns Promise<HourlyWeather[]>

  • Getter for global key

    Returns

    global API key

    Returns undefined | string

  • Getter for global language

    Returns

    global language

    Returns undefined | "id" | "hr" | "th" | "tr" | "af" | "al" | "ar" | "az" | "bg" | "ca" | "cz" | "da" | "de" | "el" | "en" | "eu" | "fa" | "fi" | "fr" | "gl" | "he" | "hi" | "hu" | "it" | "ja" | "kr" | "la" | "lt" | "mk" | "no" | "nl" | "pl" | "pt" | "pt_br" | "ro" | "ru" | "sv" | "se" | "sk" | "sl" | "sp" | "es" | "sr" | "ua" | "uk" | "vi" | "zh_cn" | "zh_tw" | "zu"

  • Getter for location

    Returns

    location or null for no location

    Parameters

    • options: Options = {}

      options used only for this call

    Returns Promise<null | Location>

  • Getter for minutely weather

    Returns

    array of Weather objects, one for every next minute (Empty if API returned no info about minutely weather)

    Parameters

    • limit: number = Number.POSITIVE_INFINITY

      maximum length of returned array

    • options: Options = {}

      options used only for this call

    Returns Promise<MinutelyWeather[]>

  • Getter for today's weather

    Returns

    weather object of today's weather NOT the same as current!

    Parameters

    • options: Options = {}

      options used only for this call

    Returns Promise<DailyWeather>

  • Getter for global units

    Returns

    global units

    Returns undefined | "standard" | "metric" | "imperial"

  • Sets global API key

    Parameters

    • key: string

      api key

    Returns void

  • Sets global language (Language must be listed here)

    Parameters

    • lang: "id" | "hr" | "th" | "tr" | "af" | "al" | "ar" | "az" | "bg" | "ca" | "cz" | "da" | "de" | "el" | "en" | "eu" | "fa" | "fi" | "fr" | "gl" | "he" | "hi" | "hu" | "it" | "ja" | "kr" | "la" | "lt" | "mk" | "no" | "nl" | "pl" | "pt" | "pt_br" | "ro" | "ru" | "sv" | "se" | "sk" | "sl" | "sp" | "es" | "sr" | "ua" | "uk" | "vi" | "zh_cn" | "zh_tw" | "zu"

      language

    Returns void

  • Sets global location by provided coordinates

    Parameters

    • lat: number

      latitude of the location

    • lon: number

      longitude of the location

    Returns void

  • Sets global location by provided name

    Parameters

    • name: string

      name of the location (q parameter here)

    Returns void

  • Sets global location by provided zip/post code

    Parameters

    • zipCode: string

      zip/post code and country code divided by comma (zip parameter here)

    Returns void

  • Sets global units

    Parameters

    • units: "standard" | "metric" | "imperial"

      units (Only standard, metric or imperial are supported)

    Returns void

  • Returns Promise<void>

Generated using TypeDoc