Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
I don't work for a solar company but QuickBase is so successful in this industry I have been thinking about starting my own solar company. QuickBase can easily handle this task without involving an external service.
Normally, one web site cannot access data from another web site because of a policy all browsers implement called the Same Origin Policy. However, the good folks over at National Renewable Energy Laboratory (NREL) have made their API work across domains by including a special header in their response that allows access from all domains:
Access-Control-Allow-Origin: *
Because of this you can directly call this API from QuickBase without involving an intermediate server.
This is the essential code that will call the API and populate 12 fields with fids 6 through 17 with the ac-monthly values:
I am tied up at the moment starting my own solar company but if you need additional help with this task feel free to contact me off-world using the information in my profile:
https://getsatisfaction.com/people/dandiebolt
Normally, one web site cannot access data from another web site because of a policy all browsers implement called the Same Origin Policy. However, the good folks over at National Renewable Energy Laboratory (NREL) have made their API work across domains by including a special header in their response that allows access from all domains:
Access-Control-Allow-Origin: *
Because of this you can directly call this API from QuickBase without involving an intermediate server.
This is the essential code that will call the API and populate 12 fields with fids 6 through 17 with the ac-monthly values:
var url = "https://developer.nrel.gov/api/pvwatts/v6.xml";You can run this code from the console on an add or edit form assuming you have specified your 12 fid values. A complete solution would involve implementing the IOL technique and the appropriate logic to assign the input parameters in the URL.
url += "?api_key=DEMO_KEY";
url += "&address=1600 Ampitheater Parkway, Mountain View, California";
url += "&system_capacity=3.05";
url += "&azimuth=180";
url += "&tilt=18.43";
url += "&array_type=1";
url += "&module_type=1";
url += "&losses=11.72";
var fids = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17];
$.get(url, function(xml) {
console.dirxml(xml);
$("response outputs ac-monthly[type=array] ac-monthly[type=float]", xml).each(function(index) {
console.log('_fid_${fids[index]}', $(this).text());
$('#_fid_${fids[index]}').val($(this).text());
});
});
I am tied up at the moment starting my own solar company but if you need additional help with this task feel free to contact me off-world using the information in my profile:
https://getsatisfaction.com/people/dandiebolt
- JohnRogers37 years agoQrew TraineeIs Access-Control-Allow-Origin _a type of substitution to a Bearer token?
- _anomDiebolt_7 years agoQrew EliteNo. An Access-Control-Allow-Origin header is included in the response from the server indicating if the server will allow cross domain access,