Giter VIP home page Giter VIP logo

solcast-ts's Introduction

Build Status NPM:

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 {
    forecasts: Forecast[];
}

export interface Forecast {
    period_end: Date;
    period: string;
    pv_estimate: number;
}

Radiation.forecast(LatLng point, RadiationOptions options?)

Return RadiationForecast promise at the location of the LatLng point input

export interface RadiationForecast {
    forecasts: Forecast[];
}

export interface Forecast {
    ghi: number;
    ghi90: number;
    ghi10: number;
    ebh: number;
    dni: number;
    dni10: number;
    dni90: number;
    dhi: number;
    air_temp: number;
    zenith: number;
    azimuth: number;
    cloud_opacity: number;
    period_end: Date;
    period: string;
}

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/

solcast-ts's People

Contributors

dhoeric avatar siliconrob avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.