ERP results from API #173
Answered
by
bpulluta
Johanna1907
asked this question in
1 - General REopt Questions
|
Hi, community, I am using the API but cannot find a way to get the ERP results I can run on the web tool. Thank you in advance for your help |
Answered by
bpulluta
Jun 27, 2025
Replies: 2 comments
|
I've never used it in the API but it looks like it's there:
This returns the structure of the input file for ERP analysis: |
0 replies
Here's an example of how to use it: Basic Setupimport requests
import time
API_KEY = 'YOUR_API_KEY_HERE' # Get from developer.nrel.gov
base_url = "https://developer.nrel.gov/api/reopt/stable"Step 1: Run REopt Optimization# Basic REopt inputs
reopt_inputs = {
"Site": {"latitude": 37.77, "longitude": -122.42},
"ElectricLoad": {
"doe_reference_name": "LargeOffice",
"annual_kwh": 6000000,
"critical_load_percent": 0.5
},
"ElectricTariff": {"urdb_label": "YOUR_UTILITY_RATE"},
"ElectricUtility": {
"outage_start_time_steps": [1000, 3000, 5000],
"outage_durations": 24
},
"PV": {"max_kw": 10000},
"ElectricStorage": {"max_kw": 5000, "max_kwh": 20000}
}
# Submit and get results
resp = requests.post(f"{base_url}/job/?api_key={API_KEY}", json=reopt_inputs)
run_uuid = resp.json()['run_uuid']
# Wait for results
while True:
resp = requests.get(f"{base_url}/job/{run_uuid}/results/?api_key={API_KEY}")
if resp.json().get('status') != 'Optimizing...':
break
time.sleep(10)Step 2: Run ERP Analysis# ERP inputs - requires REopt run_uuid
erp_inputs = {
"reopt_run_uuid": run_uuid
}
# Submit ERP job
resp = requests.post(f"{base_url}/erp/?api_key={API_KEY}", json=erp_inputs)
erp_uuid = resp.json()['run_uuid']
# Wait for ERP results
while True:
resp = requests.get(f"{base_url}/erp/{erp_uuid}/results/?api_key={API_KEY}")
if resp.json().get('status') != 'Optimizing...':
erp_results = resp.json()
break
time.sleep(10)Step 3: Get ERP Results# Key ERP outputs
survival_curve = erp_results["outputs"]["mean_cumulative_survival_by_duration"]
print(f"Survival probabilities: {survival_curve}")Key Differences from Web Tool
|
0 replies
Answer selected by
adfarth
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Here's an example of how to use it:
Basic Setup
Step 1: Run REopt Optimization