puter.drivers.call("weather", ...)
Get current weather or weather forecast from weatherapi.com.
Note: links in this documentation will not go directly to the relevant location on their respective page because of a lack of anchor links
The weather
driver has two methods:
weather
forecast
weather
The weather
method has a default parameter called q
, which is the "query"
for the weather location. It supports coordinates, zip/postal code, city names,
and any other input specified in the weatherapi docs.
Because the weather
method has the same name as its respective driver, it is
not necessary to specify both the driver and method name.
// Using the default parameter
puter.call('weather', 'Ottawa');
// Using named parameters
puter.call('weather', { q: 'Ottawa' });
// Specifying both the driver and method name.
puter.call('weather', 'weather', { q: 'Ottawa' })
forecast
The weather
driver also has a method called forecast
. To use this, specify
"weather" as the name of the interface, and then "forecast" as the name of the
method. This requires passing at least three arguments to .call()
.
// Using default parameter `q`
puter.call('weather', 'forecast', 'Ottawa');
// Using named parameter `q`
puter.call('weather', 'forecast', { q: 'Ottawa' });
Parameters are the same as on the weatherapi.com /current.json endpoint
weather
method
Return value structure matches the Current object.
forecast
method
Return value structure matches the Forecast object.