Demo🌞
Live Glitch 🌞Solcast TypeScript API Client library
TypeScript library for querying the Solcast API async/Promise based
This module allows a registered users to query the Solcast API https://api.solcast.com.au. You will need to register your user account to obtain an API key https://solcast.com.au/api/register. Without an API key you will not be able to successfully obtain valid API results.
API async/Promise based
Power.forecast(LatLng point, PowerOptions options?)
Returns a PowerForecast promise at the location of the LatLng point input
Radiation.forecast(LatLng point, RadiationOptions options?)
Return RadiationForecast promise at the location of the LatLng point input
Examples
NOTE:
You can use standard environment variables to hold your API key and not need to pass the optional {Radiation|Power}Options object to each function
Environment variable names
SOLCAST_API_KEY
SOLCAST_API_URL
Accessible through common process environment variable.
process.env.SOLCAST_API_KEY
process.env.SOLCAST_API_URL
Typescript
;const point = solcast; // Sydney, Australiaconst radiationOptions = solcastOptions;radiationOptionsAPIKey = 'YOUR API KEY HERE';const promiseFn = solcastRadiation;promiseFn;
Javascript Radiation async
const solcast = ;const point = solcast; // Sydney, Australiaconst radiationOptions = solcastOptions;radiationOptionsAPIKey = 'YOUR API KEY HERE';const fn = {return await solcastRadiation};;
Javascript Radiation Promise
const solcast = ;const point = solcast; // Sydney, Australiaconst radiationOptions = solcastOptions;radiationOptionsAPIKey = 'YOUR API KEY HERE';const results = solcastRadiation;results;
JSON sample results
{ forecasts:
[ { ghi: 0,
ghi90: 0,
ghi10: 0,
ebh: 0,
dni: 0,
dni10: 0,
dni90: 0,
dhi: 0,
air_temp: 10,
zenith: 103,
azimuth: -88,
cloud_opacity: 3,
period_end: '2017-08-31T19:30:00.0000000Z',
period: 'PT30M' },
...
]
}
Development note
- Copy
.env.json.sample
to.env.json
- Set
SOLCAST_API_KEY
on json file after register from https://solcast.com.au/api/register/