> For the complete documentation index, see [llms.txt](https://apidocs.gsped.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.gsped.com/gsped-api-english-version/spedizioni-e-dintorni/shipmentslist.md).

# ShipmentsList

List of shipments

## ShipmentsList

This endpoint lets you get the list of shipments.

{% hint style="info" %}
Using the **previousPageUrl** and **nextPageUrl** URLs returned in the response is not mandatory, but it is recommended because it makes the call considerably faster.
{% endhint %}

## ShipmentsList

<mark style="color:blue;">`GET`</mark> `https://api.gsped.it/[INSTANCE]/ShipmentsList`

Retrieves a list of shipments

#### Query Parameters

| Name                                       | Type         | Description                                                                                                                                                                                                            |
| ------------------------------------------ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| data\_da<mark style="color:red;">\*</mark> | Y-m-d H:i:s  | selects if `date_created` >= data\_da                                                                                                                                                                                  |
| data\_a<mark style="color:red;">\*</mark>  | Y-m-d H:i:s  | selects if `date_created` < data\_a                                                                                                                                                                                    |
| corriere                                   | int \| array | selects if corriere IN \[id, id...]                                                                                                                                                                                    |
| servizio                                   | int \| array | selects if servizio IN \[id, id...]                                                                                                                                                                                    |
| cliente                                    | int \| array | selects if client\_id IN \[id, id...]                                                                                                                                                                                  |
| fatt\_cliente                              | int \| array | selects invoiced\_*client\_*&#x69;d IN \[id, id...]                                                                                                                                                                    |
| nazionale                                  | 1/0          | <p><strong>1</strong> selects if <code>rcpt\_country\_code</code> = <code>sender\_country\_code</code><br><strong>0</strong> selects if <code>rcpt\_country\_code</code> != <code>sender\_country\_code</code><br></p> |
| contrassegno                               | 1/0          | <p><strong>1</strong> selects if contrassegno > 0<br><strong>0</strong> selects if contrassegno <= 0</p>                                                                                                               |
| assicurazione                              | 1/0          | <p><strong>1</strong> selects if assicurazione > 0<br><strong>0</strong> selects if assicurazione <= 0 OR NULL</p>                                                                                                     |
| confermato                                 | 1/0          | <p><strong>1</strong> selects if confermato = 1<br><strong>0</strong> selects if confermato = 0</p>                                                                                                                    |
| documenti                                  | 1/0          | <p><strong>1</strong> selects if documenti = 1<br><strong>0</strong> selects if documenti = 0</p>                                                                                                                      |
| reso                                       | 1/0          | <p><strong>1</strong> selects return shipments<br><strong>0</strong> selects normal shipments</p>                                                                                                                      |
| tipo                                       | 1/0          | <p><strong>1</strong> selects shipments<br><strong>0</strong> selects pickups</p>                                                                                                                                      |
| perPage                                    | 1...200      | Number of items per page. Default: 200                                                                                                                                                                                 |
| page                                       | int          | Number of the requested page                                                                                                                                                                                           |
| order                                      | ASC\|DESC    | Sort direction. Default: DESC                                                                                                                                                                                          |
| orderBy                                    | string       | <p>Name of the field used to sort the results. Default: id</p><p>Possible values:</p><p>id,</p><p>corriere,</p><p>client\_id,</p><p>date\_created,</p><p>invoiced\_client\_id</p>                                      |
| status                                     | float        | Shipment status. Must be greater than or equal to zero                                                                                                                                                                 |

{% hint style="info" %}
Array parameters (corriere, servizio, cliente, fatt\_cliente) are passed by repeating the parameter name followed by square brackets, for example `?corriere[]=1&corriere[]=104`. For a single value, `?corriere=1` is enough.
{% endhint %}

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| x-api-key<mark style="color:red;">\*</mark> | String | Apikey provided by GSPED |

{% tabs %}
{% tab title="200: OK Shipments list" %}

```javascript
{
    "status": 200,
    "page": 1,
    "totPages": 3,
    "totEntries": 6,
    "entries": 2,
    "payload": [
        {...},
        {...},
    ],
    "previousPageUrl": null,
    "nextPageUrl": "http://apistaging.gsped.it/testbed/shipments?corriere%5B0%5D=1&corriere%5B1%5D=104&perPage=2&page=2&totEntries=6"
}
```

{% endtab %}

{% tab title="400: Bad Request Input error" %}

```javascript
{
    "status": 400,
    "error": "Testo descrittivo dell'errore"
}
```

{% endtab %}

{% tab title="403: Forbidden Invalid apikey" %}

```javascript
{
    "status": false,
    "error": "Invalid API key "
}
```

{% endtab %}
{% endtabs %}

### Example code snippets

{% tabs %}
{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/ShipmentsList",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "x-api-key: YOUR-API-KEY"
  ],
]);

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

curl_close($curl);

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

{% endtab %}

{% tab title="PYTHON" %}

```python
import http.client

conn = http.client.HTTPSConnection("api.gsped.it")

payload = ""

headers = { 'x-api-key': "YOUR-API-KEY" }

conn.request("GET", "/sandbox/ShipmentsList", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.gsped.it/sandbox/ShipmentsList"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-api-key", "YOUR-API-KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri("https://api.gsped.it/sandbox/ShipmentsList"),
    Headers =
    {
        { "x-api-key", "YOUR-API-KEY" },
    },
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
```

{% endtab %}

{% tab title="cURL" %}

```shell
curl --request GET \
  --url 'https://api.gsped.it/sandbox/ShipmentsList' \
  --header 'x-api-key: YOUR-API-KEY'
```

{% endtab %}
{% endtabs %}
