Skip to content

REST API

printpal.io edited this page Sep 20, 2023 · 2 revisions

REST API

The PrintWatch Bed Segmentation AI can be used via the external REST API. The API requests must be routed to the main server url at: https://octoprint.printpal.io. Use the endpoints below to make your requests.

Example request url + endpoint: https://octoprint.printpal.io/api/v2/segment


POST /api/v2/segment

Description:

Run segmentation on the provided image. This will automatically compare to the baseline image stored on the cloud if it exists, if the compare argument is True. The input 'image' must be a base64 encoded string containing the image.

Inputs:

Request Body:

Type: application/json

{
  image : string,
  api_key : string,
  printer_id : string,
  [Optional] compare_baseline : bool,
}

Output:

Type: application/json

{
  status : int = 8000 | 8001,
  items : dict = {
    status : dict = {
      status : dict = {
        mask : string = base64encoded image,
        loss : float = 0.0 - 1.0,
        unique_id : string = uuid4 hex 
      }
    }
  }
}

Possible values of status are:

8000: Request successful.

8001: Request Error


GET /api/v2/segment/set_baseline

Description:

Sets the baseline image on the server for future segmentation requests.

Inputs: Query String arguments:

  • api_key : string = your API key
  • printer_id : string = your printer's unique id
  • unique_id : string = the unique id associated with a previous segmentation request. Get this from the response of /api/v2/segment

Output:

Type: application/json

{
  status : int = 8000 | 8001,
  response : string = explanation of result
}

Possible values of status are:

8000: Request successful. 8001: Request unsuccessful.


GET /api/v2/segment/get_baseline

Description:

GEts the baseline image on the server.

Inputs: Query String arguments:

  • api_key : string = your API key
  • printer_id : string = your printer's unique id

Output:

Type: application/json

{
  status : int = 8000 | 8001,
  response : string = explanation of result if failure occurs,
  items : dict = {
    status : dict = {
      mask : string = base64 encoded image mask
    }
  }
}

Possible values of status are:

8000: Request successful. 8001: Request unsuccessful.