Retrieves an EasyPost shipment
curl -X GET https://api.easypost.com/v2/shipments/shp_... \
-u <YOUR_TEST/PRODUCTION_API_KEY>:
var
rest: HCkRest;
success: Boolean;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
sbResponseBody: HCkStringBuilder;
jsonResponse: HCkJsonObject;
id: PWideChar;
object: PWideChar;
mode: PWideChar;
to_addressId: PWideChar;
to_addressObject: PWideChar;
to_addressName: PWideChar;
to_addressCompany: Boolean;
to_addressStreet1: PWideChar;
to_addressStreet2: Boolean;
to_addressCity: PWideChar;
to_addressState: PWideChar;
to_addressZip: PWideChar;
to_addressCountry: PWideChar;
to_addressPhone: PWideChar;
to_addressMode: PWideChar;
to_addressCarrier_facility: Boolean;
to_addressResidential: Boolean;
to_addressEmail: PWideChar;
to_addressCreated_at: PWideChar;
to_addressUpdated_at: PWideChar;
from_addressId: PWideChar;
from_addressObject: PWideChar;
from_addressName: PWideChar;
from_addressCompany: Boolean;
from_addressStreet1: PWideChar;
from_addressStreet2: PWideChar;
from_addressCity: PWideChar;
from_addressState: PWideChar;
from_addressZip: PWideChar;
from_addressCountry: PWideChar;
from_addressPhone: PWideChar;
from_addressEmail: PWideChar;
from_addressMode: PWideChar;
from_addressCarrier_facility: Boolean;
from_addressResidential: Boolean;
from_addressCreated_at: PWideChar;
from_addressUpdated_at: PWideChar;
parcelId: PWideChar;
parcelObject: PWideChar;
parcelLength: Integer;
parcelWidth: Integer;
parcelHeight: Integer;
parcelPredefined_package: Boolean;
parcelWeight: Integer;
parcelCreated_at: PWideChar;
parcelUpdated_at: PWideChar;
customs_infoId: PWideChar;
customs_infoObject: PWideChar;
customs_infoCreated_at: PWideChar;
customs_infoUpdated_at: PWideChar;
customs_infoContents_explanation: Boolean;
customs_infoContents_type: PWideChar;
customs_infoCustoms_certify: Boolean;
customs_infoCustoms_signer: Boolean;
customs_infoEel_pfc: Boolean;
customs_infoNon_delivery_option: PWideChar;
customs_infoRestriction_comments: Boolean;
customs_infoRestriction_type: PWideChar;
scan_form: Boolean;
selected_rate: Boolean;
postage_label: Boolean;
tracking_code: Boolean;
refund_status: Boolean;
insurance: Boolean;
created_at: PWideChar;
updated_at: PWideChar;
i: Integer;
count_i: Integer;
description: PWideChar;
hs_tariff_number: PWideChar;
origin_country: PWideChar;
quantity: Integer;
value: Integer;
weight: Integer;
carrier_account_id: PWideChar;
service: PWideChar;
rate: PWideChar;
carrier: PWideChar;
shipment_id: PWideChar;
delivery_days: Integer;
delivery_date: PWideChar;
delivery_date_guaranteed: Boolean;
begin
rest := CkRest_Create();
// URL: https://api.easypost.com/v2/shipments/shp_...
bTls := True;
port := 443;
bAutoReconnect := True;
success := CkRest_Connect(rest,'api.easypost.com',port,bTls,bAutoReconnect);
if (success <> True) then
begin
Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
CkRest_SetAuthBasic(rest,'<YOUR_TEST/PRODUCTION_API_KEY>','');
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/v2/shipments/shp_...',sbResponseBody);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
jsonResponse := CkJsonObject_Create();
CkJsonObject_LoadSb(jsonResponse,sbResponseBody);
id := CkJsonObject__stringOf(jsonResponse,'id');
object := CkJsonObject__stringOf(jsonResponse,'object');
mode := CkJsonObject__stringOf(jsonResponse,'mode');
to_addressId := CkJsonObject__stringOf(jsonResponse,'to_address.id');
to_addressObject := CkJsonObject__stringOf(jsonResponse,'to_address.object');
to_addressName := CkJsonObject__stringOf(jsonResponse,'to_address.name');
to_addressCompany := CkJsonObject_IsNullOf(jsonResponse,'to_address.company');
to_addressStreet1 := CkJsonObject__stringOf(jsonResponse,'to_address.street1');
to_addressStreet2 := CkJsonObject_IsNullOf(jsonResponse,'to_address.street2');
to_addressCity := CkJsonObject__stringOf(jsonResponse,'to_address.city');
to_addressState := CkJsonObject__stringOf(jsonResponse,'to_address.state');
to_addressZip := CkJsonObject__stringOf(jsonResponse,'to_address.zip');
to_addressCountry := CkJsonObject__stringOf(jsonResponse,'to_address.country');
to_addressPhone := CkJsonObject__stringOf(jsonResponse,'to_address.phone');
to_addressMode := CkJsonObject__stringOf(jsonResponse,'to_address.mode');
to_addressCarrier_facility := CkJsonObject_IsNullOf(jsonResponse,'to_address.carrier_facility');
to_addressResidential := CkJsonObject_IsNullOf(jsonResponse,'to_address.residential');
to_addressEmail := CkJsonObject__stringOf(jsonResponse,'to_address.email');
to_addressCreated_at := CkJsonObject__stringOf(jsonResponse,'to_address.created_at');
to_addressUpdated_at := CkJsonObject__stringOf(jsonResponse,'to_address.updated_at');
from_addressId := CkJsonObject__stringOf(jsonResponse,'from_address.id');
from_addressObject := CkJsonObject__stringOf(jsonResponse,'from_address.object');
from_addressName := CkJsonObject__stringOf(jsonResponse,'from_address.name');
from_addressCompany := CkJsonObject_IsNullOf(jsonResponse,'from_address.company');
from_addressStreet1 := CkJsonObject__stringOf(jsonResponse,'from_address.street1');
from_addressStreet2 := CkJsonObject__stringOf(jsonResponse,'from_address.street2');
from_addressCity := CkJsonObject__stringOf(jsonResponse,'from_address.city');
from_addressState := CkJsonObject__stringOf(jsonResponse,'from_address.state');
from_addressZip := CkJsonObject__stringOf(jsonResponse,'from_address.zip');
from_addressCountry := CkJsonObject__stringOf(jsonResponse,'from_address.country');
from_addressPhone := CkJsonObject__stringOf(jsonResponse,'from_address.phone');
from_addressEmail := CkJsonObject__stringOf(jsonResponse,'from_address.email');
from_addressMode := CkJsonObject__stringOf(jsonResponse,'from_address.mode');
from_addressCarrier_facility := CkJsonObject_IsNullOf(jsonResponse,'from_address.carrier_facility');
from_addressResidential := CkJsonObject_IsNullOf(jsonResponse,'from_address.residential');
from_addressCreated_at := CkJsonObject__stringOf(jsonResponse,'from_address.created_at');
from_addressUpdated_at := CkJsonObject__stringOf(jsonResponse,'from_address.updated_at');
parcelId := CkJsonObject__stringOf(jsonResponse,'parcel.id');
parcelObject := CkJsonObject__stringOf(jsonResponse,'parcel.object');
parcelLength := CkJsonObject_IntOf(jsonResponse,'parcel.length');
parcelWidth := CkJsonObject_IntOf(jsonResponse,'parcel.width');
parcelHeight := CkJsonObject_IntOf(jsonResponse,'parcel.height');
parcelPredefined_package := CkJsonObject_IsNullOf(jsonResponse,'parcel.predefined_package');
parcelWeight := CkJsonObject_IntOf(jsonResponse,'parcel.weight');
parcelCreated_at := CkJsonObject__stringOf(jsonResponse,'parcel.created_at');
parcelUpdated_at := CkJsonObject__stringOf(jsonResponse,'parcel.updated_at');
customs_infoId := CkJsonObject__stringOf(jsonResponse,'customs_info.id');
customs_infoObject := CkJsonObject__stringOf(jsonResponse,'customs_info.object');
customs_infoCreated_at := CkJsonObject__stringOf(jsonResponse,'customs_info.created_at');
customs_infoUpdated_at := CkJsonObject__stringOf(jsonResponse,'customs_info.updated_at');
customs_infoContents_explanation := CkJsonObject_IsNullOf(jsonResponse,'customs_info.contents_explanation');
customs_infoContents_type := CkJsonObject__stringOf(jsonResponse,'customs_info.contents_type');
customs_infoCustoms_certify := CkJsonObject_BoolOf(jsonResponse,'customs_info.customs_certify');
customs_infoCustoms_signer := CkJsonObject_IsNullOf(jsonResponse,'customs_info.customs_signer');
customs_infoEel_pfc := CkJsonObject_IsNullOf(jsonResponse,'customs_info.eel_pfc');
customs_infoNon_delivery_option := CkJsonObject__stringOf(jsonResponse,'customs_info.non_delivery_option');
customs_infoRestriction_comments := CkJsonObject_IsNullOf(jsonResponse,'customs_info.restriction_comments');
customs_infoRestriction_type := CkJsonObject__stringOf(jsonResponse,'customs_info.restriction_type');
scan_form := CkJsonObject_IsNullOf(jsonResponse,'scan_form');
selected_rate := CkJsonObject_IsNullOf(jsonResponse,'selected_rate');
postage_label := CkJsonObject_IsNullOf(jsonResponse,'postage_label');
tracking_code := CkJsonObject_IsNullOf(jsonResponse,'tracking_code');
refund_status := CkJsonObject_IsNullOf(jsonResponse,'refund_status');
insurance := CkJsonObject_IsNullOf(jsonResponse,'insurance');
created_at := CkJsonObject__stringOf(jsonResponse,'created_at');
updated_at := CkJsonObject__stringOf(jsonResponse,'updated_at');
i := 0;
count_i := CkJsonObject_SizeOfArray(jsonResponse,'customs_info.customs_items');
while i < count_i do
begin
CkJsonObject_putI(jsonResponse,i);
id := CkJsonObject__stringOf(jsonResponse,'customs_info.customs_items[i].id');
object := CkJsonObject__stringOf(jsonResponse,'customs_info.customs_items[i].object');
description := CkJsonObject__stringOf(jsonResponse,'customs_info.customs_items[i].description');
hs_tariff_number := CkJsonObject__stringOf(jsonResponse,'customs_info.customs_items[i].hs_tariff_number');
origin_country := CkJsonObject__stringOf(jsonResponse,'customs_info.customs_items[i].origin_country');
quantity := CkJsonObject_IntOf(jsonResponse,'customs_info.customs_items[i].quantity');
value := CkJsonObject_IntOf(jsonResponse,'customs_info.customs_items[i].value');
weight := CkJsonObject_IntOf(jsonResponse,'customs_info.customs_items[i].weight');
created_at := CkJsonObject__stringOf(jsonResponse,'customs_info.customs_items[i].created_at');
updated_at := CkJsonObject__stringOf(jsonResponse,'customs_info.customs_items[i].updated_at');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jsonResponse,'rates');
while i < count_i do
begin
CkJsonObject_putI(jsonResponse,i);
id := CkJsonObject__stringOf(jsonResponse,'rates[i].id');
object := CkJsonObject__stringOf(jsonResponse,'rates[i].object');
carrier_account_id := CkJsonObject__stringOf(jsonResponse,'rates[i].carrier_account_id');
service := CkJsonObject__stringOf(jsonResponse,'rates[i].service');
rate := CkJsonObject__stringOf(jsonResponse,'rates[i].rate');
carrier := CkJsonObject__stringOf(jsonResponse,'rates[i].carrier');
shipment_id := CkJsonObject__stringOf(jsonResponse,'rates[i].shipment_id');
delivery_days := CkJsonObject_IntOf(jsonResponse,'rates[i].delivery_days');
delivery_date := CkJsonObject__stringOf(jsonResponse,'rates[i].delivery_date');
delivery_date_guaranteed := CkJsonObject_BoolOf(jsonResponse,'rates[i].delivery_date_guaranteed');
created_at := CkJsonObject__stringOf(jsonResponse,'rates[i].created_at');
updated_at := CkJsonObject__stringOf(jsonResponse,'rates[i].updated_at');
i := i + 1;
end;
CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jsonResponse);
{
"id": "shp_vN9h7XLn",
"object": "Shipment",
"mode": "test",
"to_address": {
"id": "adr_zMlCRtmt",
"object": "Address",
"name": "Dr. Steve Brule",
"company": null,
"street1": "179 N Harbor Dr",
"street2": null,
"city": "Redondo Beach",
"state": "CA",
"zip": "90277",
"country": "US",
"phone": "4153334444",
"mode": "test",
"carrier_facility": null,
"residential": null,
"email": "dr_steve_brule@gmail.com",
"created_at": "2013-04-22T05:39:56Z",
"updated_at": "2013-04-22T05:39:56Z"
},
"from_address": {
"id": "adr_VgoLT6Ex",
"object": "Address",
"name": "EasyPost",
"company": null,
"street1": "417 Montgomery Street",
"street2": "5th Floor",
"city": "San Francisco",
"state": "CA",
"zip": "94104",
"country": "US",
"phone": "4153334444",
"email": "support@easypost.com",
"mode": "test",
"carrier_facility": null,
"residential": null,
"created_at": "2013-04-22T05:39:57Z",
"updated_at": "2013-04-22T05:39:57Z"
},
"parcel": {
"id": "prcl_SI55pjx8",
"object": "Parcel",
"length": 20.2,
"width": 10.9,
"height": 5.0,
"predefined_package": null,
"weight": 140.8,
"created_at": "2013-04-22T05:39:57Z",
"updated_at": "2013-04-22T05:39:57Z"
},
"customs_info": {
"id": "cstinfo_iNAizey5",
"object": "CustomsInfo",
"created_at": "2013-04-22T05:39:57Z",
"updated_at": "2013-04-22T05:39:57Z",
"contents_explanation": null,
"contents_type": "merchandise",
"customs_certify": false,
"customs_signer": null,
"eel_pfc": null,
"non_delivery_option": "return",
"restriction_comments": null,
"restriction_type": "none",
"customs_items": [
{
"id": "cstitem_9eDIbaDR",
"object": "CustomsItem",
"description": "Many, many EasyPost stickers.",
"hs_tariff_number": "123456",
"origin_country": "US",
"quantity": 1,
"value": 879,
"weight": 140,
"created_at": "2013-04-22T05:39:57Z",
"updated_at": "2013-04-22T05:39:57Z"
}
]
},
"rates": [
{
"id": "rate_nyCb6ubX",
"object": "Rate",
"carrier_account_id": "ca_12345678",
"service": "FirstClassPackageInternationalService",
"rate": "9.50",
"carrier": "USPS",
"shipment_id": "shp_vN9h7XLn",
"delivery_days": 4,
"delivery_date": "2013-04-26T05:40:57Z",
"delivery_date_guaranteed": false,
"created_at": "2013-04-22T05:40:57Z",
"updated_at": "2013-04-22T05:40:57Z"
},
{
"id": "rate_uJh8iO2n",
"object": "Rate",
"carrier_account_id": "ca_12345678",
"service": "PriorityMailInternational",
"rate": "27.40",
"carrier": "USPS",
"shipment_id": "shp_vN9h7XLn",
"delivery_days": 2,
"delivery_date": "2013-04-24T05:40:57Z",
"delivery_date_guaranteed": false,
"created_at": "2013-04-22T05:40:57Z",
"updated_at": "2013-04-22T05:40:57Z"
},
{
"id": "rate_oZqapNpE",
"object": "Rate",
"carrier_account_id": "ca_12345678",
"service": "ExpressMailInternational",
"rate": "35.48",
"carrier": "USPS",
"shipment_id": "shp_vN9h7XLn",
"delivery_days": 1,
"delivery_date": "2013-04-23T05:40:57Z",
"delivery_date_guaranteed": true,
"created_at": "2013-04-22T05:40:57Z",
"updated_at": "2013-04-22T05:40:57Z"
}
],
"scan_form": null,
"selected_rate": null,
"postage_label": null,
"tracking_code": null,
"refund_status": null,
"insurance": null,
"created_at": "2013-04-22T05:40:57Z",
"updated_at": "2013-04-22T05:40:57Z"
}