solcast
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Build Status NPM: Join the chat at https://gitter.im/solcast-ts/Lobby

Live Glitch 🌞Demo🌞

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

export interface PowerForecast {
    forecastsForecast[];
}
 
export interface Forecast {
    period_endDate;
    periodstring;
    pv_estimatenumber;
}

Radiation.forecast(LatLng point, RadiationOptions options?)

Return RadiationForecast promise at the location of the LatLng point input

export interface RadiationForecast {
    forecastsForecast[];
}
 
export interface Forecast {
    ghinumber;
    ghi90number;
    ghi10number;
    ebhnumber;
    dninumber;
    dni10number;
    dni90number;
    dhinumber;
    air_tempnumber;
    zenithnumber;
    azimuthnumber;
    cloud_opacitynumber;
    period_endDate;
    periodstring;
}

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

import * as solcast from 'solcast';
 
const point = solcast.latLng(-33.865143, 151.209900); // Sydney, Australia
 
const radiationOptions = solcast.Options.radiation();
radiationOptions.APIKey = 'YOUR API KEY HERE';
 
const promiseFn = solcast.Radiation.forecast(point, radiationOptions);
promiseFn.then(results => {
    console.log(results);
})
.catch(err => {
    console.log(err);
});
 

Javascript Radiation async

const solcast = require('solcast');
const point = solcast.latLng(-33.865143, 151.209900); // Sydney, Australia
const radiationOptions = solcast.Options.radiation();
radiationOptions.APIKey = 'YOUR API KEY HERE';
const fn = async function() {
    return await solcast.Radiation.forecast(point, radiationOptions)
};
fn().then(results => {
    console.log(results);
})
.catch(err => {
    console.log(err);
});

Javascript Radiation Promise

const solcast = require('solcast');
const point = solcast.latLng(-33.865143, 151.209900); // Sydney, Australia
const radiationOptions = solcast.Options.radiation();
radiationOptions.APIKey = 'YOUR API KEY HERE';
const results = solcast.Radiation.forecast(point, radiationOptions);
results.then(results => {
    console.log(results);
})
.catch(err => {
    console.log(err);
});

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

  1. Copy .env.json.sample to .env.json
  2. Set SOLCAST_API_KEY on json file after register from https://solcast.com.au/api/register/

Package Sidebar

Install

npm i solcast

Weekly Downloads

7

Version

0.0.6

License

MIT

Last publish

Collaborators

  • siliconrob