weather-au-api
NodeJS API library for accessing api.weather.bom.gov.au
This API is inspired by tonyallan/weather-au.
As the API is reversed engineered from the usage in https://weather.bom.gov.au with no information about future access arrangements or availability, use this module as your own risks.
Installation
Through npm
:
npm install weather-au-api
Through yarn
:
yarn install weather-au-api
Example Usage
let Api = require('weather-au-api');
let api = new Api();
# Set your current location
api.search('3053');
# Retrieve the daily forecasts for the next 7 days
let resp = await api.forecasts_daily();
console.log(resp)
Usage
Set the geohash (optional)
api = new Api(geohash)
When initialising a new Api
object, a geohash
can be optionally provided.
This will bypass the need to use the search()
function to set location.
# Set the location to Carlton, VIC
api = new Api('r1r0fyd');
Set the search location
api.search(string)
Search by post code or location string and set the geohash
location to first location returned through the API.
When searching using location string, join the terms with +
.
Return a JSON list of locations found.
carlton = await api.search('3053');
console.log(carlton.data);
carlton2 = await api.search('Carlton+VIC');
console.log(carlton2);
Get the daily forecasts
api.forecasts_daily()
Get bom.gov.au daily forecasts for the next 7-8 days.
A geohash
must be set when initialising or through running api.search()
.
Return a JSON list of daily forecasts.
forecasts = await api.forecasts_daily();
console.log(forecasts);
Get warnings
api.warnings()
Get bom.gov.au current warnings. Might be empty if there is no warnings for current location.
A geohash
must be previously set.
Return a JSON list of warnings.
warnings = await api.warnings();
console.log(warnings);
Get specific warning
api.warning(warning_id)
Get the warning with warning_id
. Get warning_id
from api.warnings()
.
Return a JSON object.
warning = await api.warning('VIC_RC022_IDV36310');
console.log(warning);
Get observations reading
api.observations()
Get the observations reading for the current location.
Return a JSON object.
observations = await api.observations();
console.log(observations);
Get last response timestamp
api.response_timestamp()
Get the last response timestamp.
timestamp = api.response_timestamp()