Import from and Export to API JSON
When you run a calculation from the desktop SolarFarmer application in the cloud, input files are generated first (including a JSON file which describes the main PV plant configuration), which are then sent to the SolarFarmer API. Most users of the SolarFarmer desktop application use the API this way and don't need to know the details of what is sent.
Some users like to generate their own API input files from their own scripts. This can make it easier for them to integrate the SolarFarmer API into their own workflows without having to interact with the desktop application.
You can import these user-created API files into the SolarFarmer application to create a workbook. This can be a good way to transition from a potentially simple site configuration described in the API JSON to a more involved site design in the desktop application.
Note that only the workbook elements that are used for the calculation are exported in the API JSON. Specific desktop features such as map layers, multiple site layouts, terrain, are not exported and cannot be imported this way.
Note
The following import functionality only works for 2D API calculations. The import of 3D API calculations will be supported in future.
Import from API JSON
Import from API JSON using the UI
You can import from a 2D API JSON file through the following menu option in the UI:
Click on the 'File > Import from API JSON...' menu option:
The 'Import from API JSON' dialog appears. Browse for the API JSON file you wish to import:
Click the green 'Import' button to start the import process.
The import will happen. Output of what it has imported appears in the Output panel below. Any errors will also appear here:
On successful import the workbook will be filled with the appropriate content, including the site location, time zone, horizon, solar resource data, components, layouts, and energy calculation options.
You are then free to modify the workbook as you like. Import terrain. Create more complex site designs. Run the 3D API.
Import from API JSON using scripting
The Toolbox.Import.PopulateWorkbookFromSolarFarmerApiInputFile scripting function allows you to import from an API JSON file.
Toolbox.Import.PopulateWorkbookFromSolarFarmerApiInputFile(string inputFilePath);
Export to API JSON
Export to API JSON using the UI
You can now do this export through a menu option in the UI - slightly easier than creating and running a script:
Click on the 'File > Export to API JSON...' menu option:
Select a folder to export the API files
The files of your current workbook configuration will be generated and saved to the folder you specify.
Export to API JSON using scripting
This is available through the scripting command Toolbox.GenerateCloudEnergyCalculationInputFiles:
Toolbox.GenerateCloudEnergyCalculationInputFiles(string folderPathToSaveFiles);