Retrieving your orders

To receive a overview of your orders, you can send a GET request to /api/orders. Your response will look something like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
  "count": 2,
  "orders": [
    {
      "id": 1234567,
      "number": "DDB123457",
      "status": "cancelled",
      "date": "2017-08-24T11:08:19+02:00",
      "uuid": "347f6e49-952e-48ec-a49b-8bf528222012"
    },
    {
      "id": 7654321,
      "number": "PBB7654321",
      "status": "in-progress",
      "date": "2017-03-14T16:17:21+01:00",
      "uuid": "66150572-e513-4284-bec2-9d87060ab894"
    }
  ]
}

The id field can be used to retrieve more information about an order. You can do this by sending a GET request to /api/orders/{id}.

By default, you will get max. 50 results back. This can be used to create a paginated overview. If you want less results, you can add the parameter limit to your query string. Keep in mind that the maximum results is 50. You should store some data on your side to prevent retrieving all order information each time you need the overview.

For the paginated overview, you can also use the parameter offset to specify the orders that you want to see on the page. E.g., for page 1, you send the offset with the value 0 (or you omit this parameter),for page 2, you send 50, for page 3 100, etc. Finally you will receive an empty result set so you know you have reached the end.

The status parameter can be used to filter to show only a specific status. All available statusses can be found on the order status page.

Example request for retrieving orders

The following PHP code can be used for retrieve order information. Make sure you replace the values YOUR_USER_ID_HERE and YOUR_SECRET_HERE with the User-ID and secret you received on the API-credentials page, and{orderId} with the corresponding orderId or orderUuid.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.printdeal.com/api/orders",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
        "User-ID: YOUR_USER_ID_HERE",
        "API-Secret: YOUR_SECRET_HERE",
        "Accept: application/vnd.printdeal-api.v2"
    )
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}