TrophyCustomer's Canvas is honored with a 2020 InterTech Technology Award! Learn more 

Origami Web API

You can use the Origami Web API to get details about packaging models, generate die-cut templates, and preview 3D models. This Web API doesn't require authentication and only supports the JSON data format in the request payload and request response. The base path of an API request represents a folder on your server where you deploy the Origami application, for example, https://example.com/. This path is assigned to the appUrl variable in the Web API examples.

Getting Details about Parametric Packaging Models

List Die-Cut Models

The ListDieCutModels method returns an array of identifiers of available models. These identifiers represent file names without extensions in the Origami.DieCutModelPath location.

Request type

[GET]

URL

~/api/Origami/ListDieCutModels

Example call

JavaScript
$.ajax({
    type: "GET",
    url: appUrl + "api/Origami/ListDieCutModels",
    dataType: 'json',
    contentType: "application/json; charset=utf-8",
    success: function (data, textStatus, jqXHR) {
        console.log("Die cut model list: " + JSON.stringify(data));
    }
});

Success response

Status Code: 200 OK
Content:
[  
   "ECMA A20.20.03.01 ReversedTuckEnd",
   "ECMA A20.21.03.01",
   "ECMA A55.20.01.01 DisplayOuterSnapLockBase",
   "ECMA B21.05.00.00 GluedBufferWallTray",
   "ECMA F70.01.00.00",
   "FEFCO 0215",
   "FEFCO 0217",
   "FEFCO 0717"
]

Get Parameters of a Die-Cut Model

The GetDieCutModel method returns a JSON object containing parameters of a specified die-cut model.

Request type

[GET]

URL

~/api/Origami/GetDieCutModel?id=<modelId>

Required URL Param

id=[string] - a die-cut model name.

Example call

JavaScript
$.ajax({
    type: "GET",
    url: appUrl + "api/Origami/GetDieCutModel",
    dataType: 'json',
    data: {
        id: "FEFCO 0215"
    },
    contentType: "application/json; charset=utf-8",
    success: function (data, textStatus, jqXHR) {
        dieCutModel = data;
        console.log("dieCutModel: " + JSON.stringify(dieCutModel));
    }
});

Success response

Status Code: 200 OK
Content:
{  
    "name":"FEFCO 0215",
    "description":"",
    "params":{  
        "L":{  
            "type":"float",
            "rules":{  
                "min":50,
                "max":400
            }
        },
       "W":{  
           "type":"float",
           "rules":{  
               "min":50,
               "max":400,
               "lessOrEqual":"L"
           }
       },
       "H":{  
           "type":"float",
           "rules":{  
               "min":30,
               "max":400
           }
       },
       "material":{  
           "type":"material",
           "default":"corrugated"
       },
       "thickness":{  
           "type":"float",
           "default":3,
           "rules":{  
               "min":0.1,
               "max":10
           }
       },
       "flute":{  
           "type":"flute",
           "default":"B"
       }
    },
   "predefinedParams":{  
       "name":"DIMENSIONS_LWH",
       "params":[  
          {  
              "L":150,
              "W":100,
              "H":80
          },
          {  
              "L":200,
              "W":100,
              "H":150
          },
          {  
              "L":300,
              "W":200,
              "H":190
          }
       ]
   }
}

This model contains three parameters in the params object:

  • L (Length), which should be at least 50 mm and less than or equal to 400 mm.
  • W (Width), which should be at least 50 mm, less than or equal to 400 mm, and less than or equal to the value of the L (Length) parameter.
  • H (Height), which should be at least 30 mm and less than or equal to 400 mm.
  • material is the material type with two valid values:
    • corrugated - corrugated fibreboard
    • folding - folding carton
  • thickness - the material thickness, which should be at least 0.1 mm and less than or equal to 100 mm.
  • flute - the flute type (a type of corrugated fibreboard) with the following valid values:
    • F
    • E
    • B
    • C
    • EB
    • BC

The predefined parameters (predefinedParams) specify popular or optimal size sets. This model defines the following boxes:

  • 150x 100 x80 mm
  • 200 x 100 x 150 mm
  • 300x 200 x 190 mm

Get Parameters of Die-Cut Models

The GetDieCutModels method works in the same way as GetDieCutModel but allows you to retrieve parameters of a number of models at once.

Request type

[GET]

URL

~/api/Origami/GetDieCutModels?ids[]=<modelId>

Required URL Param

ids - an array of die-cut model names.

Example call

JavaScript
var modelIds = ["ECMA A20.20.03.01 ReversedTuckEnd", "FEFCO 0215"];
$.ajax({
    type: "GET",
    url: appUrl + "api/Origami/GetDieCutModels",
    data: {
        ids: modelIds
    },
    dataType: 'json',
    contentType: "application/json; charset=utf-8",
    success: function (data, textStatus, jqXHR) {
        console.log("Die cut models: " + JSON.stringify(data));
    }
});

Success response

Status Code: 200 OK
Content:
[  
   {  
       "id":"ECMA A20.20.03.01 ReversedTuckEnd",
       "model":{  
           "name":"ECMA A20.20.03.01 Reversed Tuck End",
           "description":"",
           "params":{  
               "L":{  
                   "type":"float",
                   "rules":{  
                       "min":30,
                       "max":300
                   }
               },
               "W":{  
                   "type":"float",
                   "rules":{  
                       "min":20,
                       "max":200,
                       "lessOrEqual":"L"
                   }
               },
               "H":{  
                   "type":"float",
                   "rules":{  
                       "min":20,
                       "max":300
                   }
               },
               "thickness":{  
                   "type":"float",
                   "default":0.5,
                   "rules":{  
                       "min":0.1,
                       "max":10
                   }
               },
               "material":{  
                   "type":"material",
                   "default":"folding"
               }
           },
           "predefinedParams":{  
               "name":"DIMENSIONS_LWH",
               "params":[  
                  {  
                      "L":40,
                      "W":20,
                      "H":20
                  },
                  {  
                      "L":150,
                      "W":30,
                      "H":80
                  },
                 {
                     "L": 100,
                     "W": 50,
                     "H": 150
                 }
               ]
           }
       }
   },
   {  
       "id":"FEFCO 0215",
       "model":{  
           "name":"FEFCO 0215",
           "description":"",
           "params":{  
               "L":{  
                   "type":"float",
                   "rules":{  
                       "min":50,
                       "max":400
                   }
               },
               "W":{  
                   "type":"float",
                   "rules":{  
                       "min":50,
                       "max":400,
                       "lessOrEqual":"L"
                   }
               },
               "H":{  
                   "type":"float",
                   "rules":{  
                       "min":30,
                       "max":400
                   }
               },
               "material":{  
                   "type":"material",
                   "default":"corrugated"
               },
               "thickness":{  
                   "type":"float",
                   "default":3,
                   "rules":{  
                       "min":0.1,
                       "max":10
                   }
               },
               "flute":{  
                   "type":"flute",
                   "default":"B"
               }
           },
           "predefinedParams":{  
               "name":"DIMENSIONS_LWH",
               "params":[  
                  {  
                      "L":150,
                      "W":100,
                      "H":80
                  },
                  {  
                      "L":200,
                      "W":100,
                      "H":150
                  },
                  {  
                      "L":300,
                      "W":200,
                      "H":190
                  }
               ]
           }
       }
   }
]

Generating Die-Cut Templates

The CreateDieCutTemplate method creates die-cut templates based on a model ID and parameters. As a result, you get a mockup in the SVG format, a model in the COLLADA format, and a die-cut template in PDF.

Request type

[POST]

URL

~/api/Origami/CreateDieCutTemplate

Request Payload

You can pass data in the following format in this POST request.

{  
    ModelId:"ECMA A20.21.03.01",
    Params:{  
        L:50,
        W:30,
        H:60
    }
}

Example call

JavaScript
var dieCutModelParams = {  
    L:50,
    W:30,
    H:60
};

$.ajax({
    type: "POST",
    url: appUrl + "api/Origami/CreateDieCutTemplate",
    dataType: 'json',
    data: JSON.stringify({
        ModelId: "ECMA A20.21.03.01",
        Params: dieCutModelParams
    }),
    contentType: "application/json; charset=utf-8",
    success: function (data, textStatus, jqXHR) {
        console.log("dieCutTemplate: " + JSON.stringify(dieCutTemplate));
    },
    error: function (jqXHR, textStatus, errorThrown) {
        alert(jqXHR.responseText);
    }
});

Success response

Status Code: 200 OK
Content:
[  
   {  
       "Mockup":"origami/bxr2gajj.fo4",
       "Template":"h5mkuxbl.r0u",
       "Model3D":"xthxzotk.rkh",
       "Width":2155,
       "Height":2309,
       "Dpi":300.0,
       "Name":"",
       "Animation":null,
       "Position":null
   }
]

The success response contains the following properties:

  • Mockup is used by Customer's Canvas to display a die-cut template. A mockup is a graphics overlay we load to the Customer's Canvas online editor to show a die-cut template. The value is the name of a mockup file (without an extension) placed to the location defined by the Origami.CustomersCanvasMockupPath key.
  • Template is an ID of the die-cut template in the PDF format. This file is placed to the location defined by the Origami.DieCutTemplatePath key.
  • Model3D is an ID of a 3D model file. This file is placed to the location defined by the Origami.Model3DPath key.
  • Width and Height define the size of the mockup in pixels.
  • Dpi is used to translate the size to absolute units (inches, cm).
  • If a model has several elements (for example, if a box consists of a container and a lid), then the following parameters are used:
    • Name of the element.
    • Position of the element (to align items to each other).
    • Animation of the element position (opening and closing the box).

Generating a 3D Model Preview

The Viewer method allows you to preview a 3D model of the customized packaging. This preview is implemented in an IFRAME element.

Request type

[GET]

URL

~/viewer/model1=<modelId>

URL Params

  • model1=[string] (model2, and so on, if a box consists of several elements) specifies a 3D model name.
  • (Optional) image1=[string] (image2, and so on, if a box consists of several elements) specifies graphic design generated by Customer's Canvas. It is applied as a texture to the 3D model.
  • (Optional) hidecontrols=[numeric] specifies the appearance of controls. Set this parameter to 1 to hide controls.

Example call

HTML
<body>
    <iframe id="iframe3DPreview" allowfullscreen></iframe>
    ...
</body>
<script>
    ...
    var previewUrl = appUrl + "viewer/?hidecontrols=1&model1=xthxzotk.rkh&image1=http://example.com/api/rendering/GetProofImage/default/f289c933-b758-499a-b0c1-eec202202fed/0_0[1867x2000].jpg";
    $("#iframe3DPreview").attr("src", previewUrl);
<script>

Additional Methods

Download a Die-Cut Template

The GetDieCutTemplate method allows you to download a die-cut template in the PDF format.

Request type

[GET]

URL

~/api/Origami/GetDieCutTemplate?template=<templateName>

Required URL Param

template=[string] - a template file name.

Example call

HTML
<a href="https://example.com/api/Origami/GetDieCutTemplate?template=h5mkuxbl.r0u">Download a die-cut template</a>  

Success response

If the result is successful, this method returns the content of a PDF file with the die-cut template in the file stream.

Status Code: 200 OK
Content-type: application/octet-stream

Merge Graphic Design with a Die-Cut Template

The MergeGraphicsAndDieCutTemplate method allows you to merge graphic design created in the Customer's Canvas editor with a die-cut template in a PDF format. The die-cut template is rendered in the overprint mode.

Request type

[GET]

URL

~/api/Origami/MergeGraphicsAndDieCutTemplate?graphicsUrl=<linkToHiRes>&template=<templateName>

Required URL Params

  • graphicsUrl=[string] - a URL that links to the resulting file of Customer's Canvas.
  • template=[string] - a template file name.

Example call

HTML
<a href="https://example.com/api/Origami/MergeGraphicsAndDieCutTemplate?graphicsUrl=http://example.com:58102/api/rendering/GetHiResOutput/default/f6169e31-aaef-4f18-be71-124b7e3fe362/0_-1.pdf/design&template=h5mkuxbl.r0u">Download a packaging</a>  

Success response

If the result is successful, this method returns the content of a PDF file with graphic design merged with the die-cut template in the file stream.

Status Code: 200 OK
Content-type: application/octet-stream

Save Project Parameters

The SaveProject method saves a JSON file on your server and returns its unique ID. You can save your packaging project with all the settings for further editing.

Request type

[POST]

URL

~/api/Origami/SaveProject

Request Payload

You can pass data in the following format in this POST request.

{  
    "DieCutModelId":"ECMA_A20.21.03.01",
    "DieCutModelParams":{  
        "L":50,
        "W":30,
        "H":60
    },
   "DieCutTemplate":[  
      {  
          "Name":"",
          "Mockup":"origami/a4ufmjb3.skt",
          "Template":"5b1flwr1.akk",
          "Model3D":"tvrwzxn0.vfq",
          "Width":2155,
          "Height":2309,
          "Dpi":300,
          "Animation":null,
          "Position":null
      }
   ],
   "StateId":"67129ad4-af22-494e-aafc-22b1f64f3bdf"
}
Note

This project data allows you to recreate the saved project and return to product editing.

The StateId property is a unique ID of graphic design edited in Customer's Canvas.

Example call

JavaScript
$.ajax({
    type: "POST",
    url: appUrl + "api/Origami/SaveProject",
    dataType: 'json',
    data: JSON.stringify(projectData),
    contentType: "application/json; charset=utf-8",
    success: function (data, textStatus, jqXHR) {
        window.prompt("Project id of the saved project: ", data);
    }
});

Success response

Status Code: 200 OK
Content: ftpdkb25.4uo

Get Saved Project Parameters

The GetProject method retrieves a saved JSON file from your server. It may be used to recreate the saved project in the editor.

Request type

[GET]

URL

~/api/Origami/GetProject?id=<projectFileName>

Required URL Param

id=[string] - a name of a file containing the editor's data.

Example call

JavaScript
$.ajax({
    type: "GET",
    url: appUrl + "api/Origami/GetProject",
    dataType: 'json',
    data: {
        id: "ftpdkb25.4uo"
    },
    contentType: "application/json; charset=utf-8",
    success: function (data, textStatus, jqXHR) {
        console.log("Project: " + data);
    },
    error: function (jqXHR, textStatus, errorThrown) {
        alert("Error occured during loading the project.");
    }
});

Success response

Status Code: 200 OK
Content:
{  
    "DieCutModelId":"ECMA_A20.21.03.01",
    "DieCutModelParams":{  
        "L":50,
        "W":30,
        "H":60
    },
    "DieCutTemplate":[  
        {  
            "Name":"",
            "Mockup":"origami/a4ufmjb3.skt",
            "Template":"5b1flwr1.akk",
            "Model3D":"tvrwzxn0.vfq",
            "Width":2155,
            "Height":2309,
            "Dpi":300,
            "Animation":null,
            "Position":null
        }
    ],
    "StateId":"67129ad4-af22-494e-aafc-22b1f64f3bdf"
}

See Also

Manual

Other