NAV
JSON cURL PHP Python JAVA C#

Introduction

This subpage contains description about the implementation of our algorithms into your system. Our alghorithms were created to optimize and visualize packing of cubic items in in various cubic shaped loading spaces. Each our algorithm is possible to connect via the API which accepts requests and returns responses in JSON format.

What is an API?

An API is a set of programming code that enables data transmission between one software product and another. It also contains the terms of this data exchange.

Get started

To use our API, you need to register on our website (www.3dbinpacking.com) and get your username and API key.

In case you like to test our API, please replace username and api key given below and paste them into the browser address bar.

https://global-api.3dbinpacking.com/packer/fillContainer?query={"username":"USERNAME","api_key":"API_KEY","items":[{"id":"Speakers","w":3,"h":3,"d":3,"wg":2,"quantity":3,"vr":true},{"id":"Bigger item","w":3,"h":3,"d":5,"wg":1,"quantity":2,"vr":true}],"bins":[{"id":"Pack M","h":4,"w":4,"d":4,"wg":"","max_wg":""},{"id":"Pack S","h":3,"w":3,"d":6,"wg":"","max_wg":""}],"params":{"images_background_color":"255,255,255","images_bin_border_color":"59,59,59","images_bin_fill_color":"230,230,230","images_item_border_color":"22,22,22","images_item_fill_color":"255,193,6","images_item_back_border_color":"22,22,22","images_sbs_last_item_fill_color":"177,14,14","images_sbs_last_item_border_color":"22,22,22","images_format":"svg","images_width":50,"images_height":50,"images_source":"file","save_response":true,"stats":0,"item_coordinates":1,"images_complete":1,"images_sbs":1,"images_separated":0}}

If you get a response as below, it will mean that you did everything correctly.

{"id":"1556529305_9ff402ed696d0a5a3d9f26b8987a3758","not_packed_items":[],"bins_packed":[{"bin_data":{"w":4,"h":4,"d":4,"id":"Pack M","used_space":42.1875,"weight":2,"used_weight":100,"stack_height":3,"order_id":null},"image_complete":"https:\/\/eu.api.3dbinpacking.com\/images\/file_hash1.svg","items":[{"id":"Speakers","w":3,"h":3,"d":3,"wg":2,"image_sbs":"https:\/\/eu.api.3dbinpacking.com\/images\/file_hash2.svg","coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}}]},{"bin_data":{"w":3,"h":3,"d":6,"id":"Pack S","used_space":100,"weight":4,"used_weight":100,"stack_height":3,"order_id":null},"image_complete":"https:\/\/eu.api.3dbinpacking.com\/images\/file_hash3.svg","items":[{"id":"Speakers","w":3,"h":3,"d":3,"wg":2,"image_sbs":"https:\/\/eu.api.3dbinpacking.com\/images\/file_hash4.svg","coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}},{"id":"Speakers","w":3,"h":3,"d":3,"wg":2,"image_sbs":"https:\/\/eu.api.3dbinpacking.com\/images\/file_hash5.svg","coordinates":{"x1":0,"y1":0,"z1":3,"x2":3,"y2":3,"z2":6}}]}]}

Endpoints

Currently we have a few servers running around the world for high availability, low latency.
Our global API server is the best. This server will redirect your request to the closest available server.
The list of 3DBinPacking API endpoints:

PEM (X.509)

Requests

Below you can read through the details about methods of sending requests to our API servers.

Available methods of sending data

- POST - Recommended
- GET

Available protocols:

- https - Recommended
- http

Call methods:

- as parameter - Example GET: https://global-api.3dbinpacking.com/packer/pack?query={json_encoded_data}
- as JSON content request

Products

Pack a Shipment

Use Pack a Shipment tool to optimize your packing - by number of boxes, space utilization or cost.

URL

Request parameters

Required parameters

REQUEST

{
    "username":"USERNAME",
    "api_key":"API_KEY",
    "items":
    [
        {
            "id":"Speakers",
            "w":3,
            "h":3,
            "d":3,
            "wg":2,
            "q":3,
            "vr":true
        },
        {
            "id":"Bigger item",
            "w":3,
            "h":3,
            "d":5,
            "wg":1,
            "q":2,
            "vr":true
        },
        {
            "id":"Too big item",
            "w":5,
            "h":5,
            "d":5,
            "wg":1,
            "q":1,
            "vr":true
        }
    ],
    "bins":
    [
        {
            "id":"Pack M",
            "h":4,
            "w":4,
            "d":4,
            "wg":"",
            "max_wg":"",
            "q":null,
            "cost":0,
            "type":"pallet"
        },
        {
            "id":"Pack S",
            "h":3,
            "w":3,
            "d":6,
            "wg":"",
            "max_wg":"",
            "q":null,
            "cost":0,
            "type":"pallet"
        }
    ],
    "params":
    {
        "images_background_color":"255,255,255",
        "images_bin_border_color":"59,59,59",
        "images_bin_fill_color":"230,230,230",
        "images_item_border_color":"22,22,22",
        "images_item_fill_color":"255,193,6",
        "images_item_back_border_color":"22,22,22",
        "images_sbs_last_item_fill_color":"177,14,14",
        "images_sbs_last_item_border_color":"22,22,22",
        "images_format":"svg",
        "images_width":50,
        "images_height":50,
        "images_source":"file",
        "stats":0,
        "item_coordinates":1,
        "images_complete":1,
        "images_sbs":1,
        "images_separated":0,
        "optimization_mode":"bins_number",
        "images_version":2
    }
}
curl -X POST \
-H "Content-Type: application/json" \
-d '{"username": "USERNAME", "api_key": "API_KEY", "items": [{"id": "Speakers", "w": 3, "h": 3, "d": 3, "wg": 2, "q": 3, "vr": true},{"id": "Bigger item", "w": 3, "h": 3, "d": 5, "wg": 1, "q": 2, "vr": true},{"id":"Too big item","w":5,"h":5,"d":5,"wg":1,"q":1,"vr":true}], "bins": [{"id": "Pack M", "h": 4, "w": 4, "d": 4, "wg": "", "max_wg": "", "q":null, "cost":0, "type":"pallet"},{"id": "Pack S", "h": 3, "w": 3, "d": 6, "wg": "", "max_wg": "", "q":null, "cost":0, "type":"box"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "stats": 0, "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "optimization_mode":"bins_number", "images_version":2}}' \
https://global-api.3dbinpacking.com/packer/packIntoMany \
-k
<?php
$data = array(
    'bins' => array(
            array(
                    'id' => 'Pack M',
                    'h' => '4',
                    'w' => '4',
                    'd' => '4',
                    'wg' => '',
                    'max_wg' => '',
                    'q'=>null,
                    'cost'=>0,
                    'type'=>'pallet'
                ),
            array(
                    'id' => 'Pack S',
                    'h' => '3',
                    'w' => '3',
                    'd' => '6',
                    'wg' => '',
                    'max_wg' => '',
                    'q'=>null,
                    'cost'=>0,
                    'type'=>'pallet'
                )
        ),
    'items' => array(
            array(
                    'id' => 'Speakers',
                    'w' => '3',
                    'h' => '3',
                    'd' => '3',
                    'wg' => '2',
                    'q' => '3',
                    'vr' => '1'
                ),
            array(
                    'id' => 'Bigger item',
                    'w' => '3',
                    'h' => '3',
                    'd' => '5',
                    'wg' => '1',
                    'q' => '2',
                    'vr' => '1'
                ),
            array(
                    'id' => 'Too big item',
                    'w' => '5',
                    'h' => '5',
                    'd' => '5',
                    'wg' => '1',
                    'q' => '1',
                    'vr' => '1'
                )
        ),
    'username' => 'YOUR_USERNAME',
    'api_key' => 'YOUR_API_KEY',
    'params' => array(
            'images_background_color' => '255,255,255',
            'images_bin_border_color' => '59,59,59',
            'images_bin_fill_color' => '230,230,230',
            'images_item_border_color' => '22,22,22',
            'images_item_fill_color' => '255,193,6',
            'images_item_back_border_color' => '22,22,22',
            'images_sbs_last_item_fill_color' => '177,14,14',
            'images_sbs_last_item_border_color' => '22,22,22',
            'images_format' => 'svg',
            'images_width' => '50',
            'images_height' => '50',
            'images_source' => 'file',
            'stats' => '0',
            'item_coordinates' => '1',
            'images_complete' => '1',
            'images_sbs' => '1',
            'images_separated' => '0',
            'optimization_mode'=>'bins_number',
            'images_version'=>2
        )
);
$query = json_encode($data);

$url = "https://global-api.3dbinpacking.com/packer/packIntoMany"; $prepared_query = 'query='.$query; $ch = curl_init($url); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $prepared_query ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $resp = curl_exec($ch); if (curl_errno($ch)) { echo 'Error #' . curl_errno($ch) . ': ' . curl_error($ch).'<br>'; } curl_close($ch);

$response = json_decode($resp,true); // display errors if(isset($response['response']['errors'])){ foreach($response['response']['errors'] as $error){ echo $error['message'].'<br>'; } } // display data if( $response['response']['status'] > -1 ){ $b_packed= $response['response']['bins_packed']; foreach ($b_packed as $bin){ echo "<h2>Bin id:{$bin['bin_data']['id']}</h2> <p> {$bin['bin_data']['w']} x {$bin['bin_data']['h']} x {$bin['bin_data']['d']}</p> <p> Weight:{$bin['bin_data']['weight']}</p> <p> Used weight:{ $bin['bin_data']['used_weight'] }</p> <img src=\"{$bin['image_complete']}\"> <h2>Items packed in this bin:</h2>"; $items = $bin['items']; echo '<table style="text-align: center"> <tr><th>Item id</th> <th>Item dimensions</th> <th>Item weight</th> <th>Separated item</th> <th>Step by step</th></tr>'; foreach ( $items as $item){ echo "<tr><td>{$item['id']}</td> <td> {$item['w']} x {$item['h']} x {$bin['bin_data']['d']}</td> <td> {$item['wg']}</td> <td><img src=\"{$item['image_separated']}\"></td> <td><img src=\"{$item['image_sbs']}\"></td> </tr>"; } echo '</table>'; echo '<hr>';

} }

#!/usr/bin/python

import httplib
import urllib
import json

conn = httplib.HTTPConnection(host='global-api.3dbinpacking.com', port=80) data = {"username": "USERNAME", "api_key": "API_KEY", "items": [{"id": "Speakers", "w": 3, "h": 3, "d": 3, "wg": 2, "q": 3, "vr": true},{"id": "Bigger item", "w": 3, "h": 3, "d": 5, "wg": 1, "q": 2, "vr": true},{"id": "Too big item", "w": 5, "h": 5, "d": 5, "wg": 1, "q": 1, "vr": true}], "bins": [{"id": "Pack M", "h": 4, "w": 4, "d": 4, "wg": "", "max_wg": "", "q":null, "cost":0, "type":"pallet"},{"id": "Pack S", "h": 3, "w": 3, "d": 6, "wg": "", "max_wg": "", "q":null, "cost":0 "type":"box"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "stats": 0, "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "optimization_mode":"bins_number", "images_version":2}} params = urllib.urlencode( {'query':json.dumps(data)} ) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn.request( "POST", "/packer/packIntoMany", params, headers ) content = conn.getresponse( ).read( ) conn.close( ) print content

package javaapplication1;

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;; import org.json.simple.JSONObject; import org.springframework.web.client.RestTemplate;

public class JavaApplication1 {

/** * @param args the command line arguments */ public static void main(String[] args) throws MalformedURLException, ProtocolException, IOException { RestTemplate restTemplate = new RestTemplate(); JSONObject json = new JSONObject();

//SET BINS List<Map<String , String>> bins = new ArrayList<Map<String,String>>();

Map<String, String> bin1 = new HashMap<String, String>(); bin1.put("id", "Pack M"); bin1.put("h", "4"); bin1.put("w", "4"); bin1.put("d", "4"); bin1.put("wg", ""); bin1.put("max_wg", ""); bin1.put("q", null); bin1.put("cost", 0); bin1.put("type","pallet"); bins.add(bin1); Map<String, String> bin2 = new HashMap<String, String>(); bin2.put("id", "Pack S"); bin2.put("h", "3"); bin2.put("w", "3"); bin2.put("d", "6"); bin2.put("wg", ""); bin2.put("max_wg", ""); bin2.put("q", null); bin2.put("cost", 0); bin2.put("type", "pallet"); bins.add(bin2);

//SET ITEMS List<Map<String , String>> items = new ArrayList<Map<String,String>>(); Map<String, String> item1 = new HashMap<String, String>(); item1.put("id", "Speakers"); item1.put("w", "3"); item1.put("h", "3"); item1.put("d", "3"); item1.put("wg", "2"); item1.put("q", "3"); item1.put("vr", "1"); items.add(item1); Map<String, String> item2 = new HashMap<String, String>(); item2.put("id", "Bigger item"); item2.put("w", "3"); item2.put("h", "3"); item2.put("d", "5"); item2.put("wg", "1"); item2.put("q", "2"); item2.put("vr", "1"); items.add(item2); Map<String, String> item3 = new HashMap<String, String>(); item3.put("id", "Too big item"); item3.put("w", "5"); item3.put("h", "5"); item3.put("d", "5"); item3.put("wg", "1"); item3.put("q", "1"); item3.put("vr", "1"); items.add(item3);

//SET PARAMETERS Map <String , String > params = new HashMap <String , String >(); params.put("images_background_color", "255,255,255") params.put("images_bin_border_color", "59,59,59") params.put("images_bin_fill_color", "230,230,230") params.put("images_item_border_color", "22,22,22") params.put("images_item_fill_color", "255,193,6") params.put("images_item_back_border_color", "22,22,22") params.put("images_sbs_last_item_fill_color", "177,14,14") params.put("images_sbs_last_item_border_color", "22,22,22") params.put("images_format", "svg") params.put("images_width", "50") params.put("images_height", "50") params.put("images_source", "file") params.put("stats", "0") params.put("item_coordinates", "1") params.put("images_complete", "1") params.put("images_sbs", "1") params.put("images_separated", "0") params.put("optimization_mode", "bins_number") params.put("images_version", "2")

//ADD ELEMENTS TO JSON json.put("username", "YOUR_USERNAME"); json.put("api_key", "YOUR_API_KEY"); json.put("items", items); json.put("bins", bins); json.put("params", params);

//CALL QUERY HttpURLConnection conn; URL addr = new URL("https://global-api.3dbinpacking.com/packer/packIntoMany"); conn = (HttpURLConnection) addr.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.connect(); OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream());

// prepare POST body String query = "query=" + json.toString();

osw.write(query); osw.flush(); osw.close();

BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String response_json = br.readLine();

//DO SOMETHING COOL WITH THE RESPONSE System.out.println(response_json); } }

string data;
System.Net.HttpWebRequest req = System.Net.WebRequest.Create("https://global-api.3dbinpacking.com/packer/packIntoMany") as System.Net.HttpWebRequest;

var request_data = new {username = "YOUR_USERNAME", api_key = "YOUR_API_KEY", items = new[] { new { id = "Speakers", w = "3", h = "3", d = "3", wg = "2", q = "3", vr = "1"}, new { id = "Bigger item", w = "3", h = "3", d = "5", wg = "1", q = "2", vr = "1"}, new { id = "Too big item", w = "5", h = "5", d = "5", wg = "1", q = "1", vr = "1"} }, bins = new[] { new { id = "Pack M", h = "4", w = "4", d = "4", wg = "", max_wg = "", "q" = null, "cost" = 0, "type" = "pallet"}, new { id = "Pack S", h = "3", w = "3", d = "6", wg = "", max_wg = "", "q" = null, "cost" = 0, "type" = "box"} },

@params = new { images_background_color = "255,255,255", images_bin_border_color = "59,59,59", images_bin_fill_color = "230,230,230", images_item_border_color = "22,22,22", images_item_fill_color = "255,193,6", images_item_back_border_color = "22,22,22", images_sbs_last_item_fill_color = "177,14,14", images_sbs_last_item_border_color = "22,22,22", images_format = "svg", images_width = "50", images_height = "50", images_source = "file", stats = "0", item_coordinates = "1", images_complete = "1", images_sbs = "1", images_separated = "0", optimization_mode= "bins_number", images_version = "2" } };

string json_str = JsonConvert.SerializeObject(request_data);

string queryParam = "query="+json_str;

byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(queryParam); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postBytes.Length;

System.IO.Stream postStream = req.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();

X509Certificate Cert = X509Certificate2.CreateFromCertFile("path_to_pem_key\global-api.3dbinpacking.com.pem"); req.ClientCertificates.Add(Cert);

using (System.Net.HttpWebResponse response = req.GetResponse() as System.Net.HttpWebResponse) { System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()); data = reader.ReadToEnd(); }

Param name Description Data type
username
(required)
Username. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
api_key
(required)
API key. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
[bins]
(required)
Array of packing spaces parameters array
[items]
(required)
Array of items parameters. Limit: maximum total number of items per request = 4999 array
params Array of extra request parameters of extra request parameters array

[bins] - Packing spaces array details

Param name Description Data type
id
(required)
Packing space ID. The number or code you use to identify the packing space. string
w
(required)
Packing space width integer or float
h
(required)
Packing space height integer or float
d
(required)
Packing space depth/length integer or float
wg The weight of the packing space integer or float
max_wg The maximum weight that this packing space can hold. Value set to '0' (zero) means there is no weight limit integer or float
q Maximum number of packing spaces of given dimensions NULL or integer; if the value is not set or is set to NULL - it means that the number of packing spaces is indefinite
cost Packing space shipping cost. This value is used while packing with 'optimization_mode' parameter set to 'cost' integer or float
type
Only with the images_version: 2 parameter
Specifies whether the image will be presented in the form of a box or a pallet translation missing: en.params_type_stringt

[items] - Items array details

Param name Description Data type Info
id
(required)
Item ID/SKU. The number or code you use to identify what is being packed. string
w
(required)
The width of the item integer or float
h
(required)
The height of the item integer or float
d
(required)
The depth or length of the item integer or float
wg The weight of the item integer or float
vr Vertical rotation. The information if the item can be rotated vertically. integer Vertical rotation. The information if the item can be rotated vertically.
q
(required)
The amount of the same items to pack integer
group Grouped items are packed together, which enables to separate e.g. food products (group 'X') from domestic detergents (group 'Y'). string
separate Items separation; Parameter set to '1' means that given items cannot be packed together with other items integer Available values:
1 - means that items will be separated,
0 [default] - means that items will not be separated
limit_per_bin Define how many items can be packed in one packing space integer
acceptable_bins Define which packing spaces can be used to pack items. If the parameter is not set, then all packing spaces can be used. Given values have to contain packing spaces ID included in 'bins' parameter. array
item_colors_schema Define which kind of color schema should be used string Available values:
default - colors set in the following parameters will be used 'images_item_border_color' and 'images_bin_fill_color',
'random' - x,
'item' - x
item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
item_border_color Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'

params - Optional parameters

Param name Description Data type Info
optimization_mode Define a packing optimisation method string Available values:
bins_number [default] - the smallest possible number of packing spaces;
bins_utilization - max. utilization inside packing spaces;
cost - the lowest cost of shipment or transport ('cost' parameter is required to be given for every packing space)
images_version Images generator version integer Available values: [1 | 2]
images_width Max. width of generated images integer Available values: 1 - 250
images_height Max. height of generated images integer Available values: 1 - 250
images_background_color Background color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_border_color
Only with the images_version: 1 parameter
Packing space border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_dashed_line_color
Only with the images_version: 1 parameter
Packing space front border color (dashed) string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_fill_color Packing space fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_border_color
Only with the images_version: 1 parameter
Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_fill_color Fill color of the last item on images showing a packing process 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_border_color
Only with the images_version: 1 parameter
Border color of the last item on images showing packing 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_format Images format string Available values: [ png , svg ]
images_sbs Generate images showing a packing process 'step-by-step' integer Available values:
0 [default] - means that images showing a packing process 'step-by-step' will not be generated,
1 - means that images showing a packing process 'step-by-step' will be generated
images_complete Generate images showing a final packing result integer Available values:
0 [default] - means that images showing final packing result will not be generated,
1 - means that images showing final packing result will be generated
images_separated Generate images showing the placement of each item separately integer Available values:
0 [default] - means that images showing the placement of each item separately will not be generated,
1 - means that images showing the placement of each item separately will be generated
item_coordinates Return coordinates (x, y, z) for each item integer Available values:
0 [default] - means that coordinates of the placement of each item will not be returned,
1 - that coordinates of the placement of each item will be returned
stats Return the statistics of a packing process (e.g. images generation time) integer Available values:
0 [default] - means that the statistics of a packing process will not be returned,
1 - means that the statistics of a packing process will be returned

Response parameters

RESPONSE

{
    "response":{
        "id":"response_id",
        "bins_packed":[
            {
                "bin_data":{
                    "w":3,
                    "h":3,
                    "d":6,
                    "id":"Pack S",
                    "used_space":100,
                    "weight":4,
                    "gross_weight":4,
                    "used_weight":100,
                    "stack_height":3
                },
                "image_complete":"image_url.svg",
                "items":[
                    {
                        "id":"Speakers",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":2,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}
                    },{
                        "id":"Speakers",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":2,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":0,"z1":3,"x2":3,"y2":3,"z2":6}
                    }
                ]
            },{
                "bin_data":{
                    "w":3,
                    "h":3,
                    "d":6,
                    "id":"Pack S",
                    "used_space":83.3333,
                    "weight":1,
                    "gross_weight":1,
                    "used_weight":100,
                    "stack_height":3
                },
                "image_complete":"image_url.svg",
                "items":[
                    {
                        "id":"Bigger item",
                        "w":3,
                        "h":3,
                        "d":5,
                        "wg":1,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":5}
                    }
                ]
            }
        ],
        "errors":[
            {
                "level":"notice",
                "message":"Item \u0027Too big item\u0027 can\u0027t be packed into any bin."
            }
        ],
        "status":1,
        "not_packed_items":[
            {
                "id":"Too big item",
                "q":1,
                "w":5,
                "h":5,
                "d":5,
                "wg":1
            }
        ]
    }
}

Param name Description Data type Info
[bins_packed] List of packed items array
errors List of possible errors that may occur in request array Example: [{'level'}]; Possible returned values:'critical' - critical error - disabling packing, 'warning' - warning about incorrect data in request
status Response status integer Possible returned values:
1 - response hasn't included critical errors,
0 - response has included critical errors. * critical error - the error disabling packing. It could be caused by lack of one of the required parameters ('username','api_key') or incorrect value of parameter (eg. a field, which should contain number, contains string).
[not_packed_items] The list of item unable to be packed e.g. incorrect parameters input, excessive weight or size array

[bins_packed] - The list of packing spaces to be packed

Param name Description Data type
bin_data Details of the packing space to be packed array
image_complete Image of the packing space to be packed url
[items] Information about items to be packed in the packing space array

[bin_data] - Details of the packing space to be packed

Param name Description Data type
id Packing space ID. The number or code you use to identify the packing space. string
w Packing space width integer or float
h Packing space height integer or float
d Packing space depth/length integer or float
used_space Percentage of packing space utilized integer or float
weight Weight of items to be packed integer or float
gross_weight Weight of items to be packed + weight of packing space integer or float
used_weight Percentage of the permissible weight utilized integer or float
stack_height The height of stacked items integer or float

[items] - The list of items to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
wg The weight of the item integer or float
image_separated Image showing the position of each item url
image_sbs Images showing the packing process step-by-step url
coordinates Coordinates of items in the packing space {"x1":0,"y1":0,"z1":0,"x2":5,"y2":3,"z2":2}

[not_packed_items] - The list of items unable to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
q The amount of the same items to pack integer
wg The weight of the item integer or float

Stack Pallets

Use Stack Pallets tool to optimize how you pack your pallets and reduce their number for transport and storage.

URL

Request parameters

Required parameters

REQUEST

{
    "username":"USERNAME",
    "api_key":"API_KEY",
    "items":
    [
        {
            "id":"Speakers",
            "w":3,
            "h":3,
            "d":3,
            "wg":2,
            "q":2,
            "vr":true
        },
        {
            "id":"Bigger item",
            "w":3,
            "h":3,
            "d":5,
            "wg":1,
            "q":2,
            "vr":true
        }
    ],
    "pallet":
    {
        "id":"Palet M",
        "h":4,
        "w":4,
        "d":4,
        "wg":"",
        "max_wg":"",
        "type":"pallet"
    },
    "params":
    {
        "images_background_color":"255,255,255",
        "images_bin_border_color":"59,59,59",
        "images_bin_fill_color":"230,230,230",
        "images_item_border_color":"22,22,22",
        "images_item_fill_color":"255,193,6",
        "images_item_back_border_color":"22,22,22",
        "images_sbs_last_item_fill_color":"177,14,14",
        "images_sbs_last_item_border_color":"22,22,22",
        "images_format":"svg",
        "images_width":50,
        "images_height":50,
        "images_source":"file",
        "stats":0,
        "item_coordinates":1,
        "images_complete":1,
        "images_sbs":1,
        "images_separated":0
        "images_version":2
    }
}

Param name Description Data type
username
(required)
Username. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
api_key
(required)
API key. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
[pallet]
(required)
Array of pallet parameters array
[items]
(required)
Array of items parameters. Limit: maximum total number of items per request = 4999 array
params Array of extra request parameters array

[pallet] - Pallet array details

Param name Description Data type
id
(required)
Pallet ID. A pallet you want to stack your items onto string
w
(required)
Pallet width integer or float
h
(required)
Pallet height integer or float
d
(required)
Pallet depth/length integer or float
wg The weight of the packing space integer or float
max_wg The maximum weight that this packing space can hold. Value set to '0' (zero) means there is no weight limit integer or float
type
Only with the images_version: 2 parameter
Specifies whether the image will be presented in the form of a box or a pallet translation missing: en.params_type_stringt

[items] - Items array details

Param name Description Data type Info
id
(required)
Item ID/SKU. The number or code you use to identify what is being packed. string
w
(required)
The width of the item integer or float
h
(required)
The height of the item integer or float
d
(required)
The depth or length of the item integer or float
wg The weight of the item integer or float
vr Vertical rotation. The information if the item can be rotated vertically. integer Vertical rotation. The information if the item can be rotated vertically.
q
(required)
The amount of the same items to pack integer
item_colors_schema Define which kind of color schema should be used string
item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
item_border_color Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'

params - Optional parameters

Param name Description Data type Info
images_version Images generator version integer Available values: [1 | 2]
images_width Max. width of generated images integer Available values: 1 - 250
images_height Max. height of generated images integer Available values: 1 - 250
images_background_color Background color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_border_color
Only with the images_version: 1 parameter
Packing space border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_dashed_line_color
Only with the images_version: 1 parameter
Packing space front border color (dashed) string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_fill_color Packing space fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_border_color
Only with the images_version: 1 parameter
Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_fill_color Fill color of the last item on images showing a packing process 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_border_color
Only with the images_version: 1 parameter
Border color of the last item on images showing packing 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_format Images format string Available values: [ png , svg ]
images_sbs Generate images showing a packing process 'step-by-step' integer Available values:
0 [default] - means that images showing a packing process 'step-by-step' will not be generated,
1 - means that images showing a packing process 'step-by-step' will be generated
images_complete Generate images showing a final packing result integer Available values:
0 [default] - means that images showing final packing result will not be generated,
1 - means that images showing final packing result will be generated
images_separated Generate images showing the placement of each item separately integer Available values:
0 [default] - means that images showing the placement of each item separately will not be generated,
1 - means that images showing the placement of each item separately will be generated
item_coordinates Return coordinates (x, y, z) for each item integer Available values:
0 [default] - means that coordinates of the placement of each item will not be returned,
1 - that coordinates of the placement of each item will be returned
stats Return the statistics of a packing process (e.g. images generation time) integer Available values:
0 [default] - means that the statistics of a packing process will not be returned,
1 - means that the statistics of a packing process will be returned

Response parameters

RESPONSE

{
    "id":"response_id",
    "pallets_packed":[
        {
            "pallet_data":{
                "w":4,
                "h":3,
                "d":4,
                "id":"Paleta M",
                "used_space":56.25,
                "weight":2,
                "used_weight":100,
                "gross_weight":2,
                "stack_height":3
            },
            "image_complete":"image_url.svg",
            "items":[
                {
                    "id":"Speakers",
                    "w":3,
                    "h":3,
                    "d":3,
                    "wg":2,
                    "image_sbs":"image_url.svg",
                    "coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}
                }
            ]
        },
        {
            "pallet_data":{
                "w":4,
                "h":3,
                "d":4,
                "id":"Palet M",
                "used_space":56.25,
                "weight":2,
                "used_weight":100,
                "gross_weight":2,
                "stack_height":3
            },
            "image_complete":"image_url.svg",
            "items":[
                {
                    "id":"Speakers",
                    "w":3,
                    "h":3,
                    "d":3,
                    "wg":2,
                    "image_sbs":"image_url.svg",
                    "coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}
                }
            ]
        }
    ],
    "errors":[],
    "status":1,
    "not_packed_items":[
        {
            "id":"Bigger item",
            "q":2,
            "w":3,
            "h":3,
            "d":5,
            "wg":1
        }
    ]
}

Param name Description Data type Info
[pallets_packed] The list of pallets to be packed array
errors List of possible errors that may occur in request array Example: [{'level'}]; Possible returned values:'critical' - critical error - disabling packing, 'warning' - warning about incorrect data in request
status Response status integer Possible returned values:
1 - response hasn't included critical errors,
0 - response has included critical errors. * critical error - the error disabling packing. It could be caused by lack of one of the required parameters ('username','api_key') or incorrect value of parameter (eg. a field, which should contain number, contains string).
[not_packed_items] The list of item unable to be packed e.g. incorrect parameters input, excessive weight or size array

[pallets_packed] - The list of pallets to be packed

Param name Description Data type
pallet_data Details of the packing space to be packed array
image_complete Image of the packing space to be packed url
[items] Information about items to be packed in the packing space array

[pallet_data] - Details of the packing space to be packed

Param name Description Data type
id Packing space ID. The number or code you use to identify the packing space. string
w Packing space width integer or float
h Packing space height integer or float
d Packing space depth/length integer or float
used_space Percentage of packing space utilized integer or float
weight Weight of items to be packed integer or float
gross_weight Weight of items to be packed + weight of packing space integer or float
used_weight Percentage of the permissible weight utilized integer or float
stack_height The height of stacked items integer or float

[items] - The list of items to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
wg The weight of the item integer or float
image_separated Image showing the position of each item url
image_sbs Images showing the packing process step-by-step url
coordinates Coordinates of items in the packing space {"x1":0,"y1":0,"z1":0,"x2":5,"y2":3,"z2":2}

[not_packed_items] - The list of items unable to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
q The amount of the same items to pack integer
wg The weight of the item integer or float

Find a Missing Dimension

Use Find a Missing Dimension tool to calculate measurements and the area your packing will use.

URL

Request parameters

Required parameters

REQUEST

{
    "username":"USERNAME",
    "api_key":"API_KEY",
    "bins": [
        {
            "w": 5,
            "h": 0,
            "d": 5,
            "id": "Bin1",
            "find": "h",
            "type":"pallet"
        },
        {
            "w": 3,
            "h": 30,
            "d": 3,
            "id": "Bin2",
            "find": "h",
            "type":"box"
        }
    ],
    "items": [
        {
            "w": 5,
            "h": 3,
            "d": 2,
            "q": 2,
            "vr": 1,
            "id": "Item1"
        },
        {
            "w": 3,
            "h": 3,
            "d": 3,
            "q": 3,
            "vr": 1,
            "id": "Item2"
        }
    ],
    "params":
    {
        "images_background_color":"255,255,255",
        "images_bin_border_color":"59,59,59",
        "images_bin_fill_color":"230,230,230",
        "images_item_border_color":"22,22,22",
        "images_item_fill_color":"255,193,6",
        "images_item_back_border_color":"22,22,22",
        "images_sbs_last_item_fill_color":"177,14,14",
        "images_sbs_last_item_border_color":"22,22,22",
        "images_format":"svg",
        "images_width":50,
        "images_height":50,
        "images_source":"file",
        "stats":0,
        "item_coordinates":1,
        "images_complete":1,
        "images_sbs":1,
        "images_separated":0,
        "images_version": 2
    }
}
curl -X POST \
-H "Content-Type: application/json" \
-d '{"username": "USERNAME", "api_key": "API_KEY", "bins": [{"w": 5,"h": 0,"d": 5,"id": "Bin1","find": "h", "type":"pallet"},{"w": 3,"h": 30,"d": 3,"id": "Bin2","find": "h", "type":"box"}],"items": [{"w": 5,"h": 3,"d": 2,"q": 2,"vr": 1,"id": "Item1"},{"w": 3,"h": 3,"d": 3,"q": 3,"vr": 1,"id": "Item2"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "stats": 0, "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "images_version":2}}' \
https://global-api.3dbinpacking.com/packer/findSmallestBin \
-k
<?php

$data = array( 'bins' => array( array( 'id' => 'Bin1', 'h' => '0', 'w' => '5', 'd' => '5', 'find' => 'h', 'type' => 'pallet' ), array( 'id' => 'Pack S', 'h' => '30', 'w' => '3', 'd' => '3', 'find' => 'h', 'type' => 'box' ) ), 'items' => array( array( 'id' => 'Item1', 'w' => '5', 'h' => '3', 'd' => '2', 'wg' => '2', 'q' => '2', 'vr' => '1' ), array( 'id' => 'Item2', 'w' => '3', 'h' => '3', 'd' => '3', 'wg' => '1', 'q' => '3', 'vr' => '1' ) ), 'username' => 'YOUR_USERNAME', 'api_key' => 'YOUR_API_KEY', 'params' => array( 'images_background_color' => '255,255,255', 'images_bin_border_color' => '59,59,59', 'images_bin_fill_color' => '230,230,230', 'images_item_border_color' => '22,22,22', 'images_item_fill_color' => '255,193,6', 'images_item_back_border_color' => '22,22,22', 'images_sbs_last_item_fill_color' => '177,14,14', 'images_sbs_last_item_border_color' => '22,22,22', 'images_format' => 'svg', 'images_width' => '50', 'images_height' => '50', 'images_source' => 'file', 'stats' => '0', 'item_coordinates' => '1', 'images_complete' => '1', 'images_sbs' => '1', 'images_separated' => '0', 'images_version' => 2 ) ); $query = json_encode($data);

$url = "https://global-api.3dbinpacking.com/packer/findSmallestBin"; $prepared_query = 'query='.$query; $ch = curl_init($url); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $prepared_query ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $resp = curl_exec($ch); if (curl_errno($ch)) { echo 'Error #' . curl_errno($ch) . ': ' . curl_error($ch).'<br>'; } curl_close($ch);

$response = json_decode($resp,true); // display errors if(isset($response['response']['errors'])){ foreach($response['response']['errors'] as $error){ echo $error['message'].'<br>'; } } // display data if( $response['response']['status'] > -1 ){ $b_packed= $response['response']['bins_packed']; foreach ($b_packed as $bin){ echo "<h2>Bin id:{$bin['bin_data']['id']}</h2> <p> {$bin['bin_data']['w']} x {$bin['bin_data']['h']} x {$bin['bin_data']['d']}</p> <p> Weight:{$bin['bin_data']['weight']}</p> <p> Used weight:{ $bin['bin_data']['used_weight'] }</p> <img src=\"{$bin['image_complete']}\"> <h2>Items packed in this bin:</h2>"; $items = $bin['items']; echo '<table style="text-align: center"> <tr><th>Item id</th> <th>Item dimensions</th> <th>Item weight</th> <th>Separated item</th> <th>Step by step</th></tr>'; foreach ( $items as $item){ echo "<tr><td>{$item['id']}</td> <td> {$item['w']} x {$item['h']} x {$bin['bin_data']['d']}</td> <td> {$item['wg']}</td> <td><img src=\"{$item['image_separated']}\"></td> <td><img src=\"{$item['image_sbs']}\"></td> </tr>"; } echo '</table>'; echo '<hr>';

} }

#!/usr/bin/python

import httplib
import urllib
import json

conn = httplib.HTTPConnection(host='global-api.3dbinpacking.com', port=80) data = {"username": "USERNAME", "api_key": "API_KEY", "bins": [{"w": 5,"h": 0,"d": 5,"id": "Bin1","find": "h", "type":"pallet"},{"w": 3,"h": 30,"d": 3,"id": "Bin2","find": "h", "type":"box"}],"items": [{"w": 5,"h": 3,"d": 2,"q": 2,"vr": 1,"id": "Item1"},{"w": 3,"h": 3,"d": 3,"q": 3,"vr": 1,"id": "Item2"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "stats": 0, "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "images_version":2}} params = urllib.urlencode( {'query':json.dumps(data)} ) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn.request( "POST", "/packer/findSmallestBin", params, headers ) content = conn.getresponse( ).read( ) conn.close( ) print content

package javaapplication1;

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;; import org.json.simple.JSONObject; import org.springframework.web.client.RestTemplate;

public class JavaApplication1 {

/** * @param args the command line arguments */ public static void main(String[] args) throws MalformedURLException, ProtocolException, IOException { RestTemplate restTemplate = new RestTemplate(); JSONObject json = new JSONObject();

//SET BINS List<Map<String , String>> bins = new ArrayList<Map<String,String>>();

Map<String, String> bin1 = new HashMap<String, String>(); bin1.put("id", "Bin1"); bin1.put("h", "0"); bin1.put("w", "5"); bin1.put("d", "5"); bin1.put("find", "h"); bin1.put("type", "pallet"); bins.add(bin1); Map<String, String> bin2 = new HashMap<String, String>(); bin2.put("id", "Bin2"); bin2.put("h", "30"); bin2.put("w", "5"); bin2.put("d", "5"); bin2.put("find", "h"); bin2.put("type", "pallet"); bins.add(bin2);

//SET ITEMS List<Map<String , String>> items = new ArrayList<Map<String,String>>(); Map<String, String> item1 = new HashMap<String, String>(); item1.put("id", "Item1"); item1.put("w", "5"); item1.put("h", "3"); item1.put("d", "2"); item1.put("q", "2"); item1.put("vr", "1"); items.add(item1); Map<String, String> item2 = new HashMap<String, String>(); item2.put("id", "Item2"); item2.put("w", "3"); item2.put("h", "3"); item2.put("d", "3"); item2.put("wg", "1"); item2.put("q", "3"); item2.put("vr", "1"); items.add(item2);

//SET PARAMETERS Map <String , String > params = new HashMap <String , String >(); params.put("images_background_color", "255,255,255") params.put("images_bin_border_color", "59,59,59") params.put("images_bin_fill_color", "230,230,230") params.put("images_item_border_color", "22,22,22") params.put("images_item_fill_color", "255,193,6") params.put("images_item_back_border_color", "22,22,22") params.put("images_sbs_last_item_fill_color", "177,14,14") params.put("images_sbs_last_item_border_color", "22,22,22") params.put("images_format", "svg") params.put("images_width", "50") params.put("images_height", "50") params.put("images_source", "file") params.put("stats", "0") params.put("item_coordinates", "1") params.put("images_complete", "1") params.put("images_sbs", "1") params.put("images_separated", "0") params.put("images_version", 2)

//ADD ELEMENTS TO JSON json.put("username", "YOUR_USERNAME"); json.put("api_key", "YOUR_API_KEY"); json.put("items", items); json.put("bins", bins); json.put("params", params);

//CALL QUERY HttpURLConnection conn; URL addr = new URL("https://global-api.3dbinpacking.com/packer/findSmallestBin"); conn = (HttpURLConnection) addr.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.connect(); OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream());

// prepare POST body String query = "query=" + json.toString();

osw.write(query); osw.flush(); osw.close();

BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String response_json = br.readLine();

//DO SOMETHING COOL WITH THE RESPONSE System.out.println(response_json); } }

string data;
System.Net.HttpWebRequest req = System.Net.WebRequest.Create("https://global-api.3dbinpacking.com/packer/findSmallestBin") as System.Net.HttpWebRequest;

var request_data = new {username = "YOUR_USERNAME", api_key = "YOUR_API_KEY", items = new[] { new { id = "Item1", w = "5", h = "3", d = "2", wg = "2", q = "2", vr = "1"}, new { id = "Item2", w = "3", h = "3", d = "3", wg = "1", q = "3", vr = "1"} }, bins = new[] { new { id = "Bin1", h = "0", w = "5", d = "5", type = "pallet"}, new { id = "Bin2", h = "30", w = "5", d = "5", type = "box"} },

@params = new { images_background_color = "255,255,255", images_bin_border_color = "59,59,59", images_bin_fill_color = "230,230,230", images_item_border_color = "22,22,22", images_item_fill_color = "255,193,6", images_item_back_border_color = "22,22,22", images_sbs_last_item_fill_color = "177,14,14", images_sbs_last_item_border_color = "22,22,22", images_format = "svg", images_width = "50", images_height = "50", images_source = "file", stats = "0", item_coordinates = "1", images_complete = "1", images_sbs = "1", images_separated = "0", images_version = "2" } };

string json_str = JsonConvert.SerializeObject(request_data);

string queryParam = "query="+json_str;

byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(queryParam); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postBytes.Length;

System.IO.Stream postStream = req.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();

X509Certificate Cert = X509Certificate2.CreateFromCertFile("path_to_pem_key\global-api.3dbinpacking.com.pem"); req.ClientCertificates.Add(Cert);

using (System.Net.HttpWebResponse response = req.GetResponse() as System.Net.HttpWebResponse) { System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()); data = reader.ReadToEnd(); }

Param name Description Data type
username
(required)
Username. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
api_key
(required)
API key. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
[bins]
(required)
Array of packing spaces parameters array
[items]
(required)
Array of items parameters. Limit: maximum total number of items per request = 4999 array
params Array of extra request parameters array

[bins] - Packing spaces array details

Param name Description Data type Info
id
(required)
Packing space ID. The number or code you use to identify the packing space. string
w
(required)
Packing space width float
h
(required)
Packing space height float
d
(required)
Packing space depth/length float
find
(required)
It indicate which dimension of container should be found string Available values:
'w' - menas that the algorithm will calculate width of container,
'h' - menas that the algorithm will calculate height of container,
'd' - menas that the algorithm will calculate depth of container
type
Only with the images_version: 2 parameter
Specifies whether the image will be presented in the form of a box or a pallet translation missing: en.params_type_stringt

[items] - Items array details

Param name Description Data type Info
id
(required)
Item ID/SKU. The number or code you use to identify what is being packed. string
w
(required)
The width of the item integer or float
h
(required)
The height of the item integer or float
d
(required)
The depth or length of the item integer or float
wg The weight of the item integer or float
vr Vertical rotation. The information if the item can be rotated vertically. integer Vertical rotation. The information if the item can be rotated vertically.
q
(required)
The amount of the same items to pack integer
acceptable_bins Define which packing spaces can be used to pack items. If the parameter is not set, then all packing spaces can be used. Given values have to contain packing spaces ID included in 'bins' parameter. array
item_colors_schema Define which kind of color schema should be used string Available values:
default - colors set in the following parameters will be used 'images_item_border_color' and 'images_bin_fill_color',
'random' - x,
'item' - x
item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
item_border_color Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'

params - Optional parameters

Param name Description Data type Info
images_version Images generator version integer Available values: [1 | 2]
images_width Max. width of generated images integer Available values: 1 - 250
images_height Max. height of generated images integer Available values: 1 - 250
images_background_color Background color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_border_color
Only with the images_version: 1 parameter
Packing space border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_dashed_line_color
Only with the images_version: 1 parameter
Packing space front border color (dashed) string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_fill_color Packing space fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_border_color
Only with the images_version: 1 parameter
Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_fill_color Fill color of the last item on images showing a packing process 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_border_color
Only with the images_version: 1 parameter
Border color of the last item on images showing packing 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_format Images format string Available values: [ png , svg ]
images_sbs Generate images showing a packing process 'step-by-step' integer Available values:
0 [default] - means that images showing a packing process 'step-by-step' will not be generated,
1 - means that images showing a packing process 'step-by-step' will be generated
images_complete Generate images showing a final packing result integer Available values:
0 [default] - means that images showing final packing result will not be generated,
1 - means that images showing final packing result will be generated
images_separated Generate images showing the placement of each item separately integer Available values:
0 [default] - means that images showing the placement of each item separately will not be generated,
1 - means that images showing the placement of each item separately will be generated
item_coordinates Return coordinates (x, y, z) for each item integer Available values:
0 [default] - means that coordinates of the placement of each item will not be returned,
1 - that coordinates of the placement of each item will be returned
stats Return the statistics of a packing process (e.g. images generation time) integer Available values:
0 [default] - means that the statistics of a packing process will not be returned,
1 - means that the statistics of a packing process will be returned

Response parameters

RESPONSE

{
    "response":{
        "id":"response_id",
        "bins_packed":[
            {
                "bin_data":{
                    "w":5,
                    "h":9,
                    "d":5,
                    "id":"Bin1",
                    "used_space":62.6667,
                    "weight":0,
                    "gross_weight":0,
                    "used_weight":100,
                    "stack_height":9,
                    "order_id":null
                },
                "image_complete":"image_url.svg",
                "items":[
                    {
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":2,"y2":5,"z2":3}
                    },{
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":2,"y1":0,"z1":0,"x2":5,"y2":3,"z2":3}
                    },{
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":5,"z1":0,"x2":2,"y2":8,"z2":5}
                    },{
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":2,"y1":3,"z1":0,"x2":5,"y2":6,"z2":3}
                    },{
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":2,"y1":6,"z1":0,"x2":5,"y2":9,"z2":3}
                    }
                ],
                "not_packed_items":[]
            },{
                "bin_data":{
                    "w":3,
                    "h":19,
                    "d":3,
                    "id":"Bin2",
                    "used_space":82.4561,
                    "weight":0,
                    "gross_weight":0,
                    "used_weight":100,
                    "stack_height":19,
                    "order_id":null
                },
                "image_complete":"image_url.svg",
                "items":[
                    {
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}
                    },{
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":3,"z1":0,"x2":3,"y2":6,"z2":3}
                    },{
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":6,"z1":0,"x2":3,"y2":9,"z2":3}
                    },{
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":9,"z1":0,"x2":3,"y2":14,"z2":2}
                    },{
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":14,"z1":0,"x2":3,"y2":19,"z2":2}
                    }
                ],
                "not_packed_items":[]
            }
        ],
        "errors":[],
        "status":1,
        "not_packed_items":[]
    }
}

Param name Description Data type Info
[bins_packed] List of packed items array
errors List of possible errors that may occur in request array Example: [{'level'}]; Possible returned values:'critical' - critical error - disabling packing, 'warning' - warning about incorrect data in request
status Response status integer Possible returned values:
1 - response hasn't included critical errors,
0 - response has included critical errors. * critical error - the error disabling packing. It could be caused by lack of one of the required parameters ('username','api_key') or incorrect value of parameter (eg. a field, which should contain number, contains string).
[not_packed_items] The list of item unable to be packed e.g. incorrect parameters input, excessive weight or size array

[bins_packed] - The list of packing spaces to be packed

Param name Description Data type
bin_data Details of the packing space to be packed array
image_complete Image of the packing space to be packed url
[items] Information about items to be packed in the packing space array
[not_packed_items] Items unable to be packed in the packing space array

[bin_data] - Details of the packing space to be packed

Param name Description Data type
id Packing space ID. The number or code you use to identify the packing space. string
w Packing space width integer or float
h Packing space height integer or float
d Packing space depth/length integer or float
used_space Percentage of packing space utilized integer or float
weight Weight of items to be packed integer or float
gross_weight Weight of items to be packed + weight of packing space integer or float
used_weight Percentage of the permissible weight utilized integer or float
stack_height The height of stacked items integer or float

[items] - The list of items to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
wg The weight of the item integer or float
image_separated Image showing the position of each item url
image_sbs Images showing the packing process step-by-step url
coordinates Coordinates of items in the packing space {"x1":0,"y1":0,"z1":0,"x2":5,"y2":3,"z2":2}

[not_packed_items] - The list of items unable to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
q The amount of the same items to pack integer
wg The weight of the item integer or float

Find a Box Size

Use Find a Box Size tool to maximize the use of space and calculate the right-sized box for your packing.

URL

Request parameters

Required parameters

REQUEST

{
    "bins": [
        {
            "w": 0,
            "h": 0,
            "d": 0,
            "id": "Bin1",
            "type":"pallet"
        }
    ],
    "items": [
        {
            "w": 5,
            "h": 3,
            "d": 2,
            "q": 2,
            "vr": 1,
            "id": "Item1"
        },{
            "w": 3,
            "h": 3,
            "d": 3,
            "q": 3,
            "vr": 1,
            "id": "Item2"
        }
    ],
    "username": "YOUR_USERNAME",
    "api_key": "YOUR_API_KEY",
    "params": {
        "images_background_color": "255,255,255",
        "images_bin_border_color": "59,59,59",
        "images_bin_fill_color": "230,230,230",
        "images_item_border_color": "214,79,79",
        "images_item_fill_color": "177,14,14",
        "images_item_back_border_color": "215,103,103",
        "images_sbs_last_item_fill_color": "99,93,93",
        "images_sbs_last_item_border_color": "145,133,133",
        "images_width": 100,
        "images_height": 100,
        "images_source": "file",
        "images_sbs": 1,
        "item_coordinates": 1,
        "images_complete": 1,
        "images_separated": 1,
        "images_version": 2
    }
}
curl -X POST \
-H "Content-Type: application/json" \
-d '{"username": "USERNAME", "api_key": "API_KEY", "bins": [{"w": 0,"h": 0,"d": 0,"id": "Bin1", "type":"pallet"}],"items": [{"w": 5,"h": 3,"d": 2,"q": 2,"vr": 1,"id": "Item1"},{"w": 3,"h": 3,"d": 3,"q": 3,"vr": 1,"id": "Item2"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "images_version":2}}' \
https://global-api.3dbinpacking.com/packer/findBinSize \
-k
<?php

$data = array( 'bins' => array( array( 'id' => 'Bin1', 'h' => '0', 'w' => '0', 'd' => '0', 'type' => 'pallet' ) ), 'items' => array( array( 'id' => 'Item1', 'w' => '5', 'h' => '3', 'd' => '2', 'q' => '2', 'vr' => '1' ), array( 'id' => 'Item2', 'w' => '3', 'h' => '3', 'd' => '3', 'q' => '3', 'vr' => '1' ) ), 'username' => 'YOUR_USERNAME', 'api_key' => 'YOUR_API_KEY', 'params' => array( 'images_background_color' => '255,255,255', 'images_bin_border_color' => '59,59,59', 'images_bin_fill_color' => '230,230,230', 'images_item_border_color' => '22,22,22', 'images_item_fill_color' => '255,193,6', 'images_item_back_border_color' => '22,22,22', 'images_sbs_last_item_fill_color' => '177,14,14', 'images_sbs_last_item_border_color' => '22,22,22', 'images_format' => 'svg', 'images_width' => '50', 'images_height' => '50', 'images_source' => 'file', 'item_coordinates' => '1', 'images_complete' => '1', 'images_sbs' => '1', 'images_separated' => '0', 'images_version' => 2 ) ); $query = json_encode($data);

$url = "https://global-api.3dbinpacking.com/packer/findBinSize"; $prepared_query = 'query='.$query; $ch = curl_init($url); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $prepared_query ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $resp = curl_exec($ch); if (curl_errno($ch)) { echo 'Error #' . curl_errno($ch) . ': ' . curl_error($ch).'<br>'; } curl_close($ch);

$response = json_decode($resp,true); // display errors if(isset($response['response']['errors'])){ foreach($response['response']['errors'] as $error){ echo $error['message'].'<br>'; } } // display data if( $response['response']['status'] > -1 ){ $b_packed= $response['response']['bins_packed']; foreach ($b_packed as $bin){ echo "<h2>Bin id:{$bin['bin_data']['id']}</h2> <p> {$bin['bin_data']['w']} x {$bin['bin_data']['h']} x {$bin['bin_data']['d']}</p> <p> Weight:{$bin['bin_data']['weight']}</p> <p> Used weight:{ $bin['bin_data']['used_weight'] }</p> <img src=\"{$bin['image_complete']}\"> <h2>Items packed in this bin:</h2>"; $items = $bin['items']; echo '<table style="text-align: center"> <tr><th>Item id</th> <th>Item dimensions</th> <th>Item weight</th> <th>Separated item</th> <th>Step by step</th></tr>'; foreach ( $items as $item){ echo "<tr><td>{$item['id']}</td> <td> {$item['w']} x {$item['h']} x {$bin['bin_data']['d']}</td> <td> {$item['wg']}</td> <td><img src=\"{$item['image_separated']}\"></td> <td><img src=\"{$item['image_sbs']}\"></td> </tr>"; } echo '</table>'; echo '<hr>';

} }

#!/usr/bin/python

import httplib
import urllib
import json

conn = httplib.HTTPConnection(host='global-api.3dbinpacking.com', port=80) data = {"username": "USERNAME", "api_key": "API_KEY", "bins": [{"w": 0,"h": 0,"d": 0,"id": "Bin1", "type":"pallet"}],"items": [{"w": 5,"h": 3,"d": 2,"q": 2,"vr": 1,"id": "Item1"},{"w": 3,"h": 3,"d": 3,"q": 3,"vr": 1,"id": "Item2"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "images_version":2}} params = urllib.urlencode( {'query':json.dumps(data)} ) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn.request( "POST", "/packer/findBinSize", params, headers ) content = conn.getresponse( ).read( ) conn.close( ) print content

package javaapplication1;

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;; import org.json.simple.JSONObject; import org.springframework.web.client.RestTemplate;

public class JavaApplication1 {

/** * @param args the command line arguments */ public static void main(String[] args) throws MalformedURLException, ProtocolException, IOException { RestTemplate restTemplate = new RestTemplate(); JSONObject json = new JSONObject();

//SET BINS List<Map<String , String>> bins = new ArrayList<Map<String,String>>();

Map<String, String> bin1 = new HashMap<String, String>(); bin1.put("id", "Bin1"); bin1.put("h", "0"); bin1.put("w", "0"); bin1.put("d", "0"); bin1.put("type", "pallet"); bins.add(bin1);

//SET ITEMS List<Map<String , String>> items = new ArrayList<Map<String,String>>(); Map<String, String> item1 = new HashMap<String, String>(); item1.put("id", "Item1"); item1.put("w", "5"); item1.put("h", "3"); item1.put("d", "2"); item1.put("q", "2"); item1.put("vr", "1"); items.add(item1); Map<String, String> item2 = new HashMap<String, String>(); item2.put("id", "Item2"); item2.put("w", "3"); item2.put("h", "3"); item2.put("d", "3"); item2.put("q", "3"); item2.put("vr", "1"); items.add(item2);

//SET PARAMETERS Map <String , String > params = new HashMap <String , String >(); params.put("images_background_color", "255,255,255") params.put("images_bin_border_color", "59,59,59") params.put("images_bin_fill_color", "230,230,230") params.put("images_item_border_color", "22,22,22") params.put("images_item_fill_color", "255,193,6") params.put("images_item_back_border_color", "22,22,22") params.put("images_sbs_last_item_fill_color", "177,14,14") params.put("images_sbs_last_item_border_color", "22,22,22") params.put("images_format", "svg") params.put("images_width", "50") params.put("images_height", "50") params.put("images_source", "file") params.put("item_coordinates", "1") params.put("images_complete", "1") params.put("images_sbs", "1") params.put("images_separated", "0") params.put("images_version", "2")

//ADD ELEMENTS TO JSON json.put("username", "YOUR_USERNAME"); json.put("api_key", "YOUR_API_KEY"); json.put("items", items); json.put("bins", bins); json.put("params", params);

//CALL QUERY HttpURLConnection conn; URL addr = new URL("https://global-api.3dbinpacking.com/packer/findBinSize"); conn = (HttpURLConnection) addr.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.connect(); OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream());

// prepare POST body String query = "query=" + json.toString();

osw.write(query); osw.flush(); osw.close();

BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String response_json = br.readLine();

//DO SOMETHING COOL WITH THE RESPONSE System.out.println(response_json); } }

string data;
System.Net.HttpWebRequest req = System.Net.WebRequest.Create("https://global-api.3dbinpacking.com/packer/findBinSize") as System.Net.HttpWebRequest;

var request_data = new {username = "YOUR_USERNAME", api_key = "YOUR_API_KEY", items = new[] { new { id = "Item1", w = "5", h = "3", d = "2", q = "2", vr = "1"}, new { id = "Item2", w = "3", h = "3", d = "3", q = "3", vr = "1"} }, bins = new[] { new { id = "Bin1", h = "0", w = "0", d = "0", type = "pallet"} },

@params = new { images_background_color = "255,255,255", images_bin_border_color = "59,59,59", images_bin_fill_color = "230,230,230", images_item_border_color = "22,22,22", images_item_fill_color = "255,193,6", images_item_back_border_color = "22,22,22", images_sbs_last_item_fill_color = "177,14,14", images_sbs_last_item_border_color = "22,22,22", images_format = "svg", images_width = "50", images_height = "50", images_source = "file", item_coordinates = "1", images_complete = "1", images_sbs = "1", images_separated = "0", images_version = "1" } };

string json_str = JsonConvert.SerializeObject(request_data);

string queryParam = "query="+json_str;

byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(queryParam); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postBytes.Length;

System.IO.Stream postStream = req.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();

X509Certificate Cert = X509Certificate2.CreateFromCertFile("path_to_pem_key\global-api.3dbinpacking.com.pem"); req.ClientCertificates.Add(Cert);

using (System.Net.HttpWebResponse response = req.GetResponse() as System.Net.HttpWebResponse) { System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()); data = reader.ReadToEnd(); }

Param name Description Data type
username
(required)
Username. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
api_key
(required)
API key. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
[bins]
(required)
Array of packing spaces parameters array
[items]
(required)
Array of items parameters. Limit: maximum total number of items per request = 4999 array
params Array of extra request parameters array

[bins] - Packing spaces array details

Param name Description Data type
id
(required)
Packing space ID. The number or code you use to identify the packing space. string
w
(required)
Packing space max. width
(required)
float
h
(required)
Packing space max. height float
d
(required)
Packing space max. depth/length float
type
Only with the images_version: 2 parameter
Specifies whether the image will be presented in the form of a box or a pallet translation missing: en.params_type_stringt

[items] - Items array details

Param name Description Data type Info
id
(required)
Item ID/SKU. The number or code you use to identify what is being packed. string
w
(required)
The width of the item integer or float
h
(required)
The height of the item integer or float
d
(required)
The depth or length of the item integer or float
wg The weight of the item integer or float
vr Vertical rotation. The information if the item can be rotated vertically. integer Vertical rotation. The information if the item can be rotated vertically.
q
(required)
The amount of the same items to pack integer
item_colors_schema Define which kind of color schema should be used string
item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
item_border_color Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'

params - Optional parameters

Param name Description Data type Info
images_version Images generator version integer Available values: [1 | 2]
images_width Max. width of generated images integer Available values: 1 - 250
images_height Max. height of generated images integer Available values: 1 - 250
images_background_color Background color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_border_color
Only with the images_version: 1 parameter
Packing space border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_dashed_line_color
Only with the images_version: 1 parameter
Packing space front border color (dashed) string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_fill_color Packing space fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_border_color
Only with the images_version: 1 parameter
Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_fill_color Fill color of the last item on images showing a packing process 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_border_color
Only with the images_version: 1 parameter
Border color of the last item on images showing packing 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_format Images format string Available values: [ png , svg ]
images_sbs Generate images showing a packing process 'step-by-step' integer Available values:
0 [default] - means that images showing a packing process 'step-by-step' will not be generated,
1 - means that images showing a packing process 'step-by-step' will be generated
images_complete Generate images showing a final packing result integer Available values:
0 [default] - means that images showing final packing result will not be generated,
1 - means that images showing final packing result will be generated
images_separated Generate images showing the placement of each item separately integer Available values:
0 [default] - means that images showing the placement of each item separately will not be generated,
1 - means that images showing the placement of each item separately will be generated
item_coordinates Return coordinates (x, y, z) for each item integer Available values:
0 [default] - means that coordinates of the placement of each item will not be returned,
1 - that coordinates of the placement of each item will be returned
stats Return the statistics of a packing process (e.g. images generation time) integer Available values:
0 [default] - means that the statistics of a packing process will not be returned,
1 - means that the statistics of a packing process will be returned

Response parameters

RESPONSE

{
    "response":{
        "id":"response_id",
        "bins_packed":[
            {
                "bin_data":{
                    "w":8,
                    "h":3,
                    "d":7,
                    "id":null,
                    "used_space":83.9286,
                    "weight":0,
                    "gross_weight":0,
                    "used_weight":100,
                    "stack_height":3
                },
                "image_complete":"image_url.png",
                "items":[
                    {
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":5,"y2":3,"z2":2}
                    },{
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":0,"y1":0,"z1":2,"x2":5,"y2":3,"z2":4}
                    },{
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":2,"y1":0,"z1":4,"x2":5,"y2":3,"z2":7}
                    },{
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":5,"y1":0,"z1":0,"x2":8,"y2":3,"z2":3}
                    },{
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":5,"y1":0,"z1":3,"x2":8,"y2":3,"z2":6}
                    }
                ]
            }
        ],
        "errors":[],
        "status":1,
        "not_packed_items":[]
    }
}

Param name Description Data type Info
[bins_packed] List of packed items array
errors List of possible errors that may occur in request array Example: [{'level'}]; Possible returned values:'critical' - critical error - disabling packing, 'warning' - warning about incorrect data in request
status Response status integer Possible returned values:
1 - response hasn't included critical errors,
0 - response has included critical errors. * critical error - the error disabling packing. It could be caused by lack of one of the required parameters ('username','api_key') or incorrect value of parameter (eg. a field, which should contain number, contains string).
[not_packed_items] The list of item unable to be packed e.g. incorrect parameters input, excessive weight or size array

[bins_packed] - The list of packing spaces to be packed

Param name Description Data type
bin_data Details of the packing space to be packed array
image_complete Image of the packing space to be packed url
[items] Information about items to be packed in the packing space array
[not_packed_items] Items unable to be packed in the packing space array

[bin_data] - Details of the packing space to be packed

Param name Description Data type
id Packing space ID. The number or code you use to identify the packing space. string
w Packing space width integer or float
h Packing space height integer or float
d Packing space depth/length integer or float
used_space Percentage of packing space utilized integer or float
weight Weight of items to be packed integer or float
gross_weight Weight of items to be packed + weight of packing space integer or float
used_weight Percentage of the permissible weight utilized integer or float
stack_height The height of stacked items integer or float

[items] - The list of items to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
wg The weight of the item integer or float
image_separated Image showing the position of each item url
image_sbs Images showing the packing process step-by-step url
coordinates Coordinates of items in the packing space {"x1":0,"y1":0,"z1":0,"x2":5,"y2":3,"z2":2}

[not_packed_items] - The list of items unable to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
q The amount of the same items to pack integer
wg The weight of the item integer or float

Try Out Box Sizes

Use Try Out Box Sizes tool to compare packing items in different sized boxes or packing spaces.

URL

Request parameters

Required parameters

REQUEST

{
    "username":"USERNAME",
    "api_key":"API_KEY",
    "items":
    [
       {"id":"Speakers","w":3,"h":3,"d":3,"wg":2,"q":3,"vr":true},
       {"id":"Bigger item","w":3,"h":3,"d":5,"wg":1,"q":2,"vr":true}
    ],
    "bins":
    [
       {"id":"Pack M","h":4,"w":4,"d":4,"wg":"","max_wg":"", "type":"pallet"},
       {"id":"Pack S","h":3,"w":3,"d":6,"wg":"","max_wg":"", "type":"box"}
    ],
    "params":
    {
       "images_background_color":"255,255,255",
       "images_bin_border_color":"59,59,59",
       "images_bin_fill_color":"230,230,230",
       "images_item_border_color":"22,22,22",
       "images_item_fill_color":"255,193,6",
       "images_item_back_border_color":"22,22,22",
       "images_sbs_last_item_fill_color":"177,14,14",
       "images_sbs_last_item_border_color":"22,22,22",
       "images_format":"svg",
       "images_width":50,
       "images_height":50,
       "images_source":"file",
       "stats":0,
       "item_coordinates":1,
       "images_complete":1,
       "images_sbs":1,
       "images_separated":0,
       "images_version":2
    }
}
curl -X POST \
-H "Content-Type: application/json" \
-d '{"username": "USERNAME", "api_key": "API_KEY", "items": [{"id": "Speakers", "w": 3, "h": 3, "d": 3, "wg": 2, "q": 3, "vr": true},{"id": "Bigger item", "w": 3, "h": 3, "d": 5, "wg": 1, "q": 2, "vr": true}], "bins": [{"id": "Pack M", "h": 4, "w": 4, "d": 4, "wg": "", "max_wg": "", "type":"pallet"},{"id": "Pack S", "h": 3, "w": 3, "d": 6, "wg": "", "max_wg": "", "type":"box"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "stats": 0, "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "images_version":2}}' \
https://global-api.3dbinpacking.com/packer/pack \
-k
<?php
$data = array(
    'bins' => array(
            array(
                    'id' => 'Pack M',
                    'h' => '4',
                    'w' => '4',
                    'd' => '4',
                    'wg' => '',
                    'max_wg' => '',
                    'type' => 'pallet'
                ),
            array(
                    'id' => 'Pack S',
                    'h' => '3',
                    'w' => '3',
                    'd' => '6',
                    'wg' => '',
                    'max_wg' => '',
                    'type' => 'pallet'
                )
        ),
    'items' => array(
            array(
                    'id' => 'Speakers',
                    'w' => '3',
                    'h' => '3',
                    'd' => '3',
                    'wg' => '2',
                    'q' => '3',
                    'vr' => '1'
                ),
            array(
                    'id' => 'Bigger item',
                    'w' => '3',
                    'h' => '3',
                    'd' => '5',
                    'wg' => '1',
                    'q' => '2',
                    'vr' => '1'
                )
        ),
    'username' => 'YOUR_USERNAME',
    'api_key' => 'YOUR_API_KEY',
    'params' => array(
            'images_background_color' => '255,255,255',
            'images_bin_border_color' => '59,59,59',
            'images_bin_fill_color' => '230,230,230',
            'images_item_border_color' => '22,22,22',
            'images_item_fill_color' => '255,193,6',
            'images_item_back_border_color' => '22,22,22',
            'images_sbs_last_item_fill_color' => '177,14,14',
            'images_sbs_last_item_border_color' => '22,22,22',
            'images_format' => 'svg',
            'images_width' => '50',
            'images_height' => '50',
            'images_source' => 'file',
            'stats' => '0',
            'item_coordinates' => '1',
            'images_complete' => '1',
            'images_sbs' => '1',
            'images_separated' => '0',
            'images_version" => 2
        )
);
$query = json_encode($data);

$url = "https://global-api.3dbinpacking.com/packer/pack"; $prepared_query = 'query='.$query; $ch = curl_init($url); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $prepared_query ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $resp = curl_exec($ch); if (curl_errno($ch)) { echo 'Error #' . curl_errno($ch) . ': ' . curl_error($ch).'<br>'; } curl_close($ch);

$response = json_decode($resp,true); // display errors if(isset($response['response']['errors'])){ foreach($response['response']['errors'] as $error){ echo $error['message'].'<br>'; } } // display data if( $response['response']['status'] > -1 ){ $b_packed= $response['response']['bins_packed']; foreach ($b_packed as $bin){ echo "<h2>Bin id:{$bin['bin_data']['id']}</h2> <p> {$bin['bin_data']['w']} x {$bin['bin_data']['h']} x {$bin['bin_data']['d']}</p> <p> Weight:{$bin['bin_data']['weight']}</p> <p> Used weight:{ $bin['bin_data']['used_weight'] }</p> <img src=\"{$bin['image_complete']}\"> <h2>Items packed in this bin:</h2>"; $items = $bin['items']; echo '<table style="text-align: center"> <tr><th>Item id</th> <th>Item dimensions</th> <th>Item weight</th> <th>Separated item</th> <th>Step by step</th></tr>'; foreach ( $items as $item){ echo "<tr><td>{$item['id']}</td> <td> {$item['w']} x {$item['h']} x {$bin['bin_data']['d']}</td> <td> {$item['wg']}</td> <td><img src=\"{$item['image_separated']}\"></td> <td><img src=\"{$item['image_sbs']}\"></td> </tr>"; } echo '</table>'; echo '<hr>';

} }

#!/usr/bin/python

import httplib
import urllib
import json

conn = httplib.HTTPConnection(host='global-api.3dbinpacking.com', port=80) data = {"username": "USERNAME", "api_key": "API_KEY", "items": [{"id": "Speakers", "w": 3, "h": 3, "d": 3, "wg": 2, "q": 3, "vr": true},{"id": "Bigger item", "w": 3, "h": 3, "d": 5, "wg": 1, "q": 2, "vr": true}], "bins": [{"id": "Pack M", "h": 4, "w": 4, "d": 4, "wg": "", "max_wg": "", "type":"pallet"},{"id": "Pack S", "h": 3, "w": 3, "d": 6, "wg": "", "max_wg": "", "type":"box"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "stats": 0, "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "images_version":2}} params = urllib.urlencode( {'query':json.dumps(data)} ) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn.request( "POST", "/packer/pack", params, headers ) content = conn.getresponse( ).read( ) conn.close( ) print content

package javaapplication1;

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;; import org.json.simple.JSONObject; import org.springframework.web.client.RestTemplate;

public class JavaApplication1 {

/** * @param args the command line arguments */ public static void main(String[] args) throws MalformedURLException, ProtocolException, IOException { RestTemplate restTemplate = new RestTemplate(); JSONObject json = new JSONObject();

//SET BINS List<Map<String , String>> bins = new ArrayList<Map<String,String>>();

Map<String, String> bin1 = new HashMap<String, String>(); bin1.put("id", "Pack M"); bin1.put("h", "4"); bin1.put("w", "4"); bin1.put("d", "4"); bin1.put("wg", ""); bin1.put("max_wg", ""); bin1.put("type", "pallet"); bins.add(bin1); Map<String, String> bin2 = new HashMap<String, String>(); bin2.put("id", "Pack S"); bin2.put("h", "3"); bin2.put("w", "3"); bin2.put("d", "6"); bin2.put("wg", ""); bin2.put("max_wg", ""); bin2.put("type", "pallet"); bins.add(bin2);

//SET ITEMS List<Map<String , String>> items = new ArrayList<Map<String,String>>(); Map<String, String> item1 = new HashMap<String, String>(); item1.put("id", "Speakers"); item1.put("w", "3"); item1.put("h", "3"); item1.put("d", "3"); item1.put("wg", "2"); item1.put("q", "3"); item1.put("vr", "1"); items.add(item1); Map<String, String> item2 = new HashMap<String, String>(); item2.put("id", "Bigger item"); item2.put("w", "3"); item2.put("h", "3"); item2.put("d", "5"); item2.put("wg", "1"); item2.put("q", "2"); item2.put("vr", "1"); items.add(item2);

//SET PARAMETERS Map <String , String > params = new HashMap <String , String >(); params.put("images_background_color", "255,255,255") params.put("images_bin_border_color", "59,59,59") params.put("images_bin_fill_color", "230,230,230") params.put("images_item_border_color", "22,22,22") params.put("images_item_fill_color", "255,193,6") params.put("images_item_back_border_color", "22,22,22") params.put("images_sbs_last_item_fill_color", "177,14,14") params.put("images_sbs_last_item_border_color", "22,22,22") params.put("images_format", "svg") params.put("images_width", "50") params.put("images_height", "50") params.put("images_source", "file") params.put("stats", "0") params.put("item_coordinates", "1") params.put("images_complete", "1") params.put("images_sbs", "1") params.put("images_separated", "0") params.put("images_version", "2")

//ADD ELEMENTS TO JSON json.put("username", "YOUR_USERNAME"); json.put("api_key", "YOUR_API_KEY"); json.put("items", items); json.put("bins", bins); json.put("params", params);

//CALL QUERY HttpURLConnection conn; URL addr = new URL("https://global-api.3dbinpacking.com/packer/pack"); conn = (HttpURLConnection) addr.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.connect(); OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream());

// prepare POST body String query = "query=" + json.toString();

osw.write(query); osw.flush(); osw.close();

BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String response_json = br.readLine();

//DO SOMETHING COOL WITH THE RESPONSE System.out.println(response_json); } }

string data;
System.Net.HttpWebRequest req = System.Net.WebRequest.Create("https://global-api.3dbinpacking.com/packer/pack") as System.Net.HttpWebRequest;

var request_data = new {username = "YOUR_USERNAME", api_key = "YOUR_API_KEY", items = new[] { new { id = "Speakers", w = "3", h = "3", d = "3", wg = "2", q = "3", vr = "1"}, new { id = "Bigger item", w = "3", h = "3", d = "5", wg = "1", q = "2", vr = "1"} }, bins = new[] { new { id = "Pack M", h = "4", w = "4", d = "4", wg = "", max_wg = "", type = "pallet"}, new { id = "Pack S", h = "3", w = "3", d = "6", wg = "", max_wg = "", type = "box"} },

@params = new { images_background_color = "255,255,255", images_bin_border_color = "59,59,59", images_bin_fill_color = "230,230,230", images_item_border_color = "22,22,22", images_item_fill_color = "255,193,6", images_item_back_border_color = "22,22,22", images_sbs_last_item_fill_color = "177,14,14", images_sbs_last_item_border_color = "22,22,22", images_format = "svg", images_width = "50", images_height = "50", images_source = "file", stats = "0", item_coordinates = "1", images_complete = "1", images_sbs = "1", images_separated = "0", images_version = "2" } };

string json_str = JsonConvert.SerializeObject(request_data);

string queryParam = "query="+json_str;

byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(queryParam); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postBytes.Length;

System.IO.Stream postStream = req.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();

X509Certificate Cert = X509Certificate2.CreateFromCertFile("path_to_pem_key\global-api.3dbinpacking.com.pem"); req.ClientCertificates.Add(Cert);

using (System.Net.HttpWebResponse response = req.GetResponse() as System.Net.HttpWebResponse) { System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()); data = reader.ReadToEnd(); }

Param name Description Data type
username
(required)
Username. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
api_key
(required)
API key. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
[bins]
(required)
Array of packing spaces parameters array
[items]
(required)
Array of items parameters. Limit: maximum total number of items per request = 4999 array
params Array of extra request parameters of extra request parameters array

[bins] - Packing spaces array details

Param name Description Data type
id
(required)
Packing space ID. The number or code you use to identify the packing space. string
w
(required)
Packing space width integer or float
h
(required)
Packing space height integer or float
d
(required)
Packing space depth/length integer or float
wg The weight of the packing space integer or float
max_wg The maximum weight that this packing space can hold. Value set to '0' (zero) means there is no weight limit integer or float
type
Only with the images_version: 2 parameter
Specifies whether the image will be presented in the form of a box or a pallet translation missing: en.params_type_stringt

[items] - Items array details

Param name Description Data type Info
id
(required)
Item ID/SKU. The number or code you use to identify what is being packed. string
w
(required)
The width of the item integer or float
h
(required)
The height of the item integer or float
d
(required)
The depth or length of the item integer or float
wg The weight of the item integer or float
vr Vertical rotation. The information if the item can be rotated vertically. integer
q
(required)
The amount of the same items to pack integer
item_colors_schema Define which kind of color schema should be used string Available values:
default - colors set in the following parameters will be used 'images_item_border_color' and 'images_bin_fill_color',
'random' - x,
'item' - x
item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
item_border_color Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'

params - Optional parameters

Param name Description Data type Info
images_version Images generator version integer Available values: [1 | 2]
images_width Max. width of generated images integer Available values: 1 - 250
images_height Max. height of generated images integer Available values: 1 - 250
images_background_color Background color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_border_color
Only with the images_version: 1 parameter
Packing space border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_dashed_line_color
Only with the images_version: 1 parameter
Packing space front border color (dashed) string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_fill_color Packing space fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_border_color
Only with the images_version: 1 parameter
Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_fill_color Fill color of the last item on images showing a packing process 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_border_color
Only with the images_version: 1 parameter
Border color of the last item on images showing packing 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_format Images format string Available values: [ png , svg ]
images_sbs Generate images showing a packing process 'step-by-step' integer Available values:
0 [default] - means that images showing a packing process 'step-by-step' will not be generated,
1 - means that images showing a packing process 'step-by-step' will be generated
images_complete Generate images showing a final packing result integer Available values:
0 [default] - means that images showing final packing result will not be generated,
1 - means that images showing final packing result will be generated
images_separated Generate images showing the placement of each item separately integer Available values:
0 [default] - means that images showing the placement of each item separately will not be generated,
1 - means that images showing the placement of each item separately will be generated
item_coordinates Return coordinates (x, y, z) for each item integer Available values:
0 [default] - means that coordinates of the placement of each item will not be returned,
1 - that coordinates of the placement of each item will be returned
stats Return the statistics of a packing process (e.g. images generation time) integer Available values:
0 [default] - means that the statistics of a packing process will not be returned,
1 - means that the statistics of a packing process will be returned

Response parameters

RESPONSE

{
    "response":{ 
        "id":"response_id",
        "bins_packed":[
            {
                "bin_data":{
                        "w":4,
                        "h":4,
                        "d":4,
                        "id":"Pack M",
                        "used_space":42.1875,
                        "weight":2,
                        "gross_weight":2,
                        "used_weight":100,
                        "stack_height":3
                    },
                "image_complete":"image_url.svg",
                "items":[
                    {
                        "id":"Speakers",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":2,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}
                    }
                ],
                "not_packed_items":[
                    {
                        "id":"Speakers",
                        "q":2
                    },
                    {
                        "id":"Bigger item",
                        "q":2
                    }
                ]
            },{
                "bin_data":{
                    "w":3,
                    "h":3,
                    "d":6,
                    "id":"Pack S",
                    "used_space":100,
                    "weight":4,
                    "gross_weight":4,
                    "used_weight":100,
                    "stack_height":3
                },
                "image_complete":"image_url.svg",
                "items":[
                    {
                        "id":"Speakers",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":2,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}
                    },{
                        "id":"Speakers",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":2,
                        "image_sbs":"image_url.svg",
                        "coordinates":{"x1":0,"y1":0,"z1":3,"x2":3,"y2":3,"z2":6}
                    }
                ],
                "not_packed_items":[
                    {
                        "id":"Speakers",
                        "q":1
                    },
                    {
                        "id":"Bigger item",
                        "q":2
                    }
                ]
            }
        ],
        "errors":[],
        "status":1,
        "not_packed_items":[]
    }
}

Param name Description Data type Info
[bins_packed] List of packed items array
errors List of possible errors that may occur in request array Example: [{'level'}]; Possible returned values:'critical' - critical error - disabling packing, 'warning' - warning about incorrect data in request
status Response status integer Possible returned values:
1 - response hasn't included critical errors,
0 - response has included critical errors. * critical error - the error disabling packing. It could be caused by lack of one of the required parameters ('username','api_key') or incorrect value of parameter (eg. a field, which should contain number, contains string).
[not_packed_items] The list of item unable to be packed e.g. incorrect parameters input, excessive weight or size array

[bins_packed] - The list of packing spaces to be packed

Param name Description Data type
bin_data Details of the packing space to be packed array
image_complete Image of the packing space to be packed url
[items] Information about items to be packed in the packing space array
[not_packed_items] Items unable to be packed in the packing space array

[bin_data] - Details of the packing space to be packed

Param name Description Data type
id Packing space ID. The number or code you use to identify the packing space. string
w Packing space width integer or float
h Packing space height integer or float
d Packing space depth/length integer or float
used_space Percentage of packing space utilized integer or float
weight Weight of items to be packed integer or float
gross_weight Weight of items to be packed + weight of packing space integer or float
used_weight Percentage of the permissible weight utilized integer or float
stack_height The height of stacked items integer or float

[items] - The list of items to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
wg The weight of the item integer or float
image_separated Image showing the position of each item url
image_sbs Images showing the packing process step-by-step url
coordinates Coordinates of items in the packing space {"x1":0,"y1":0,"z1":0,"x2":5,"y2":3,"z2":2}

[not_packed_items] - The list of items unable to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
q The amount of the same items to pack integer
wg The weight of the item integer or float

Check Max Load

Use Check Max Load to Check exactly how many items will fill a box or packing space to capacity.

URL

Request parameters

Required parameters

REQUEST

{
    "username":"USERNAME",
    "api_key":"API_KEY",
    "bins": [
      {
         "w": 5,
         "h": 5,
         "d": 5,
         "max_wg": 0,
         "id": "Bin1",
         "type":"pallet"
      },
      {
         "w": 4,
         "h": 3,
         "d": 3,
         "max_wg": 0,
         "id": "Bin2",
         "type":"box"
      }
   ],
   "items": [
      {
         "w": 5,
         "h": 3,
         "d": 2,
         "vr": 1,
         "wg": 0,
         "id": "Item1"
      },
      {
         "w": 3,
         "h": 3,
         "d": 3,
         "vr": 1,
         "wg": 0,
         "id": "Item2"
      }
   ],
   "params": {
      "images_version": 2,
      "images_background_color": "255,255,255",
      "images_bin_border_color": "59,59,59",
      "images_bin_fill_color": "230,230,230",
      "images_item_border_color": "214,79,79",
      "images_item_fill_color": "177,14,14",
      "images_item_back_border_color": "215,103,103",
      "images_sbs_last_item_fill_color": "99,93,93",
      "images_sbs_last_item_border_color": "145,133,133",
      "images_width": 100,
      "images_height": 100,
      "images_source": "file",
      "images_sbs": 1,
      "item_coordinates": 1,
      "images_complete": 1,
      "images_separated": 1
   }
}
curl -X POST \
-H "Content-Type: application/json" \
-d '{"username": "USERNAME", "api_key": "API_KEY", "bins": [{"w": 5,"h": 5,"d": 5,"max_wg": 0,"id": "Bin1","type":"pallet"},{"w": 4,"h": 3,"d": 3,"max_wg": 0,"id": "Bin2","type":"box"}],"items": [{"w": 5,"h": 3,"d": 2,"vr": 1,"wg": 0,"id": "Item1"},{"w": 3,"h": 3,"d": 3,"vr": 1,"wg": 0,"id": "Item2"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "stats": 0, "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "images_version":2}}' \
https://global-api.3dbinpacking.com/packer/fillContainer \
-k
<?php

$data = array( 'bins' => array( array( 'id' => 'Bin1', 'h' => '5', 'w' => '5', 'd' => '5', 'wg' => '', 'max_wg' => '', 'type' => pallet' ), array( 'id' => 'Bin2', 'h' => '4', 'w' => '3', 'd' => '3', 'wg' => '', 'max_wg' => '', 'type' => 'pallet' ) ), 'items' => array( array( 'id' => 'Item1', 'w' => '5', 'h' => '3', 'd' => '2', 'wg' => '0', 'vr' => '1' ), array( 'id' => 'Item2', 'w' => '3', 'h' => '3', 'd' => '3', 'wg' => '0', 'vr' => '1' ) ), 'username' => 'YOUR_USERNAME', 'api_key' => 'YOUR_API_KEY', 'params' => array( 'images_background_color' => '255,255,255', 'images_bin_border_color' => '59,59,59', 'images_bin_fill_color' => '230,230,230', 'images_item_border_color' => '22,22,22', 'images_item_fill_color' => '255,193,6', 'images_item_back_border_color' => '22,22,22', 'images_sbs_last_item_fill_color' => '177,14,14', 'images_sbs_last_item_border_color' => '22,22,22', 'images_format' => 'svg', 'images_width' => '50', 'images_height' => '50', 'images_source' => 'file', 'stats' => '0', 'item_coordinates' => '1', 'images_complete' => '1', 'images_sbs' => '1', 'images_separated' => '0', 'images_vesrion' => 2 ) ); $query = json_encode($data);

$url = "https://global-api.3dbinpacking.com/packer/fillContainer"; $prepared_query = 'query='.$query; $ch = curl_init($url); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $prepared_query ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $resp = curl_exec($ch); if (curl_errno($ch)) { echo 'Error #' . curl_errno($ch) . ': ' . curl_error($ch).'<br>'; } curl_close($ch);

$response = json_decode($resp,true); // display errors if(isset($response['response']['errors'])){ foreach($response['response']['errors'] as $error){ echo $error['message'].'<br>'; } } // display data if( $response['response']['status'] > -1 ){ $b_packed= $response['response']['bins_packed']; foreach ($b_packed as $bin){ echo "<h2>Bin id:{$bin['bin_data']['id']}</h2> <p> {$bin['bin_data']['w']} x {$bin['bin_data']['h']} x {$bin['bin_data']['d']}</p> <p> Weight:{$bin['bin_data']['weight']}</p> <p> Used weight:{ $bin['bin_data']['used_weight'] }</p> <img src=\"{$bin['image_complete']}\"> <h2>Items packed in this bin:</h2>"; $items = $bin['items']; echo '<table style="text-align: center"> <tr><th>Item id</th> <th>Item dimensions</th> <th>Item weight</th> <th>Separated item</th> <th>Step by step</th></tr>'; foreach ( $items as $item){ echo "<tr><td>{$item['id']}</td> <td> {$item['w']} x {$item['h']} x {$bin['bin_data']['d']}</td> <td> {$item['wg']}</td> <td><img src=\"{$item['image_separated']}\"></td> <td><img src=\"{$item['image_sbs']}\"></td> </tr>"; } echo '</table>'; echo '<hr>';

} }

#!/usr/bin/python

import httplib
import urllib
import json

conn = httplib.HTTPConnection(host='global-api.3dbinpacking.com', port=80) data = {"username": "USERNAME", "api_key": "API_KEY", "bins": [{"w": 5,"h": 5,"d": 5,"max_wg": 0,"id": "Bin1", "type":"pallet"},{"w": 4,"h": 3,"d": 3,"max_wg": 0,"id": "Bin2","type":"box"}],"items": [{"w": 5,"h": 3,"d": 2,"vr": 1,"wg": 0,"id": "Item1"},{"w": 3,"h": 3,"d": 3,"vr": 1,"wg": 0,"id": "Item2"}], "params": {"images_background_color": "255,255,255", "images_bin_border_color": "59,59,59", "images_bin_fill_color": "230,230,230", "images_item_border_color": "22,22,22", "images_item_fill_color": "255,193,6", "images_item_back_border_color": "22,22,22", "images_sbs_last_item_fill_color": "177,14,14", "images_sbs_last_item_border_color": "22,22,22", "images_format": "svg", "images_width": 50, "images_height": 50, "images_source": "file", "stats": 0, "item_coordinates": 1, "images_complete": 1, "images_sbs": 1, "images_separated": 0, "images_version":2}} params = urllib.urlencode( {'query':json.dumps(data)} ) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn.request( "POST", "/packer/fillContainer", params, headers ) content = conn.getresponse( ).read( ) conn.close( ) print content

package javaapplication1;

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;; import org.json.simple.JSONObject; import org.springframework.web.client.RestTemplate;

public class JavaApplication1 {

/** * @param args the command line arguments */ public static void main(String[] args) throws MalformedURLException, ProtocolException, IOException { RestTemplate restTemplate = new RestTemplate(); JSONObject json = new JSONObject();

//SET BINS List<Map<String , String>> bins = new ArrayList<Map<String,String>>();

Map<String, String> bin1 = new HashMap<String, String>(); bin1.put("id", "Bin1"); bin1.put("h", "5"); bin1.put("w", "5"); bin1.put("d", "5"); bin1.put("wg", ""); bin1.put("max_wg", ""); bin1.put("type", "pallet"); bins.add(bin1); Map<String, String> bin2 = new HashMap<String, String>(); bin2.put("id", "Bin2"); bin2.put("h", "3"); bin2.put("w", "4"); bin2.put("d", "3"); bin2.put("wg", ""); bin2.put("max_wg", ""); bin2.put("type":"box"); bins.add(bin2);

//SET ITEMS List<Map<String , String>> items = new ArrayList<Map<String,String>>(); Map<String, String> item1 = new HashMap<String, String>(); item1.put("id", "Item1"); item1.put("w", "5"); item1.put("h", "3"); item1.put("d", "2"); item1.put("wg", "0"); item1.put("vr", "1"); items.add(item1); Map<String, String> item2 = new HashMap<String, String>(); item2.put("id", "Item2"); item2.put("w", "3"); item2.put("h", "3"); item2.put("d", "3"); item2.put("wg", "0"); item2.put("vr", "1"); items.add(item2);

//SET PARAMETERS Map <String , String > params = new HashMap <String , String >(); params.put("images_background_color", "255,255,255") params.put("images_bin_border_color", "59,59,59") params.put("images_bin_fill_color", "230,230,230") params.put("images_item_border_color", "22,22,22") params.put("images_item_fill_color", "255,193,6") params.put("images_item_back_border_color", "22,22,22") params.put("images_sbs_last_item_fill_color", "177,14,14") params.put("images_sbs_last_item_border_color", "22,22,22") params.put("images_format", "svg") params.put("images_width", "50") params.put("images_height", "50") params.put("images_source", "file") params.put("stats", "0") params.put("item_coordinates", "1") params.put("images_complete", "1") params.put("images_sbs", "1") params.put("images_separated", "0") params.put("images_version", "2")

//ADD ELEMENTS TO JSON json.put("username", "YOUR_USERNAME"); json.put("api_key", "YOUR_API_KEY"); json.put("items", items); json.put("bins", bins); json.put("params", params);

//CALL QUERY HttpURLConnection conn; URL addr = new URL("https://global-api.3dbinpacking.com/packer/fillContainer"); conn = (HttpURLConnection) addr.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.connect(); OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream());

// prepare POST body String query = "query=" + json.toString();

osw.write(query); osw.flush(); osw.close();

BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String response_json = br.readLine();

//DO SOMETHING COOL WITH THE RESPONSE System.out.println(response_json); } }

string data;
System.Net.HttpWebRequest req = System.Net.WebRequest.Create("https://global-api.3dbinpacking.com/packer/fillContainer") as System.Net.HttpWebRequest;

var request_data = new {username = "YOUR_USERNAME", api_key = "YOUR_API_KEY", items = new[] { new { id = "Item1", w = "5", h = "3", d = "2", wg = "0", vr = "1"}, new { id = "Item2", w = "3", h = "3", d = "3", wg = "0", vr = "1"} }, bins = new[] { new { id = "Bin1", h = "5", w = "5", d = "5", wg = "", max_wg = "", type = "pallet"}, new { id = "Bin2", h = "3", w = "4", d = "3", wg = "", max_wg = "", type = "box"} },

@params = new { images_background_color = "255,255,255", images_bin_border_color = "59,59,59", images_bin_fill_color = "230,230,230", images_item_border_color = "22,22,22", images_item_fill_color = "255,193,6", images_item_back_border_color = "22,22,22", images_sbs_last_item_fill_color = "177,14,14", images_sbs_last_item_border_color = "22,22,22", images_format = "svg", images_width = "50", images_height = "50", images_source = "file", stats = "0", item_coordinates = "1", images_complete = "1", images_sbs = "1", images_separated = "0", images_version = "2" } };

string json_str = JsonConvert.SerializeObject(request_data);

string queryParam = "query="+json_str;

byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(queryParam); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postBytes.Length;

System.IO.Stream postStream = req.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();

X509Certificate Cert = X509Certificate2.CreateFromCertFile("path_to_pem_key\global-api.3dbinpacking.com.pem"); req.ClientCertificates.Add(Cert);

using (System.Net.HttpWebResponse response = req.GetResponse() as System.Net.HttpWebResponse) { System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()); data = reader.ReadToEnd(); }

Param name Description Data type
username
(required)
Username. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
api_key
(required)
API key. You can find the API key in the '/Profile settings/API access' section after logging in https://www.3dbinpacking.com/en/customer/api-data string
[bins]
(required)
Array of packing spaces parameters array
[items]
(required)
Array of items parameters. Limit: maximum total number of items per request = 4999 array
params Array of extra request parameters array

[bins] - Packing spaces array details

Param name Description Data type
id
(required)
Packing space ID. The number or code you use to identify the packing space. string
w
(required)
Packing space width float
h
(required)
Packing space height float
d
(required)
Packing space depth/length float
wg The weight of the packing space integer or float
max_wg The maximum weight that this packing space can hold. Value set to '0' (zero) means there is no weight limit integer or float
type
Only with the images_version: 2 parameter
Specifies whether the image will be presented in the form of a box or a pallet translation missing: en.params_type_stringt

[items] - Items array details

Param name Description Data type Info
id
(required)
Item ID/SKU. The number or code you use to identify what is being packed. string
w
(required)
The width of the item integer or float
h
(required)
The height of the item integer or float
d
(required)
The depth or length of the item integer or float
wg The weight of the item integer or float
vr Vertical rotation. The information if the item can be rotated vertically. integer Vertical rotation. The information if the item can be rotated vertically.
item_colors_schema Define which kind of color schema should be used string
item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
item_border_color Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'

params - Optional parameters

Param name Description Data type Info
images_version Images generator version integer Available values: [1 | 2]
images_width Max. width of generated images integer Available values: 1 - 250
images_height Max. height of generated images integer Available values: 1 - 250
images_background_color Background color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_border_color
Only with the images_version: 1 parameter
Packing space border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_dashed_line_color
Only with the images_version: 1 parameter
Packing space front border color (dashed) string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_bin_fill_color Packing space fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_fill_color Item fill color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_item_border_color
Only with the images_version: 1 parameter
Item border color string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_fill_color Fill color of the last item on images showing a packing process 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_sbs_last_item_border_color
Only with the images_version: 1 parameter
Border color of the last item on images showing packing 'step-by-step' string Available values: RGB values of colors dots separated 'red,green,blue', allowed values 0-255; Example: '255,120,10'
images_format Images format string Available values: [ png , svg ]
images_sbs Generate images showing a packing process 'step-by-step' integer Available values:
0 [default] - means that images showing a packing process 'step-by-step' will not be generated,
1 - means that images showing a packing process 'step-by-step' will be generated
images_complete Generate images showing a final packing result integer Available values:
0 [default] - means that images showing final packing result will not be generated,
1 - means that images showing final packing result will be generated
images_separated Generate images showing the placement of each item separately integer Available values:
0 [default] - means that images showing the placement of each item separately will not be generated,
1 - means that images showing the placement of each item separately will be generated
item_coordinates Return coordinates (x, y, z) for each item integer Available values:
0 [default] - means that images showing the placement of each item separately will not be generated,
1 - means that images showing the placement of each item separately will be generated
stats Return the statistics of a packing process (e.g. images generation time) integer Available values:
0 [default] - means that the statistics of a packing process will not be returned,
1 - means that the statistics of a packing process will be returned

Response parameters

RESPONSE

{
    "response":{
        "id":"response_id",
        "bins_packed":[
            {
                "bin_data":{
                    "w":5,
                    "h":5,
                    "d":5,
                    "id":"Bin1",
                    "used_space":72,
                    "weight":0,
                    "gross_weight":0,
                    "used_weight":100,
                    "stack_height":5,
                    "order_id":null
                },
                "image_complete":"image_url.png",
                "items":[
                    {
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":5,"y2":3,"z2":2}
                    },{
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":0,"y1":0,"z1":2,"x2":5,"y2":3,"z2":4}
                    },{
                        "id":"Item1",
                        "w":5,
                        "h":3,
                        "d":2,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":0,"y1":3,"z1":0,"x2":5,"y2":5,"z2":3}
                    }
                ]
            },{
                "bin_data":{
                    "w":4,
                    "h":3,
                    "d":3,
                    "id":"Bin2",
                    "used_space":75,
                    "weight":0,
                    "gross_weight":0,
                    "used_weight":100,
                    "stack_height":3
                },
                "image_complete":"image_url.png",
                "items":[
                    {
                        "id":"Item2",
                        "w":3,
                        "h":3,
                        "d":3,
                        "wg":0,
                        "image_separated":"image_url.png",
                        "image_sbs":"image_url.png",
                        "coordinates":{"x1":0,"y1":0,"z1":0,"x2":3,"y2":3,"z2":3}
                    }
                ]
            }
        ],
        "errors":[],
        "status":1,
        "not_packed_items":[]
    }
}

Param name Description Data type Info
[bins_packed] List of packed items array
errors List of possible errors that may occur in request array Example: [{'level'}]; Possible returned values:'critical' - critical error - disabling packing, 'warning' - warning about incorrect data in request
status Response status integer Possible returned values:
1 - response hasn't included critical errors,
0 - response has included critical errors. * critical error - the error disabling packing. It could be caused by lack of one of the required parameters ('username','api_key') or incorrect value of parameter (eg. a field, which should contain number, contains string).
[not_packed_items] The list of item unable to be packed e.g. incorrect parameters input, excessive weight or size array

[bins_packed] - The list of packing spaces to be packed

Param name Description Data type
bin_data Details of the packing space to be packed array
image_complete Image of the packing space to be packed url
[items] Information about items to be packed in the packing space array

[bin_data] - Details of the packing space to be packed

Param name Description Data type
id Packing space ID. The number or code you use to identify the packing space. string
w Packing space width integer or float
h Packing space height integer or float
d Packing space depth/length integer or float
used_space Percentage of packing space utilized integer or float
weight Weight of items to be packed integer or float
gross_weight Weight of items to be packed + weight of packing space integer or float
used_weight Percentage of the permissible weight utilized integer or float
stack_height The height of stacked items integer or float

[items] - The list of items to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
wg The weight of the item integer or float
image_separated Image showing the position of each item url
image_sbs Images showing the packing process step-by-step url
coordinates Coordinates of items in the packing space {"x1":0,"y1":0,"z1":0,"x2":5,"y2":3,"z2":2}

[not_packed_items] - The list of items unable to be packed

Param name Description Data type
id Item ID/SKU. The number or code you use to identify what is being packed. string
w The width of the item integer or float
h The height of the item integer or float
d The depth or length of the item integer or float
q The amount of the same items to pack integer
wg The weight of the item integer or float

Graphics

Below are the differences between the images and a description of some requests parameters.

Differences between version 1 and 2 of the image generator.

The main difference between the images is the way the results are presented. In the first version, the view is presented in a dimetric way. The second version is presented in an isometric way.
Other differences are:

Images depending on the type of packing space

"bins":
    [
        {
            "id":"Pack M",
            "h":50,
            "w":120,
            "d":80,
            "wg":"",
            "max_wg":"",
            "q":null,
            "cost":0,
            "type":"pallet"
        },
        {
            "id":"Pack S",
            "h":3,
            "w":3,
            "d":6,
            "wg":"",
            "max_wg":"",
            "q":null,
            "cost":0
            "type":"box"
        }
    ],

In the 2nd version of images (images_version: "2") we can generate images showing the type of packing space we define.
There are 2 options available: [‘box’ | 'pallet’]. The default value is box. In this case, the image will show a cross-section of packing space together with packed items.
If the parameter is set to pallet, the pallet will be generated together with items stacked on it.
There is an example below showing the difference between the images.

Pallet image
type: "pallet"
Box image
type: "box"

Completely packed packing space

Images showing the final packing result

Complete
Complete

Step-by-step packing instructions

This graphic shows the packing process step-by-step. In each subsequent image, the previously packed items are marked with a different color than the item currently being packed.
Below the both versions of images are presented.

Step by step 1
Step 1
Step by step 2
Step 2
Step by step 3
Step 3
Step by step 4
Step 4

Items presented individually

In this case, the image shows a single item without showing the previously packed items.
Dashed lines presenting the position of an item in relation to the ground are used to help identify the position of the item in the packing space.

Separated 1
Separated 1
Separated 2
Separated 2
Separated 3
Separated 3
Separated 4
Separated 4

Scaling SVG images

Thanks to the SVG format, it is possible to scale them freely without losing their quality.
The following example shows the same image in different sizes.
The 1st has the minimum dimensions set to 200x200px and the max dims set to 400x400px.
The 2nd has the minimum dimensions set to 300x300px and the max dims set to 400x400px.

Step by step 3Min: 100x100px; Max: 200x200px;
<img src="path_to_image/image.svg" alt="Step by step 3" style="min-width: 100px; max-width: 200px; min-height: 100px; max-height: 200px;">
Step by step 3Min: 300x300px; Max: 400x400px;
<img src="path_to_image/image.svg" alt="Step by step 3" style="min-width: 300px; max-width: 400px; min-height: 300px; max-height: 400px;">

Images format

It is possible to generate images in SVG or PNG formats.
Thanks to the SVG format, the user can freely scale the images without losing their quality.

Errors

HTTP

Error Meaning
400 Bad Request - Your request is invalid.
404 Bad URL - Your request URL is invalid.
500 Server error.

API

List of pssible API errors

Error lever Message
TYPE_CRITICAL No bins to pack.
TYPE_CRITICAL Exceeded maximum number of items per request. Maximum number is 4999 or less
TYPE_CRITICAL No items to pack.
TYPE_CRITICAL Pallet cannot be packed. - z powodu np błędnie podanych wymiarów
TYPE_CRITICAL Request parameter "query" can not be empty.
TYPE_CRITICAL Request parameter "query" has to be in JSON format! Example: query={"username":"your_username",....}
TYPE_CRITICAL Request parameter "query" not set! Correct request content format: query={...}
TYPE_CRITICAL Required parameter "bins" not set!
TYPE_CRITICAL Required parameter "username" not set!
TYPE_CRITICAL Required parameter "api_key" not set!
TYPE_CRITICAL Unknown optimization_mode in the request params!
TYPE_CRITICAL Required parameter "items" not set!
TYPE_CRITICAL Requested "bins" parameter is not an array!
TYPE_CRITICAL Each "strategy" data in "bins_strategies" parameter must be an array!
TYPE_CRITICAL Requested "bins_strategies" parameter is not an array!
TYPE_CRITICAL Missing "bins" key in strategy data!
TYPE_CRITICAL Requested "bins" parameter is not an array!
TYPE_CRITICAL Requested "items" parameter is not an array!
TYPE_WARNING Bin 'bin_id' can't be packed. Exceeded maximum number of items per simulation. The maximum number is 4999.
TYPE_WARNING Bin 'bin_id' has incorrect dimension(s) and is not packed.
TYPE_WARNING Bin 'bin_id' has incorrect 'find' value and is not packed.
TYPE_WARNING Bin 'bin_id' has incorrect dimension(s) and is not packed.
TYPE_WARNING Item 'item_id' has incorrect dimensions.
TYPE_WARNING Item 'item_id' has incorrect quantity value.
TYPE_WARNING Item 'item_id' has incorrect dimensions.
TYPE_WARNING Item 'item_id' has incorrect quantity value.
TYPE_WARNING Too many items or bins.
TYPE_WARNING Reached the maximum (100) pallets number per request.
TYPE_WARNING Pallet has incorrect dimension(s) and is not packed.
TYPE_WARNING Wrong color definition for parameter "item_fill_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "image_border_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong images_width parameter. [10-250] allowed.
TYPE_WARNING Wrong images_height parameter. [10-250] allowed
TYPE_WARNING Wrong color definition for parameter "images_background_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_bin_border_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_bin_fill_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_item_border_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_item_fill_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_filler_border_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_filler_fill_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_item_back_border_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_dashed_line_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong color definition for parameter "images_bin_dashed_line_color". [0-255] values range allowed, with comma separation. Example: 255,255,255
TYPE_WARNING Wrong "images_source" parameter. [base64|file] allowed
TYPE_WARNING Wrong "images_format" parameter. [png|svg] allowed
TYPE_NOTICE Item 'item_id' can't be packed into bin 'bin_id'
TYPE_NOTICE Item 'item_id' can't be packed into any bin.
TYPE_NOTICE Item 'item_id' can't be packed into bin 'bin_id'.
TYPE_NOTICE Item 'item_id' can't be packed into any bin.
TYPE_NOTICE Parameters "item_fill_color" and "item_border_color" are required for item_colors_schema = "item"
TYPE_NOTICE Parameter "item_color_schema" - allowed values: [default|random|item]. Value "default" has been been used