Skip to content

API design

NordineF edited this page Sep 5, 2021 · 11 revisions

 API Version 0.0.1 Documentation :

The API currently has 2 endpoints: register, run. In order to interact with our API endpoints, you must have a permission, this authorization takes the form of a token. This token allows API to authenticate the user and is passed through as an Authorization Token in the HTTP header, and this for any request to our API.

Table of content

  1. Data format definition
  2. API CALL: shared header
  3. register endpoint
  4. run endpoint

Data format definition

name type length description
username string no limit name of the client user
model string no limit the name of the simulation model
progress integer [0,100] running simulation progress from 0 to 100
runId string 8 the running simulation id which is unique for each running simulation
token string 32 a random string which allows API to authenticate the client user
host string no limit the hostname where the simulation is running

API CALL: Shared Header


Each HTTP-header must contain the following mandatory information Content-Type: application/json. The API will always respond in JSON.

Register endpoint


Method Path Description
POST /api/register Allow user to register a simulation

This call to the API requires the following arguments:

  {
    "username": <string>,
    "model":    <string>,
    "progress": <float>,    
  }

The response data will be in the following format:

  {
    "runId":   <string>,
    "token": <string>
  }

The url field will have the following format "/runs/:runId" simulation-number is randomly generated by the API.

Run endpoint


Name Method Path Description
listing GET /api/runs Return the list of all simulations
read GET /api/:runID Return information on a specific run designed by the runID argument
update PUT /api/:runID Refresh state of a running simulation
delete DELETE /api/:runID Delete a specific simulation

Listing

The API will return all running simulations informations.

  [
    {
     "username":      <string>,
     "model":         <string>,
     "progress":      <float>,
     "runId":         <string>
    },

    {
      "username":     <string>,
      "model":        <string>,
      "progress":     <float>,
      "runId":        <string>
    },
    .
    .
    .
  ]

Read

The API will return all the information of a specific running simulation. Example with the call : /run/1223

  [
    {
      "username":          <string>,
      "model":         <string>,
      "progress":      <float>,
      "runId":         <string> -> 1223  
    }
  ]

Update

This call to our API requires the following argument:

  • progress
  • token

Delete

This call to our API requires the following argument:

  • token