solcast ts
NPM release
مكتبة TypeScript للاستعلام عن Solcast API Async/Promise على أساس
تتيح هذه الوحدة للمستخدمين المسجلين الاستعلام عن API solcast https://api.solcast.com.au. ستحتاج إلى تسجيل حساب المستخدم الخاص بك للحصول على مفتاح API https://solcast.com.au/api/register. بدون مفتاح API ، لن تتمكن من الحصول على نتائج API صالحة بنجاح.
إرجاع وعد powerforecast في موقع إدخال نقطة latlng
export interface PowerForecast {
forecasts: Forecast [ ] ;
}
export interface Forecast {
period_end: Date ;
period: string ;
pv_estimate: number ;
} إرجاع الوعود radiationforecast في موقع إدخال نقطة 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.jsonSOLCAST_API_KEY على ملف JSON بعد التسجيل من https://solcast.com.au/api/register/