Skip to content

3. Calling Locally Hosted API

Hallie Dunham edited this page Aug 9, 2023 · 1 revision

Unless you are trying to call the API from within a Docker container/environment:

Mac users

api_url = "http://0.0.0.0:8000/stable"

Windows users:

api_url = "http://localhost:8000/stable"

Example POST (include json with Scenario input data in the Body): 0.0.0.0:8000/stable/job/?format=json&api_key=[copy your API key here]

Example GET: 0.0.0.0:8000/stable/job/[copy run_uuid from POST response here]/results/?api_key=[copy your API key here]

See https://github.com/NREL/REopt-API-Analysis for more examples of posting to the API (must replace urls with those above to use locally-hosted API).

Calling the API from within a Docker environment, such as the Docker setup of using REopt-API-Analysis repository:

api_url = "http://host.docker.internal:8000/stable"

or

api_url = "http://gateway.docker.internal:8000/stable"