Retrieves a list of EasyPost shipments
curl -X GET https://api.easypost.com/v2/shipments \
-u <YOUR_TEST/PRODUCTION_API_KEY>: \
-d 'page_size=2' \
-d 'start_datetime=2016-01-02T08:50:00Z'
var
rest: HCkRest;
success: Boolean;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
strResponseBody: PWideChar;
jsonResponse: HCkJsonObject;
has_more: Boolean;
i: Integer;
count_i: Integer;
batch_id: Boolean;
batch_message: Boolean;
batch_status: Boolean;
created_at: PWideChar;
customs_info: Boolean;
id: PWideChar;
insurance: Boolean;
is_return: Boolean;
mode: PWideChar;
object: PWideChar;
optionsCurrency: PWideChar;
optionsDate_advance: Integer;
optionsLabel_date: Boolean;
optionsLabel_format: PWideChar;
optionsSpecial_rates_eligibility: PWideChar;
postage_labelCreated_at: PWideChar;
postage_labelDate_advance: Integer;
postage_labelId: PWideChar;
postage_labelIntegrated_form: PWideChar;
postage_labelLabel_date: PWideChar;
postage_labelLabel_epl2_url: Boolean;
postage_labelLabel_file: Boolean;
postage_labelLabel_file_type: PWideChar;
postage_labelLabel_pdf_url: Boolean;
postage_labelLabel_resolution: Integer;
postage_labelLabel_size: PWideChar;
postage_labelLabel_type: PWideChar;
postage_labelLabel_url: PWideChar;
postage_labelLabel_zpl_url: PWideChar;
postage_labelObject: PWideChar;
postage_labelUpdated_at: PWideChar;
reference: Boolean;
refund_status: Boolean;
scan_form: Boolean;
status: PWideChar;
tracking_code: PWideChar;
updated_at: PWideChar;
usps_zone: Integer;
j: Integer;
count_j: Integer;
amount: PWideChar;
charged: Boolean;
refunded: Boolean;
type: PWideChar;
begin
rest := CkRest_Create();
// URL: https://api.easypost.com/v2/shipments
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>','');
CkRest_AddQueryParam(rest,'page_size','2');
CkRest_AddQueryParam(rest,'start_datetime','2016-01-02T08:50:00Z');
strResponseBody := CkRest__fullRequestFormUrlEncoded(rest,'GET','/v2/shipments');
if (CkRest_getLastMethodSuccess(rest) <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
jsonResponse := CkJsonObject_Create();
CkJsonObject_Load(jsonResponse,strResponseBody);
has_more := CkJsonObject_BoolOf(jsonResponse,'has_more');
i := 0;
count_i := CkJsonObject_SizeOfArray(jsonResponse,'shipments');
while i < count_i do
begin
CkJsonObject_putI(jsonResponse,i);
batch_id := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].batch_id');
batch_message := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].batch_message');
batch_status := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].batch_status');
created_at := CkJsonObject__stringOf(jsonResponse,'shipments[i].created_at');
customs_info := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].customs_info');
id := CkJsonObject__stringOf(jsonResponse,'shipments[i].id');
insurance := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].insurance');
is_return := CkJsonObject_BoolOf(jsonResponse,'shipments[i].is_return');
mode := CkJsonObject__stringOf(jsonResponse,'shipments[i].mode');
object := CkJsonObject__stringOf(jsonResponse,'shipments[i].object');
optionsCurrency := CkJsonObject__stringOf(jsonResponse,'shipments[i].options.currency');
optionsDate_advance := CkJsonObject_IntOf(jsonResponse,'shipments[i].options.date_advance');
optionsLabel_date := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].options.label_date');
optionsLabel_format := CkJsonObject__stringOf(jsonResponse,'shipments[i].options.label_format');
optionsSpecial_rates_eligibility := CkJsonObject__stringOf(jsonResponse,'shipments[i].options.special_rates_eligibility');
postage_labelCreated_at := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.created_at');
postage_labelDate_advance := CkJsonObject_IntOf(jsonResponse,'shipments[i].postage_label.date_advance');
postage_labelId := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.id');
postage_labelIntegrated_form := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.integrated_form');
postage_labelLabel_date := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.label_date');
postage_labelLabel_epl2_url := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].postage_label.label_epl2_url');
postage_labelLabel_file := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].postage_label.label_file');
postage_labelLabel_file_type := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.label_file_type');
postage_labelLabel_pdf_url := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].postage_label.label_pdf_url');
postage_labelLabel_resolution := CkJsonObject_IntOf(jsonResponse,'shipments[i].postage_label.label_resolution');
postage_labelLabel_size := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.label_size');
postage_labelLabel_type := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.label_type');
postage_labelLabel_url := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.label_url');
postage_labelLabel_zpl_url := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.label_zpl_url');
postage_labelObject := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.object');
postage_labelUpdated_at := CkJsonObject__stringOf(jsonResponse,'shipments[i].postage_label.updated_at');
reference := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].reference');
refund_status := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].refund_status');
scan_form := CkJsonObject_IsNullOf(jsonResponse,'shipments[i].scan_form');
status := CkJsonObject__stringOf(jsonResponse,'shipments[i].status');
tracking_code := CkJsonObject__stringOf(jsonResponse,'shipments[i].tracking_code');
updated_at := CkJsonObject__stringOf(jsonResponse,'shipments[i].updated_at');
usps_zone := CkJsonObject_IntOf(jsonResponse,'shipments[i].usps_zone');
j := 0;
count_j := CkJsonObject_SizeOfArray(jsonResponse,'shipments[i].fees');
while j < count_j do
begin
CkJsonObject_putJ(jsonResponse,j);
amount := CkJsonObject__stringOf(jsonResponse,'shipments[i].fees[j].amount');
charged := CkJsonObject_BoolOf(jsonResponse,'shipments[i].fees[j].charged');
object := CkJsonObject__stringOf(jsonResponse,'shipments[i].fees[j].object');
refunded := CkJsonObject_BoolOf(jsonResponse,'shipments[i].fees[j].refunded');
type := CkJsonObject__stringOf(jsonResponse,'shipments[i].fees[j].type');
j := j + 1;
end;
j := 0;
count_j := CkJsonObject_SizeOfArray(jsonResponse,'shipments[i].forms');
while j < count_j do
begin
CkJsonObject_putJ(jsonResponse,j);
j := j + 1;
end;
j := 0;
count_j := CkJsonObject_SizeOfArray(jsonResponse,'shipments[i].messages');
while j < count_j do
begin
CkJsonObject_putJ(jsonResponse,j);
j := j + 1;
end;
j := 0;
count_j := CkJsonObject_SizeOfArray(jsonResponse,'shipments[i].rates');
while j < count_j do
begin
CkJsonObject_putJ(jsonResponse,j);
j := j + 1;
end;
i := i + 1;
end;
CkRest_Dispose(rest);
CkJsonObject_Dispose(jsonResponse);
{
"has_more": true,
"shipments": [
{
"batch_id": null,
"batch_message": null,
"batch_status": null,
"buyer_address": {},
"created_at": "2016-11-28T20:03:25Z",
"customs_info": null,
"fees": [
{
"amount": "0.00000",
"charged": true,
"object": "Fee",
"refunded": false,
"type": "LabelFee"
},
{
"amount": "2.60000",
"charged": true,
"object": "Fee",
"refunded": false,
"type": "PostageFee"
}
],
"forms": [
],
"from_address": {},
"id": "shp_c0d6305d502b4532b8c507f2a8b3d5ae",
"insurance": null,
"is_return": false,
"messages": [
],
"mode": "production",
"object": "Shipment",
"options": {
"currency": "USD",
"date_advance": 0,
"label_date": null,
"label_format": "ZPL",
"special_rates_eligibility": "USPS.MEDIAMAIL"
},
"parcel": {},
"postage_label": {
"created_at": "2016-11-28T20:04:42Z",
"date_advance": 0,
"id": "pl_ec1a85e012364ad9844f55e173zd4a09",
"integrated_form": "none",
"label_date": "2016-11-28T20:04:42Z",
"label_epl2_url": null,
"label_file": null,
"label_file_type": "application/zpl",
"label_pdf_url": null,
"label_resolution": 203,
"label_size": "4x6",
"label_type": "default",
"label_url": "https://easypost-files.s3-us-west-2.amazonaws.com/files/postage_label/20161128/9zdb0ccd6009418fa12f93794f8177df.zpl",
"label_zpl_url": "https://easypost-files.s3-us-west-2.amazonaws.com/files/postage_label/20161128/9bdb0ccd6909418fa12f93794f8177df.zpl",
"object": "PostageLabel",
"updated_at": "2016-11-28T20:04:42Z"
},
"rates": [
{},
{}
],
"reference": null,
"refund_status": null,
"return_address": {},
"scan_form": null,
"selected_rate": {},
"status": "pre_transit",
"to_address": {},
"tracker": {},
"tracking_code": "9400110896700986051652",
"updated_at": "2016-11-29T03:25:18Z",
"usps_zone": 8
},
{
"id": "shp_c0d6306d502b4532b8c507f2a8b3d5fb"
}
]
}