How to call the API
There are multiple ways to interact with the Renewables.Architect Integrate API.
A typical workflow involved interacting directly with the Analysis Service and is described below.
-
Authenticate with the API to obtain an access token.
-
Queue your analysis by sending a Renewables.Architect application definition file (
app.json).You can get application definition payloads in the Applications Library - copy and place them in a new file with a
.jsonextension somewhere on your computer.When queuing your analysis you receive an analysis ID, with which you can then trace progress and results.
terminal curl --request POST https://ra.dnv.com/api/analysis/analyses \--header "Content-Type: application/json" \--header "Authorization: Bearer YOUR_TOKEN_HERE" \--silent --show-error \-d "@{PATH_TO_APP_HERE}"queue_analysis.py import requestsimport jsondef queue_analysis(token: str, json_path: str):with open(json_path, "r") as file:json_data = json.load(file)url = "https://ra.dnv.com/api/analysis/analyses"headers = {"Content-Type": "application/json","Authorization": f"Bearer {token}",}response = requests.post(url, headers=headers, json=json_data)if response.ok:print("Analysis queued successfully:")print(response.json())else:print(f"Error {response.status_code}: {response.text}")if __name__ == "__main__":my_json_path = "PATH_TO_APP_HERE" # Replace with the path to your application definition filemy_token = "YOUR_TOKEN_HERE" # Replace with your actual tokenqueue_analysis(token=my_token, json_path=my_json_path) -
Check analysis progress and logs. To check on the state of your analysis, use the following command and the analysis ID you received after queuing.
terminal curl --request GET https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/state \--header "Content-Type: application/json" \--header "Authorization: Bearer YOUR_TOKEN_HERE" \--silent --show-errorget_analysis_state.py import requestsdef get_analysis_state(token: str, analysis_id: str):url = ("https://ra.dnv.com/api/analysis"f"/analyses/{analysis_id}/state")headers = {"Content-Type": "application/json","Authorization": f"Bearer {token}",}response = requests.get(url, headers=headers)if response.ok:print("Analysis state obtained successfully:")if response.text:print(response.json())else:print(f"Error {response.status_code}: {response.text}")if __name__ == "__main__":my_token = "YOUR_TOKEN_HERE" # Replace with your actual tokenmy_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis IDget_analysis_state(token=my_token, analysis_id=my_analysis_id) -
Get summary and detailed results. The overview results for an entire analysis can be obtained with the following commands. More detailed results for every individual run can be accessed as well, corresponding commands are listed below
terminal curl --request GET https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/runs/results \--header "Content-Type: application/json" \--header "Authorization: Bearer YOUR_TOKEN_HERE" \--silent --show-errorget_analysis_results.py import requestsdef get_analysis_results(token: str, analysis_id: str):url = ("https://ra.dnv.com/api/analysis"f"/analyses/{analysis_id}/runs/results")headers = {"Content-Type": "application/json","Authorization": f"Bearer {token}",}response = requests.get(url, headers=headers)if response.ok:print("Analysis results obtained successfully:")if response.text:print(response.json())else:print(f"Error {response.status_code}: {response.text}")if __name__ == "__main__":my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis IDmy_token = "YOUR_TOKEN_HERE" # Replace with your actual tokenget_analysis_results(token=my_token, analysis_id=my_analysis_id) -
Terminate/cancel a running analysis if required. Cancelling an analysis will allow running runs to finish, whereas terminating stops all runs immediately.
terminal (cancel) curl --request PUT https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/state \--header "Content-Type: application/json" \--header "Authorization: Bearer YOUR_TOKEN_HERE" \--silent --show-error \--data '{"state": "Cancelled"}'cancel_analysis.py import requestsdef cancel_analysis(token: str, analysis_id: str):url = f"https://ra.dnv.com/api/analysis/analyses/{analysis_id}/state"headers = {"Content-Type": "application/json","Authorization": f"Bearer {token}",}response = requests.put(url, headers=headers, json={"state": "Cancelled"})if response.ok:print("Analysis successfully cancelled:")if response.text:print(response.json())else:print(f"Error {response.status_code}: {response.text}")if __name__ == "__main__":my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis IDmy_token = "YOUR_TOKEN_HERE" # Replace with your actual tokencancel_analysis(token=my_token, analysis_id=my_analysis_id)terminal (terminate) curl --request PUT https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/state \--header "Content-Type: application/json" \--header "Authorization: Bearer YOUR_TOKEN_HERE" \--silent --show-error \--data '{"state": "Terminated"}'terminate_analysis.py import requestsdef terminate_analysis(token: str, analysis_id: str):url = f"https://ra.dnv.com/api/analysis/analyses/{analysis_id}/state"headers = {"Content-Type": "application/json","Authorization": f"Bearer {token}",}response = requests.put(url, headers=headers, json={"state": "Terminated"})if response.ok:print("Analysis successfully terminated:")if response.text:print(response.json())else:print(f"Error {response.status_code}: {response.text}")if __name__ == "__main__":my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis IDmy_token = "YOUR_TOKEN_HERE" # Replace with your actual tokenterminate_analysis(token=my_token, analysis_id=my_analysis_id) -
Delete analysis data when no longer needed (optional).
terminal curl --request DELETE https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE \--header "Content-Type: application/json" \--header "Authorization: Bearer YOUR_TOKEN_HERE" \--silent --show-errordelete_analysis.py import requestsdef delete_analysis(token: str, analysis_id: str):url = ("https://ra.dnv.com/api/analysis"f"/analyses/{analysis_id}")headers = {"Content-Type": "application/json","Authorization": f"Bearer {token}",}response = requests.delete(url, headers=headers)if response.ok:print("Analysis successfully deleted:")if response.text:print(response.json())else:print(f"Error {response.status_code}: {response.text}")if __name__ == "__main__":my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis IDmy_token = "YOUR_TOKEN_HERE" # Replace with your actual tokendelete_analysis(token=my_token, analysis_id=my_analysis_id)
Get overview over analyses / Retrieve analysis IDs
Section titled “Get overview over analyses / Retrieve analysis IDs”To get an overview over all analyses listed with your user, please use the following. The received analysis ID(s) will then allow you to follow the steps 3 to 6 above, additional information about the analysis state and submit time allows identification.
curl --request GET https://ra.dnv.com/api/analysis/analyses \ --header "Content-Type: application/json" \ --header "Authorization: Bearer YOUR_TOKEN_HERE" \ --silent --show-errorimport requests
def get_user_analyses(token: str): url = "https://ra.dnv.com/api/analysis/analyses"
headers = { "Content-Type": "application/json", "Authorization": f"Bearer {token}", }
response = requests.get(url, headers=headers)
if response.ok: print("Analyses for this user obtained successfully:") if response.text: print(response.json()) else: print(f"Error {response.status_code}: {response.text}")
if __name__ == "__main__": my_token = "YOUR_TOKEN_HERE" # Replace with your actual token
get_user_analyses(token=my_token)Access individual runs
Section titled “Access individual runs”Get run IDs for an analysis
Section titled “Get run IDs for an analysis”In order to look into an analysis in more detail, it is often helpful to investigate the individual runs. To access them, their run IDs are required, which can be obtained with the following command.
curl --request GET https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/runs \ --header "Content-Type: application/json" \ --header "Authorization: Bearer YOUR_TOKEN_HERE" \ --silent --show-errorimport requests
def get_analysis_run_ids(token: str, analysis_id: str): url = ("https://ra.dnv.com/api/analysis" f"/analyses/{analysis_id}/runs")
headers = { "Content-Type": "application/json", "Authorization": f"Bearer {token}", }
response = requests.get(url, headers=headers)
if response.ok: print("Run IDs for this analysis obtained successfully:") if response.text: print(response.json()) else: print(f"Error {response.status_code}: {response.text}")
if __name__ == "__main__": my_token = "YOUR_TOKEN_HERE" # Replace with your actual token my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis ID get_analysis_run_ids(token=my_token, analysis_id=my_analysis_id)Get run states for an analysis
Section titled “Get run states for an analysis”To not only obtain the run IDs, but also the corresponding state of the run, please use the following.
curl --request GET https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/runs/state \ --header "Content-Type: application/json" \ --header "Authorization: Bearer YOUR_TOKEN_HERE" \ --silent --show-errorimport requests
def get_analysis_run_states(token: str, analysis_id: str): url = ("https://ra.dnv.com/api/analysis" f"/analyses/{analysis_id}/runs/state")
headers = { "Content-Type": "application/json", "Authorization": f"Bearer {token}", }
response = requests.get(url, headers=headers)
if response.ok: print("Run states for this analysis obtained successfully:") if response.text: print(response.json()) else: print(f"Error {response.status_code}: {response.text}")
if __name__ == "__main__": my_token = "YOUR_TOKEN_HERE" # Replace with your actual token my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis ID
get_analysis_run_states(token=my_token, analysis_id=my_analysis_id)Get run logs for an analysis
Section titled “Get run logs for an analysis”In order to understand why a run has failed, or what has happened during the modelling, the run logs can provide useful insight. Use the run ID obtained with one of the methods above.
curl --request GET https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/runs/YOUR_RUN_ID_HERE/logs \ --header "Content-Type: application/json" \ --header "Authorization: Bearer YOUR_TOKEN_HERE" \ --silent --show-errorimport requests
def get_run_logs(token: str, analysis_id: str, run_id: str): url = ("https://ra.dnv.com/api/analysis" f"/analyses/{analysis_id}/runs/{run_id}/logs")
headers = { "Content-Type": "application/json", "Authorization": f"Bearer {token}", }
response = requests.get(url, headers=headers)
if response.ok: print("Run logs obtained successfully:") if response.text: import json print(json.dumps(response.json(), indent=2)) else: print(f"Error {response.status_code}: {response.text}")
if __name__ == "__main__": my_token = "YOUR_TOKEN_HERE" # Replace with your actual token my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis ID my_run_id = "YOUR_RUN_ID_HERE" # Replace with actual run ID
get_run_logs(token=my_token, analysis_id=my_analysis_id, run_id=my_run_id)Get results for an individual run
Section titled “Get results for an individual run”Results for an individual run can be retrieved using the following commands.
curl --request GET https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/runs/YOUR_RUN_ID_HERE/results \ --header "Content-Type: application/json" \ --header "Authorization: Bearer YOUR_TOKEN_HERE" \ --silent --show-errorimport requests
def get_run_results(token: str, analysis_id: str, run_id: str): url = ("https://ra.dnv.com/api/analysis" f"/analyses/{analysis_id}/runs/{run_id}/results")
headers = { "Content-Type": "application/json", "Authorization": f"Bearer {token}", }
response = requests.get(url, headers=headers)
if response.ok: print("Run results obtained successfully:") if response.text: import json print(json.dumps(response.json(), indent=2)) else: print(f"Error {response.status_code}: {response.text}")
if __name__ == "__main__": my_token = "YOUR_TOKEN_HERE" # Replace with your actual token my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis ID my_run_id = "YOUR_RUN_ID_HERE" # Replace with actual run ID
get_run_results(token=my_token, analysis_id=my_analysis_id, run_id=my_run_id)Get figures for an individual run
Section titled “Get figures for an individual run”Figures for an individual run can be retrieved using the following commands.
curl --request GET https://ra.dnv.com/api/analysis/analyses/YOUR_ANALYSIS_ID_HERE/runs/YOUR_RUN_ID_HERE/figures \ --header "Content-Type: application/json" \ --header "Authorization: Bearer YOUR_TOKEN_HERE" \ --silent --show-errorimport requests
def get_run_figures(token: str, analysis_id: str, run_id: str): url = ("https://ra.dnv.com/api/analysis" f"/analyses/{analysis_id}/runs/{run_id}/figures")
headers = { "Content-Type": "application/json", "Authorization": f"Bearer {token}", }
response = requests.get(url, headers=headers)
if response.ok: print("Run figures obtained successfully:") if response.text: import json print(json.dumps(response.json(), indent=2)) else: print(f"Error {response.status_code}: {response.text}")
if __name__ == "__main__": my_token = "YOUR_TOKEN_HERE" # Replace with your actual token my_analysis_id = "YOUR_ANALYSIS_ID_HERE" # Replace with actual analysis ID my_run_id = "YOUR_RUN_ID_HERE" # Replace with actual run ID
get_run_figures(token=my_token, analysis_id=my_analysis_id, run_id=my_run_id)