Skip to content

1. Get API key and setup local environment

adfarth edited this page Aug 30, 2023 · 2 revisions

Obtain an API key

The API is hosted at https://developer.nrel.gov/api/reopt. In order to access the API you need to get an API key. Once you have a key you can access the API with something like:

https://developer.nrel.gov/api/reopt/stable/help?API_KEY=DEMO_KEY

You will have to replace DEMO_KEY with your own key (the DEMO_KEY only allows a few hits per day).

Set up your environment to use the API

There are two ways to setup an environment from which to call the API using the scripts in this wiki:

  1. Use Docker to host a pre-configured Python environment
  2. Install a Python environment natively on your operating system

See the instructions below for each method.

1. Use Docker to host a pre-configured Python environment

  1. Install Docker (https://www.docker.com/get-started)
  2. Open a command line terminal (e.g. command prompt, bash terminal) and type cd path/to/cloned/repo
  3. Type docker compose up --build depending on the version of Docker
  4. If there is an error in the build process (likely pulling the base image), try first running docker pull jupyter/datascience-notebook and then do docker compose up
  5. Click the provided URL (starting with http://127.0.0.1) to open Jupyter Lab in your browser
  6. Click on the work folder in the left-hand project explorer and navigate to either of the notebooks (.ipynb files).
  7. If running REopt locally, you will also need to spin up REopt Lite Docker containers (https://github.com/NREL/REopt_Lite_API)
  8. To shut down, cntrl+c in the terminal or shutdown using the Jupyter Lab controls

After initial docker setup

  1. To spin up again after you've already done --build in step 3. above, just type docker compose up and click the Jupyter URL

2. Setup a python environment

  1. Install Python 3.6+ interpreter:

    • Ubuntu: sudo apt-get install python3-dev

    • Mac OSX: Download and install version 3.6+ from here

    • Windows: Download and install version 3.6+ from here

  2. Install pip

    Recommended: use a virtual environment with venv

  3. Add the required python packages:

    NOTE: The requirements.txt does not include dependecies for the jupyter notebooks

  4. (OPTIONAL) Install git: - https://git-scm.com/book/en/v2/Getting-Started-Installing-Git