Search for content

Quick Start - Loading Space Optimization API

Loading Space Optimization is a PTV feature to calculate the best way of arranging goods in a loading space.
Every truck on the road, or container on sea is a cost factor. So minimizing their number is equal to saving money.

Using the Load Optimization API is simple. Follow the steps on this page to get started with loading space optimization. For an easy integration you can also use the clients for Java, C# and TypeScript on GitHub.

Please note the individual rate and request limits for each API. You can find all limits in our FAQ.

Request

Use the following endpoint via POST to start an optimization.

https://api.myptv.com/binpacking/v1/bins

The following simple request is to be inserted into the request body in JSON representation.

{
  "bins": [
    {
      "id": "Truck",
      "numberOfInstances": 1,
      "dimensions": {
      "x": 250,
      "y": 250,
      "z": 1360
    },
    "maximumWeightCapacity": 25000000
  }
  ],
  "items": [
    {
      "id": "Pallet",
      "numberOfInstances": 10,
      "dimensions": {
      "x": 120,
      "y": 100,
      "z": 80
      },
      "weight": 50000
    }
  ]
}

You can test the simple request by choosing one of the following options.

cURL:

curl --location --request POST "https://api.myptv.com/binpacking/v1/bins" --header "Content-Type: application/json" --header "ApiKey: YOUR_API_KEY" --data-raw "{ \"bins\": [ { \"id\": \"Truck\", \"numberOfInstances\": 1, \"dimensions\": { \"x\": 250, \"y\": 250, \"z\": 1360 }, \"maximumWeightCapacity\": 25000000 } ], \"items\": [ { \"id\": \"Pallet\", \"numberOfInstances\": 10, \"dimensions\": { \"x\": 120, \"y\": 100, \"z\": 80 }, \"weight\": 50000 } ] }"

PowerShell:

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("ApiKey", "YOUR_API_KEY")
$headers.Add("Content-Type", "application/json")

$body='{ "bins": [ { "id": "Truck", "numberOfInstances": 1, "dimensions": { "x": 250, "y": 250, "z": 1360 }, "maximumWeightCapacity": 25000000 } ], "items": [ { "id": "Pallet", "numberOfInstances": 10, "dimensions": { "x": 120, "y": 100, "z": 80 }, "weight": 50000 } ] }'

try
{
    $response = Invoke-RestMethod 'https://api.myptv.com/binpacking/v1/bins' -Method 'POST' -Headers $headers -Body $body
    $response | ConvertTo-Json -Depth 10
}
catch
{
    $streamReader = [System.IO.StreamReader]::new($_.Exception.Response.GetResponseStream())
    $streamReader.ReadToEnd() | ConvertFrom-Json
    $streamReader.Close()
}

 

Response

Below you will find a possible result.

The response contains the bins with the loaded items and their location into each bin. Additionately the list of items that could not be loaded is included.

{
    "packedBins": [
        {
            "binId":"Truck",
            "packedItems": [
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 0
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 120,
                        "y": 0,
                        "z": 0
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 80
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 120,
                        "y": 0,
                        "z": 80
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 160
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 120,
                        "y": 0,
                        "z": 160
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 240
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 120,
                        "y": 0,
                        "z": 240
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 320
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                },
                {
                    "itemId": "Pallet",
                    "position": {
                        "x": 120,
                        "y": 0,
                        "z": 320
                    },
                    "dimensions": {
                        "x": 120,
                        "y": 100,
                        "z": 80
                    },
                    "orientation": "ORIGINAL"
                }
            ],
            "totalItemsVolume": 9600000,
            "totalItemsWeight": 500000,
            "usedWeightCapacity": 2.0,
            "usedVolumeCapacity": 11.294117647058824,
            "loadingMeters": 4.0
        }
    ],
    "itemsNotPacked": []
}