//we use the $.ajax method const config = { "prod" : { "url" : "https://uss.poczta-polska.pl", "version" : "2.0" "token" : "gNDMstgP3Yr81...0jA42DTc4MrHQ=.ODU1OT...4NjQ5MjE1RQ==.ad5bf522c...197a3944" } } jQuery.ajax({ url: config['prod'].url+"/uss/v"+config['prod'].version+"/tracking/ckeckmailex", beforeSend: function(xhrObj){ xhrObj.setRequestHeader("api_key",config['prod'].token }, data: { "states": true, "number": parcel.val(), //we insert a variable with the shipment number here "language": "PL" }, type: "GET", contentType: "application/json", success: callback, error: callback })
$curl = curl_init(); $apiKey = "gNDMstgP3Yr81...0jA42DTc4MrHQ=.ODU1OT...4NjQ5MjE1RQ==.ad5bf522c...197a3944"; $number = 123456; //add your parcel number $params = array( 'language' => 'PL', 'number' => $number, 'addPostOfficeInfo' => true, //only if the USS user has the additional attribute 'states' => true ); curl_setopt_array($curl, array( CURLOPT_URL => 'https://uss.poczta-polska.pl/uss/v2.0/tracking/checkmailex?'.http_build_query($params), CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'api_key: '.$apiKey ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
USS response for checkmailex
{ "mailInfo": { "number": "123456789", "typeOfMailCode": "PX2", "typeOfMailName": "Pocztex", "states": [ { "code": "PRZ", "name": "PRZYGOTOWANA", "time": "2024-06-06T11:59:01" } ], "finished": false, "events": [ { "code": "P_REJ_KN1", "name": "Electronic shipment data received", "time": "2024-06-06T11:59:01", "postOffice": { "name": "Electronic Sender" }, "finished": false, "canceled": false, "state": { "code": "PRZ", "name": "READY" } } ] }, "number": "123456789", "mailStatus": 1 }
//we use the $.ajax method const config = { "prod" : { "url" : "https://uss.poczta-polska.pl", "version" : "2.0" "token" : "gNDMstgP3Yr81...0jA42DTc4MrHQ=.ODU1OT...4NjQ5MjE1RQ==.ad5bf522c...197a3944" } } const parcels = ["123456789","PX6761595367","PX1234102917"]; jQuery.ajax({ url: config['prod'].url+"/uss/v"+config['prod'].version+"/tracking/ckeckmailcollectionex", beforeSend: function(xhrObj){ xhrObj.setRequestHeader("api_key",config['prod'].token); }, data: { "states": true, "addPostOfficeInfo": false, "number": parcels, //insert parcel tables with shipment numbers here "language": "PL" }, type: "POST", contentType: "application/json", success: callback, error: callback })
$curl = curl_init(); $apiKey = "gNDMstgP3Yr81...0jA42DTc4MrHQ=.ODU1OT...4NjQ5MjE1RQ==.ad5bf522c...197a3944"; $numbers = ["123456789","PX6761595367","PX1234102917"]; //add your parcels array $params = array( 'language' => 'PL', 'number' => $numbers, 'addPostOfficeInfo' => false, 'states' => true ); curl_setopt_array($curl, array( CURLOPT_URL => 'https://uss.poczta-polska.pl/uss/v2.0/tracking/checkmailcollectionex?'.http_build_query($params), CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'api_key: '.$apikey ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
USS response for checkmailcollectionex
The above method is used to query the tracking system for multiple shipments in two cases:
- when we know the set of shipments to be queried (shipment table)
- when in the
checkmailex we receive a key with an array of components , then we should use this method to retrieve data about shipments in this collection.
{ "status": 0, "mailItems": [ { "mailInfo": { "number": "123456789", "typeOfMailCode": "PX2", "typeOfMailName": "Pocztex", "states": [ { "code": "PRZ", "name": "PRZYGOTOWANA", "time": "2024-06-06T11:59:01" } ], "finished": false, "events": [ { "code": "P_REJ_KN1", "name": "Electronic shipment data received", "time": "2024-06-06T11:59:01", "postOffice": { "name": "Electronic Sender" }, "finished": false, "canceled": false, "state": { "code": "PRZ", "name": "PRZYGROTOWANA" } } ] }, "number": "123456789", "mailStatus": 1 }, { "mailInfo": { "number": "PX6761595367", "typeOfMailCode": "PX2", "typeOfMailName": "Pocztex", "states": [ { "code": "PRZ", "name": "PRZYGROTOWANA", "time": "2024-06-19T11:09:06" }, { "code": "NA", "name": "NADANA", "time": "2024-06-24T17:27:58" }, { "code": "TR", "name": "W TRANSPORCIE", "time": "2024-06-26T10:29:44" }, { "code": "DOR", "name": "W DORĘCZENIU", "time": "2024-06-26T10:55:17" }, { "code": "DO", "name": "DORĘCZONA", "time": "2024-06-26T16:07:42" } ], "finished": true, "events": [ { "code": "P_REJ_KN1", "name": "Electronic shipment data received", "time": "2024-06-19T11:09:06", "postOffice": { "name": "Electronic Sender" }, "finished": false, "canceled": false, "state": { "code": "PRZ", "name": "PRZYGOTOWANA" } }, { "code": "P_NAD", "name": "Sending the shipment", "time": "2024-06-24T17:27:58", "postOffice": { "code": "258468", "name": "UP Pabianice 1", "officeType": "UP" }, "finished": false, "canceled": false, "state": { "code": "NA", "name": "NADANA" } }, { "code": "P_WEMAIL", "name": "E-mail notification sent", "time": "2024-06-24T17:45:35", "postOffice": { "name": "Centralna Baza Danych ZST" }, "finished": false, "canceled": false }, { "code": "P_WZL", "name": "Wysłanie pocztowanie", "time": "2024-06-25T06:05:32", "postOffice": { "code": "258468", "name": "UP Pabianice 1", "officeType": "UP" }, "finished": false, "canceled": false, "state": { "code": "TR", "name": "W TRANSPORCIE" } }, { "code": "P_PZL", "name": "Nadejście", "time": "2024-06-25T09:28:49", "postOffice": { "name": "Terminal Przełaunkowy", "officeType": "CP WER" }, "finished": false, "canceled": false }, { "code": "P_WZL", "name": "Sending the shipment", "time": "2024-06-25T21:58:31", "postOffice": { "name": "Terminal Przeładunkowy", "officeType": "CP WER" }, "finished": false, "canceled": false, "state": { "code": "TR", "name": "W TRANSPORCIE" } }, { "code": "P_PZL", "name": "Nadejście", "time": "2024-06-26T02:12:20", "postOffice": { "name": "Terminal Przeładunkowy", "officeType": "CP WER" }, "finished": false, "canceled": false }, { "code": "P_Z", "name": "wyjazd z Urzęd", "time": "2024-06-26T09:00:42", "postOffice": { "code": "433373", "name": "WER Wrocław", "officeType": "CP WER" }, "finished": false, "canceled": false }, { "code": "P_WZL", "name": "Sending the shipment", "time": "2024-06-26T09:15:01", "postOffice": { "name": "Terminal Przełaunkowy", "officeType": "CP WER" }, "finished": false, "canceled": false, "state": { "code": "TR", "name": "W TRANSPORCIE" } }, { "code": "P_KOD", "name": "Przygotowano do doręczenia", "time": "2024-06-26T10:29:44", "postOffice": { "code": "269232", "name": "UP Świdnica Śląska 1", "officeType": "UP" }, "finished": false, "canceled": false, "state": { "code": "TR", "name": "W TRANSPORCIE" } }, { "code": "P_PZL", "name": "Nadejście", "time": "2024-06-26T10:45:17", "postOffice": { "code": "269232", "name": "UP Świdnica Śląska 1", "officeType": "UP" }, "finished": false, "canceled": false }, { "code": "P_WD", "name": "Prepared for delivery", "time": "2024-06-26T10:53:22", "postOffice": { "code": "269232", "name": "UP Świdnica Śląska 1", "officeType": "UP" }, "finished": false, "canceled": false, "state": { "code": "DOR", "name": "W DORĘCZENIU" } }, { "code": "P_WDML", "name": "Przedano doręczenia", "time": "2024-06-26T10:55:17", "postOffice": { "code": "269232", "name": "UP Świdnica Śląska 1", "officeType": "UP" }, "finished": false, "canceled": false, "state": { "code": "DOR", "name": "W DORĘCZENIU" } }, { "code": "P_WSMS", "name": "SMS notification sent", "time": "2024-06-26T11:05:25", "postOffice": { "name": "Centralna Baza Danych ZST" }, "finished": false, "canceled": false }, { "code": "P_WEMAIL", "name": "E-mail notification sent", "time": "2024-06-26T11:06:04", "postOffice": { "name": "Centralna Baza Danych ZST" }, "finished": false, "canceled": false }, { "code": "P_D", "name": "Doręczono", "time": "2024-06-26T14:21:38", "postOffice": { "code": "269232", "name": "UP Świdnica Śląska 1", "officeType": "UP" }, "finished": true, "canceled": false, "state": { "code": "DO", "name": "DORĘCZONA" } }, { "code": "P_UKEPO", "name": "Providing the recipient's signature", "time": "2024-06-26T14:21:42", "postOffice": { "code": "119479", "name": "Central Control System for Mobile Postman", "officeType": "CSS" }, "finished": false, "canceled": false }, { "code": "P_WEMAIL", "name": "E-mail notification sent", "time": "2024-06-26T14:36:47", "postOffice": { "name": "Centralna Baza Danych ZST" }, "finished": false, "canceled": false }, { "code": "P_RDML", "name": "KD settlement by the postman", "time": "2024-06-26T15:57:34", "postOffice": { "code": "269232", "name": "UP Świdnica Śląska 1", "officeType": "UP" }, "finished": false, "canceled": false }, { "code": "P_KOL", "name": "Liquidation of the delivery book after delivery", "time": "2024-06-26T16:07:42", "postOffice": { "code": "269232", "name": "UP Świdnica Śląska 1", "officeType": "UP" }, "finished": false, "canceled": false, "state": { "code": "DO", "name": "DELIVERED" } } ] }, "number": "PX6761595367", "mailStatus": 0 }, { "number": "PX1234102917", "mailStatus": -1 } ] }
NOTE 1! Please note that for the checkmailcollectionex mailInfo in the mailItems is returned .
NOTE 2! The other two shipments have two different mailStatus , which clearly define the status of a given shipment.