to integrate our capabilities into your site.
Using our API, you can on your website:
- issue receipts (TTN) and get their number back;
- receive tracking (movement) of cargo on receipt;
- to recognize full info on the already established receipts;
- produce a calculation of the cost of sending the goods;
- display reference information for the cities in which Deliveri works, and the warehouses that are there.
To implement everything that is written in the section for owners, you can download the documentation (button below) and get acquainted with the methods.
If for work you only need reference information (lists of cities, warehouses, etc.), then methods can use right now, without any preliminary preparation. For everything else, you need registration on Deliveri's website.
Important! Some functions in the documentation are marked as "Method requires authorization", and some "Method requires authorization via API". For the second case, you need to generate the API keys (the button below), and for the first one - to simply authorize the methods available in the documentation.
Note that the functions for working with receipts require keys, so it's better not to postpone this issue for a long time.
var apiKey = 'CDBFE2D5-BF02-4C0D-B7D6-5CF277761C50';
var apiSecretKey = '6c131f01b99dfac3529d0cd68b1d6649';
var getHMAC = function (key, timestamp) {
var hash = CryptoJS.HmacSHA1(key + timestamp, apiSecretKey);
return hash.toString();
};
var data = {
"culture": "ru-RU",
"flSave": "false",
"debugMode": "true",
"receiptsList": [
{
"senderid": "CDBFE2D5-BF02-4C0D-B7D6-5CF277761C50",
"areasSendId": "4577d856-322b-e311-8b0d-00155d037960",
"areasResiveId": "16617df3-a42a-e311-8b0d-00155d037960",
"warehouseSendId": "5f2af375-5d70-e211-9ce1-00155d012a15",
"warehouseResiveId": "bdff546c-cb16-e211-89ed-00155d053b5d",
"dateSend": "2018-02-20T00:00:00",
"deliveryScheme": 0,
"posibleResiverReceipt_1": "ee5df311-6565-44d5-84f6-14875aa3e208",
"posibleResiverReceipt_2": "",
"posibleResiverReceipt_3": "",
"posibleResiverReceipt_4": "",
"currency": 100000000,
"InsuranceValue": 5000,
"payerInsuranceId": "1aa70d22-1209-e511-b3b5-000d3a200160",
"payerType": 1,
"paymentType": 0,
"paymentTypeInsuranse": 0,
"deliveryAddressId": "",
"deliveryContactName": "",
"deliveryContactPhone": "",
"DeliveryComment": "",
"ReturnDocuments": false,
"climbingToFloor": 0,
"CustomsCost": 0,
"CustomsCurrency": 100000000,
"CustomsDocuments": false,
"CustomsDescriptions": "",
"cashOnDeliveryType": 2,
"CashOnDeliveryValuta": 100000000,
"CashOnDeliveryValue": 5000,
"CashOnDeliveryCardId": "",
"CashOnDeliveryWarehouseId": "5f2af375-5d70-e211-9ce1-00155d012a15",
"CashOnDeliverySenderFullName": "Семёнов Семён Семёнович",
"CashOnDeliverySenderPhone": "0958888888",
"CashOnDeliveryRasschSchetId": "",
"CashOnDeliveryReceiverFullName": "Петров Пётр Петрович",
"CashOnDeliveryReceiverPhone": "0671234567",
"parentNumber": "",
"CashOnDeliveryDescription": "Описание",
"CashOnDeliveryPayerAccountId": "ee5df311-6565-44d5-84f6-14875aa3e208",
"pickUpDate": "",
"pickUpContactName": "",
"pickUpContactPhone": "",
"pickUpAddressId": "",
"descentFromFloor": 0,
"category": [
{
"categoryId": "00000000-0000-0000-0000-000000000000",
"cargoCategoryId": "f506d03b-9e36-e311-8b0d-00155d037960",
"countPlace": 1,
"helf": 1,
"size": 0.3,
"isEconom": false,
"PartnerNumber": "\"\""
}
]
}
]
};
$.ajax({
url: 'https://www.delivery-auto.com/api/v4/Public/PostCreateReceipts',
type: "POST",
data: data,
dataType: 'json',
beforeSend: function (request) {
request.setRequestHeader('HMACAuthorization', 'amx ' + apiKey + ':' + timestamp + ':' + getHMAC(apiKey, timestamp));
},
success: function (data) {
debugger;
if (data.status == true) {
debugger;
}
},
error: alert('error');
});
public string getHMAC(string publicKey, TimeSpan timestamp, string secretKey) {
string message = publicKey + timestamp.Milliseconds.ToString();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
HMACSHA1 hmacsha1 = new HMACSHA1(encoding.GetBytes(secretKey));
byte[] hashmessage = hmacsha1.ComputeHash(encoding.GetBytes(message));
return ByteToString(hashmessage);
}
public static string ByteToString(byte[] buff)
{
string sbinary = "";
for (int i = 0; i < buff.Length; i++)
{
sbinary += buff[i].ToString("X2"); // hex format
}
return (sbinary);
}
public ActionResult TestJSApi()
{
string dataString = @"{
"culture": "ru-RU",
"flSave": "false",
"debugMode": "true",
"receiptsList": [
{
"senderid": "CDBFE2D5-BF02-4C0D-B7D6-5CF277761C50",
"areasSendId": "4577d856-322b-e311-8b0d-00155d037960",
"areasResiveId": "16617df3-a42a-e311-8b0d-00155d037960",
"warehouseSendId": "5f2af375-5d70-e211-9ce1-00155d012a15",
"warehouseResiveId": "bdff546c-cb16-e211-89ed-00155d053b5d",
"dateSend": "2018-02-20T00:00:00",
"deliveryScheme": 0,
"posibleResiverReceipt_1": "ee5df311-6565-44d5-84f6-14875aa3e208",
"posibleResiverReceipt_2": "",
"posibleResiverReceipt_3": "",
"posibleResiverReceipt_4": "",
"currency": 100000000,
"InsuranceValue": 5000,
"payerInsuranceId": "1aa70d22-1209-e511-b3b5-000d3a200160",
"payerType": 1,
"paymentType": 0,
"paymentTypeInsuranse": 0,
"deliveryAddressId": "",
"deliveryContactName": "",
"deliveryContactPhone": "",
"DeliveryComment": "",
"ReturnDocuments": false,
"climbingToFloor": 0,
"CustomsCost": 0,
"CustomsCurrency": 100000000,
"CustomsDocuments": false,
"CustomsDescriptions": "",
"cashOnDeliveryType": 2,
"CashOnDeliveryValuta": 100000000,
"CashOnDeliveryValue": 5000,
"CashOnDeliveryCardId": "",
"CashOnDeliveryWarehouseId": "5f2af375-5d70-e211-9ce1-00155d012a15",
"CashOnDeliverySenderFullName": "Семёнов Семён Семёнович",
"CashOnDeliverySenderPhone": "0958888888",
"CashOnDeliveryRasschSchetId": "",
"CashOnDeliveryReceiverFullName": "Петров Пётр Петрович",
"CashOnDeliveryReceiverPhone": "0671234567",
"parentNumber": "",
"CashOnDeliveryDescription": "Описание",
"CashOnDeliveryPayerAccountId": "ee5df311-6565-44d5-84f6-14875aa3e208",
"pickUpDate": "",
"pickUpContactName": "",
"pickUpContactPhone": "",
"pickUpAddressId": "",
"descentFromFloor": 0,
"category": [
{
"categoryId": "00000000-0000-0000-0000-000000000000",
"cargoCategoryId": "f506d03b-9e36-e311-8b0d-00155d037960",
"countPlace": 1,
"helf": 1,
"size": 0.3,
"isEconom": false,
"PartnerNumber": "\"\""
}
]
}
]
}";
var apiKey = "CDBFE2D5-BF02-4C0D-B7D6-5CF277761C50";
var apiSecretKey = "6c131f01b99dfac3529d0cd68b1d6649";
DateTime myDate1 = new DateTime(1970, 1, 9, 0, 0, 00);
DateTime myDate2 = DateTime.Now;
var timestamp = myDate2.Subtract(myDate1);
var HMAC = getHMAC(apiKey, timestamp, apiSecretKey);
var request = (HttpWebRequest)WebRequest.Create("https://www.delivery-auto.com/api/v4/Public/PostCreateReceipts");
var data = System.Text.Encoding.UTF8.GetBytes(dataString);
request.Method = "POST";
request.ContentType = "text/json";
request.ContentLength = data.Length;
request.Headers["HMACAuthorization"] = string.Format("amx {0}:{1}:{2}", apiKey, timestamp.Milliseconds.ToString(), HMAC);
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
/*Приклад взаємодії з Delivery API (PHP) by SNENKO web development*/
class DeliveyAutoApi
{
protected $public_key;
protected $secret_key;
public $culture = 'ru-RU';//en-US, ru-RU, uk-UA
function __construct($culture = '', $public_key = '', $secret_key = '')
{
if (!empty($culture)):
$this->culture = $culture;
endif;
if (!empty($public_key)):
$this->public_key = 'your_key';
endif;
if (!empty($secret_key)):
$this->secret_key = "your_key";
endif;
}
function send($part) //you custom params here
{
$url = 'https://www.delivery-auto.com/api/v4/Public/PostReceiptCalculate';
$data = array(
'culture' => $this->culture,
'areasSendId' => $part['city_sender'],
'areasResiveId' => $part['city_incoming'],
'warehouseSendId' => $part['warehouse_sender'],
'warehouseResiveId' => $part['warehouse_incoming'],
'InsuranceValue' => 1000000,
'CashOnDeliveryValue' => 5000,
'dateSend' => $part['sending_date'],
'deliveryScheme' => 2,
'category' => [[
'categoryId' => "00000000-0000-0000-0000-000000000000",
'countPlace' => 1,
'helf' => $part['weight'],
'size'=> 0.1
]],
'dopUslugaClassificator' => [[
'dopUsluga' => [
'uslugaId' => "2b4247c9-be8c-e211-be60-00155d037919",
'count' => 1
]
]]
);
return curl_POST($url, $data);
}
function curl_POST($url, $data)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec($curl);
curl_close($curl);
return json_decode($result);
}
}
If you have any questions in the course of the work - ask them to the Delivery company developers by filling in the contact form.
You can also use the form if there were errors that you want to inform us about, or you have suggestions for improving the service. Or write to developer - SBabiy@delivery-auto.com.ua