Skip to content

Latest commit

 

History

History
163 lines (110 loc) · 6.93 KB

File metadata and controls

163 lines (110 loc) · 6.93 KB

Parcels

(parcels)

Overview

A parcel is an item you are shipping. The parcel object includes details about its physical make-up of the parcel. It includes dimensions and weight that Shippo uses to calculate rates.

Parcel Extras

The following values are supported for the extra field of the parcel object.

Available Operations

  • list - List all parcels
  • create - Create a new parcel
  • get - Retrieve an existing parcel

list

Returns a list of all parcel objects.

Example Usage

from shippo import Shippo


with Shippo(
    api_key_header="<YOUR_API_KEY_HERE>",
    shippo_api_version="2018-02-08",
) as s_client:

    res = s_client.parcels.list()

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
page Optional[int] The page number you want to select
results Optional[int] The number of results to return per page (max 100)
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.ParcelPaginatedList

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

create

Creates a new parcel object.

Example Usage

from shippo import Shippo
from shippo.models import components


with Shippo(
    api_key_header="<YOUR_API_KEY_HERE>",
    shippo_api_version="2018-02-08",
) as s_client:

    res = s_client.parcels.create(request={
        "mass_unit": components.WeightUnitEnum.LB,
        "weight": "1",
        "distance_unit": components.DistanceUnitEnum.IN,
        "height": "1",
        "length": "1",
        "width": "1",
        "extra": {
            "cod": {
                "amount": "5.5",
                "currency": "USD",
                "payment_method": components.PaymentMethod.CASH,
            },
            "insurance": {
                "amount": "5.5",
                "content": "Laptop",
                "currency": "USD",
                "provider": components.ParcelInsuranceProvider.UPS,
            },
        },
        "metadata": "Customer ID 123456",
    })

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request operations.CreateParcelRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.Parcel

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

get

Returns parcel details using an existing parcel object ID (this will not return parcel details associated with un-purchased shipment/rate parcel object IDs).

Example Usage

from shippo import Shippo


with Shippo(
    api_key_header="<YOUR_API_KEY_HERE>",
    shippo_api_version="2018-02-08",
) as s_client:

    res = s_client.parcels.get(parcel_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
parcel_id str ✔️ Object ID of the parcel
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.Parcel

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*