Step-by-Step Guide: CubeMaster Web API

FAQ

The CubeMaster API is a RESTful API, which means it can be used with a wide range of technologies, including:

Programming Languages:
  • Python (Requests, FastAPI, Flask, Django)
  • JavaScript/Node.js (Axios, Fetch API)
  • Java (Spring Boot, RestTemplate)
  • C# (.NET, RestSharp)
  • PHP (cURL, Guzzle)
  • Ruby on Rails (RestClient)
  • Go (net/http)

Platforms & Frameworks:
  • Web Applications
  • Mobile Applications (iOS, Android)
  • ERP, WMS, TMS, SAP Integrations
  • Cloud Platforms (AWS, Azure, Google Cloud)
  • IoT Devices

The API primarily supports the formats of JSON (application/json) for both input and output.

Example API Request (JSON Input):
{ "multiProcessed": false, "cargoDetailLoadedFromDatabase": true, "UOM": "UnitEnglish", "userId": "test@company.com" }

Example API Response (JSON Output):
{ "status": "success", "message": "Load successfully built", "loadDetails": { "containersUsed": 3, "volumeUtilization": "87%", "weightUtilization": "95%" } }

Pros:
  • Automation & Efficiency – Reduces manual load planning and optimizes cargo placement.
  • Scalability – Can be integrated with multiple platforms, including ERP, WMS, and TMS systems.
  • Real-time Data Processing – Supports real-time load calculations and asynchronous processing.
  • Graphical Representation – Generates load diagrams for visualization.
  • Multiple Unit Systems – Supports different units of measure (Metric, Imperial).
Cons:
  • Potential Learning Curve – May require developers with API and logistics expertise for full integration.
  • Asynchronous Processing Complexity – Webhook-based responses may need additional handling in apps.
  • Limited Input Formats – Primarily supports JSON, making it harder for XML-based systems to integrate directly.
Step 1: Understand the API Endpoints

The CubeMaster API has three main types of endpoints:

  • Calculation API: For building and optimizing loads.
  • Database API: For managing cargo and container data.
  • Archive API: For accessing and managing archived load plans.

For this guide, we’ll focus on the Calculation API.

Step 2: Set Up Authentication

Before making API requests, ensure you have the necessary authentication credentials (e.g., API key or token).

Include the API key in the request headers like this:

TokenID: YOUR_API_KEY

If you don’t have an API key, generate it in the Settings - Integration after accessing your account. If you don't have an account yet, sign up.

Step 3: Prepare the Request

To build a load, send a POST request to the following endpoint:

POST https://api.cubemaster.net/loads

Add parameters to set more settings to the request:

?multiProcessed=false&loadSaved=true&loadShared=false&UOM=UnitEnglish&graphicsCreated=true&graphicsImageWidth=200&graphicsImageDepth=200

The request body should include:

  • Cargoes: A list of cargoes to be loaded.
  • Containers: A list of containers to be filled.
  • Rules: Rules for load optimization (e.g., algorithm type, stacking rules).

Here’s an example of a request body in JSON format:

{
  "title": "Sample Load Plan",
  "description": "This is a sample load plan for testing.",
  "cargoes": [
    {
      "name": "Cargo1",
      "length": 2.0,
      "width": 1.5,
      "height": 1.0,
      "weight": 50.0,
      "qty": 10,
      "style": "Shipcase"
    }
  ],
  "containers": [
    {
      "name": "Container1",
      "length": 12.0,
      "width": 2.5,
      "height": 2.5,
      "emptyWeight": 1000.0,
      "maxWeight": 5000.0,
      "containerType": "SeaVan"
    }
  ],
  "rules": {
    "algorithmType": "Optimization",
    "optimizationLevel": 2,
    "fillDirection": "FrontToRear",
    "isWeightLimited": true,
    "isSafeStackingUsed": true
  }
}
Step 4: Make the API Request

Use a tool like Postman, cURL, or a programming language (e.g., Python, JavaScript) to send the request.

Here’s an example using cURL:

curl -X POST "https://api.cubemaster.net/loads?loadSaved=true&loadShared=false&graphicsCreated=true&graphicsImageWidth=200&graphicsImageDepth=200&UOM=UnitEnglish" \
-H "TokenID: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "title": "Sample Load Plan",
  "description": "This is a sample load plan for testing.",
  "cargoes": [
    {
      "name": "Cargo1",
      "length": 2.0,
      "width": 1.5,
      "height": 1.0,
      "weight": 50.0,
      "qty": 10,
      "style": "Shipcase"
    }
  ],
  "containers": [
    {
      "name": "Container1",
      "length": 12.0,
      "width": 2.5,
      "height": 2.5,
      "emptyWeight": 1000.0,
      "maxWeight": 5000.0,
      "containerType": "SeaVan"
    }
  ],
  "rules": {
    "algorithmType": "Optimization",
    "optimizationLevel": 2,
    "fillDirection": "FrontToRear",
    "isWeightLimited": true,
    "isSafeStackingUsed": true
  }
}'
Step 5: Handle the Response

The API will return a response in JSON format. Here’s an example of a successful response:

{
  "message": "OK",
  "calculationError": "succeed",
  "filledContainers": [
    {
      "name": "Container1",
      "sequence": 1,
      "loadQty": 10,
      "loadVolume": 30.0,
      "netWeight": 500.0,
      "grossWeight": 1500.0,
      "volumeUtilization": 80.0,
      "weightUtilization": 90.0,
      "graphics": {
        "images": [
          "https://api.cubemaster.net/graphics/container1.png"
        ]
      }
    }
  ],
  "loadSummary": {
    "cargoesLoaded": 10,
    "piecesLoaded": 100,
    "cargoesLeft": 0,
    "piecesLeft": 0,
    "volumeLoaded": 30.0,
    "weightLoaded": 500.0,
    "containersLoaded": 1
  }
}

Key fields in the response include:

  • message: Indicates the status of the request (e.g., "OK" for success).
  • calculationError: Indicates the status of the error (e.g., "succeed").
  • filledContainers: Contains details about the filled containers.
  • loadSummary: Provides a summary of the load plan.
Step 6: Save or Share the Load

If you set loadSaved or loadShared to true in the request, the load plan will be saved or shared in CubeMaster Online. You can access it later via the Archive API.

Step 7: Test and Debug

Use the Sandbox Environment provided by CubeMaster to test your requests. Check the error codes in the response to debug any issues (e.g., invalid cargo dimensions, missing parameters) by referring the Swagger Help and Reference Guide.

Step 8: Explore Advanced Features

Once you’re comfortable with the basics, explore advanced features such as:

  • Database API: Upload and manage cargo and container data.
  • Archive API: Download and search archived load plans.
  • Multi-Processed Loads: Use asynchronous processing for large shipments.
Step 9: Integrate into Your Application

Once testing is complete, integrate the API into your application (e.g., ERP, WMS, TMS) to automate load planning and data management.