Answer the question
In order to leave comments, you need to log in
Does dhl have api to calculate shipping cost?
Tell me if dhl has api for calculating shipping costs. And if so, can you provide links to examples. Didn't find anything on google.
Answer the question
In order to leave comments, you need to log in
Here it is:
https://docs.postmen.com/dhl.html
$url = 'https://sandbox-api.postmen.com/v3/rates';
$method = 'POST';
$headers = array(
"content-type: application/json",
"postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e"
);
$body = '{"async":false,"shipper_accounts":[{"id":"00000000-0000-0000-0000-000000000000"}],"shipment":{"parcels":[{"description":"Food XS","box_type":"custom","weight":{"value":2,"unit":"kg"},"dimension":{"width":20,"height":40,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"JPN","quantity":2,"price":{"amount":3,"currency":"JPY"},"weight":{"value":0.6,"unit":"kg"},"sku":"PS4-2015"}]}],"ship_from":{"contact_name":"Yin Ting Wong","street1":"Flat A, 29/F, Block 17\nLaguna Verde","city":"Hung Hom","state":"Kowloon","country":"HKG","phone":"96679797","email":"[email protected]","type":"residential"},"ship_to":{"contact_name":"Mike Carunchia","street1":"9504 W Smith ST","city":"Yorktown","state":"Indiana","postal_code":"47396","country":"USA","phone":"7657168649","email":"[email protected]","type":"residential"}}}';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $body
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
"meta": {
"code": 200,
"message": "OK",
"details": []
},
"data": {
"created_at": "2015-09-09T07:49:54.060Z",
"id": "ad1f9340-608d-4a30-be0e-b0a62e07e4cc",
"updated_at": "2015-09-09T07:49:57.360Z",
"status": "calculated",
"rates": [
{
"charge_weight": {
"value": 1.5,
"unit": "kg"
},
"total_charge": {
"amount": 429.57,
"currency": "HKD"
},
"shipper_account": {
"id": "00000000-0000-0000-0000-000000000000",
"slug": "dhl",
"description": "DHL Sandbox"
},
"service_type": "dhl_express_worldwide",
"service_name": "dhl_express_worldwide",
"pickup_deadline": "2015-09-01T18:00:00+00:00",
"booking_cut_off": "2015-09-01T17:00:00+00:00",
"delivery_date": "2015-09-01T23:00:00+00:00",
"transit_time": 1,
"detailed_charges": [
{
"type": "base",
"charge": {
"amount": 387,
"currency": "HKD"
}
},
{
"type": "fuel_surcharge",
"charge": {
"amount": 42.57,
"currency": "HKD"
}
}
],
"error_message": null,
"info_message": null
},
{
"charge_weight": {
"value": 1.5,
"unit": "kg"
},
"total_charge": {
"amount": 528,
"currency": "HKD"
},
"shipper_account": {
"id": "00000000-0000-0000-0000-000000000000",
"slug": "dhl",
"description": "DHL Sandbox"
},
"service_type": "dhl_express_easy",
"service_name": "dhl_express_easy",
"pickup_deadline": "2015-09-01T18:00:00+00:00",
"booking_cut_off": "2015-09-01T17:00:00+00:00",
"delivery_date": "2015-09-01T23:00:00+00:00",
"transit_time": 1,
"detailed_charges": [
{
"type": "base",
"charge": {
"amount": 528,
"currency": "HKD"
}
}
],
"error_message": null,
"info_message": null
}
]
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question