solcast ts
NPM release
Solcast API Async/Promise 기반 쿼리를위한 TypeScript 라이브러리
이 모듈을 사용하면 등록 된 사용자가 Solcast API https://api.solcast.com.au를 쿼리 할 수 있습니다. API 키 https://solcast.com.au/api/register를 얻으려면 사용자 계정을 등록해야합니다. API 키가 없으면 유효한 API 결과를 성공적으로 얻을 수 없습니다.
latlng 지점 입력의 위치에서 Powerforecast 약속을 반환합니다.
export interface PowerForecast {
forecasts: Forecast [ ] ;
}
export interface Forecast {
period_end: Date ;
period: string ;
pv_estimate: number ;
} Latlng 지점 입력의 위치에서 방사선 강화 약속을 반환합니다.
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 ;
}표준 환경 변수를 사용하여 API 키를 유지하고 선택 사항 {Radiation | Power} 옵션 개체를 각 함수에 전달할 필요가 없습니다.
환경 변수 이름
SOLCAST_API_KEY
SOLCAST_API_URL
일반적인 프로세스 환경 변수를 통해 액세스 할 수 있습니다.
process.env.SOLCAST_API_KEY
process.env.SOLCAST_API_URL
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 ) ;
} ) ; 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 ) ;
} ) ; 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 ) ;
} ) ; { 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' },
...
]
}
.env.json.sample 을 .env.json 으로 복사하십시오SOLCAST_API_KEY 설정하십시오.