Skip to content

REST API

Eric Redekopp edited this page Dec 17, 2022 · 2 revisions

The UI and backend server communicate with a simple HTTP API. This document describes the endpoints available on the backend server.

REST

We avoid the term "REST API" above because this API is neither cacheable nor stateless.

Future work for Modelcollab will at some point include a dashboard for running models and model results. When this is implemented, this API will be modified so that getModelResults is no longer required. Instead, /computeModel will POST to the server, which will start computing and notify the UI through some other mechanism that it is in the process of doing so.

It may make sense to adapt /getCode to accept JSON containing the component data for the canvas and any imported models. This could make that request cacheable and the API truly RESTful. Alternatively, we could change /getCode to a POST called something like /computeJuliaCodeGen and access the results through the same dashboard as we do with /computeModel. This will be decided at the time that the dashboard is being planned, but in any case will involve moving to a real REST API.

API

  • GET /getCode/<sessionId>
    • Access the components for sessionId in Firebase and interpret it as Julia code
    • Responses
      • 200 Responds with the Julia code OR an error message as text/plain
  • POST /computeModel/<sessionId>/<scenarioName>
    • Ask the server to generate Julia code for sessionId and interpret it by starting a new Julia process. The codegen process overrides parameter values as specified by the given scenario. If the scenario name is "baseline" or if the provided scenario is not found, default values are used.
    • Responses
      • 200 Julia process started. Responds with a resultID to use with /getModelResults as text/plain
      • 500 Not able to successfully generate code and start the Julia process. Responds with an error message as text/plain
  • GET /getModelResults/<resultId>
    • Get the results with the given id (returned from computeModel), if they exist
    • Responses
      • 204 Results not available
      • 200 Results available. Responds with the .png results graph as a binary blob
      • 500 The Julia process exited without saving any results files

Clone this wiki locally