Modules@robinpath/weather
weather

@robinpath/weather

0.1.1Node.jsPublic

Weather module for RobinPath.

Weather

Weather module for RobinPath.

Package: @robinpath/weather | Category: Other | Type: Utility

Authentication

weather.setCredentials "your-credentials"

Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the weather module when you need to:

  • getCurrentWeather -- Use weather.getCurrentWeather to perform this operation
  • getForecast -- Use weather.getForecast to perform this operation
  • get5DayForecast -- Use weather.get5DayForecast to perform this operation
  • getHourlyForecast -- Use weather.getHourlyForecast to perform this operation
  • getAirQuality -- Use weather.getAirQuality to perform this operation

Quick Reference

FunctionDescriptionReturns
setCredentialsConfigure weather credentials.object
getCurrentWeathergetCurrentWeatherobject
getForecastgetForecastobject
get5DayForecastget5DayForecastobject
getHourlyForecastgetHourlyForecastobject
getAirQualitygetAirQualityobject
getUVIndexgetUVIndexobject
getWeatherByZipgetWeatherByZipobject
getHistoricalWeathergetHistoricalWeatherobject
getWeatherAlertsgetWeatherAlertsobject
geocodeCitygeocodeCityobject
reverseGeocodereverseGeocodeobject
getWeatherMapgetWeatherMapobject

Functions

setCredentials

Configure weather credentials.

Module: weather | Returns: object -- API response.

weather.setCredentials
ParameterTypeRequiredDescription
apiKeystringYesapiKey

getCurrentWeather

getCurrentWeather

Module: weather | Returns: object -- API response.

weather.getCurrentWeather
ParameterTypeRequiredDescription
inputstringNoInput parameter

getForecast

getForecast

Module: weather | Returns: object -- API response.

weather.getForecast
ParameterTypeRequiredDescription
inputstringNoInput parameter

get5DayForecast

get5DayForecast

Module: weather | Returns: object -- API response.

weather.get5DayForecast
ParameterTypeRequiredDescription
inputstringNoInput parameter

getHourlyForecast

getHourlyForecast

Module: weather | Returns: object -- API response.

weather.getHourlyForecast
ParameterTypeRequiredDescription
inputstringNoInput parameter

getAirQuality

getAirQuality

Module: weather | Returns: object -- API response.

weather.getAirQuality
ParameterTypeRequiredDescription
inputstringNoInput parameter

getUVIndex

getUVIndex

Module: weather | Returns: object -- API response.

weather.getUVIndex
ParameterTypeRequiredDescription
inputstringNoInput parameter

getWeatherByZip

getWeatherByZip

Module: weather | Returns: object -- API response.

weather.getWeatherByZip
ParameterTypeRequiredDescription
inputstringNoInput parameter

getHistoricalWeather

getHistoricalWeather

Module: weather | Returns: object -- API response.

weather.getHistoricalWeather
ParameterTypeRequiredDescription
inputstringNoInput parameter

getWeatherAlerts

getWeatherAlerts

Module: weather | Returns: object -- API response.

weather.getWeatherAlerts
ParameterTypeRequiredDescription
inputstringNoInput parameter

geocodeCity

geocodeCity

Module: weather | Returns: object -- API response.

weather.geocodeCity
ParameterTypeRequiredDescription
inputstringNoInput parameter

reverseGeocode

reverseGeocode

Module: weather | Returns: object -- API response.

weather.reverseGeocode
ParameterTypeRequiredDescription
inputstringNoInput parameter

getWeatherMap

getWeatherMap

Module: weather | Returns: object -- API response.

weather.getWeatherMap
ParameterTypeRequiredDescription
inputstringNoInput parameter

Error Handling

All functions throw on failure. Common errors:

ErrorCause
Weather API error (${res.status}): ${t}Check the error message for details
weather.setCredentials requires apiKey.Check the error message for details
Weather: "..." not configured. Call weather.setCredentials first.Check the error message for details
@desc "Get current weather and validate result"
do
  set $result as weather.getCurrentWeather
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate CurrentWeather

Retrieve all items and loop through them.

@desc "Setup authentication"
do
  weather.setCredentials $token
enddo

@desc "Get current weather and iterate results"
do
  set $result as weather.getCurrentWeather
  each $item in $result
    print $item
  end
enddo

2. Multi-step Weather workflow

Chain multiple weather operations together.

@desc "Setup authentication"
do
  weather.setCredentials $token
enddo

@desc "Get current weather, get forecast, and more"
do
  set $r_getCurrentWeather as weather.getCurrentWeather
  set $r_getForecast as weather.getForecast
  set $r_get5DayForecast as weather.get5DayForecast
  print "All operations complete"
enddo

3. Safe getCurrentWeather with validation

Check results before proceeding.

@desc "Setup authentication"
do
  weather.setCredentials $token
enddo

@desc "Get current weather and validate result"
do
  set $result as weather.getCurrentWeather
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/weather

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size4.0 KB
Versions1
Weekly Downloads21
Total Downloads21
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

utilities