DPD API library, to help to integrate with other systems
To install via composer:
composer require neriba/dpd-api-lib
- LT - Lithuania production (default).
- LT_TEST - Lithuania sandbox.
- LV - Latvia production.
- LV_TEST - Latvia sandbox.
- EE - Estonia production.
- EE_TEST - Estonia sandbox.
If you don't have an API key from DPD, but you have an old API credencials name and password you can generate your own API key.
// By default, third parameter is Lithuanian production environment
$getToken = new \NeriBa\DpdApiLib\ApiTokenGenerator('USERNAME','PASSWORD','LT_TEST');
$getToken->createAuthToken('Token name');
$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9....';
// By default, third parameter is Lithuanian production environment
$dpd = new \NeriBa\DpdApiLib\Request($token, 'LT_TEST');
$dpd->authMe();
$dpd->getAuthTokenSecrets();
$dpd->deleteAuthTokenSecrets('99bb2035-5ed8-4547-95ca-7ffb5e79e694');
// additional parameters are possible as an array e.g ['countryFrom' => 'LT', 'countryTo' => 'LT']
// Parameters list: https://esiunta.dpd.lt/api#/Services/042db4934d823e1cc21745c549f2a810
$dpd->getServices(['countryFrom' => 'LT', 'countryTo' => 'LT']);
// additional parameters are possible as an array e.g ['limit'=> 10]
// Parameters list: https://esiunta.dpd.lt/api/#/Shipment/1aed3b00cafe6d7bd576b2b84b41826f
$dpd->getShipments();
$senderAddress = new \NeriBa\DpdApiLib\Shipment\Package\Address();
$senderAddress
->setName('Test Sender')
->setPhone('62166025')
->setStreet('Uosių g')
->setStreetNo(24)
->setCity('Kaunas')
->setPostalCode('51446')
->setCountry('LT');
$receiverAddress = new \NeriBa\DpdApiLib\Shipment\Package\Address();
$receiverAddress
->setName('Test Receiver')
->setPhone('65123456')
->setStreet('Uriekstes')
->setStreetNo(24)
->setCity('Kaunas')
->setPostalCode('51446')
->setCountry('LT');
$shipment = new \NeriBa\DpdApiLib\Shipment\Shipment();
$shipment
->setSenderAddress($senderAddress)
->setReceiverAddress($receiverAddress)
->setService((new \NeriBa\DpdApiLib\Shipment\Package\Service())->setServiceName('DPD CLASSIC'))
->setParcel((new \NeriBa\DpdApiLib\Shipment\Package\Parcel())->setWeight(31)->setSize('XS'));
$shipment2 = new \NeriBa\DpdApiLib\Shipment\Shipment();
$shipment2
->setSenderAddress($senderAddress)
->setReceiverAddress($receiverAddress)
->setService((new \NeriBa\DpdApiLib\Shipment\Package\Service())->setServiceName('DPD CLASSIC'))
->setParcel((new \NeriBa\DpdApiLib\Shipment\Package\Parcel())->setWeight(10)->setSize('m'));
// Max 50 shipments per request
$dpd->createShipments([$shipment,$shipment2]);
$dpd->deleteShipments(['0fa01f06-7c56-4c5c-a33f-0eca869663f3','0fa01f06-7c56-4c5c-a33f-0eca869663f4']);
$dpd->createShipmentsLabels((new \NeriBa\DpdApiLib\Shipment\Package\LabelOption())->setShipmentIds(['0fa01f06-7c56-4c5c-a33f-0eca869663f3']));
$dpd->getInvoices('0fa01f06-7c56-4c5c-a33f-0eca869663f3');
$dpd->getLockers(['countryCode' => 'LT']);
$dpd->createShipmentManifest((new \NeriBa\DpdApiLib\Shipment\Package\Manifest())->setShipmentIds(['0fa01f06-7c56-4c5c-a33f-0eca869663f3']));
$dpd->getShipmentsManifestByManifest('0fa01f06-7c56-4c5c-a33f-0eca869663f3');
$dpd->getShipmentsManifestByShipment('0fa01f06-7c56-4c5c-a33f-0eca869663f3');
$pickupAddress = new \NeriBa\DpdApiLib\Shipment\Package\Address();
$pickupAddress
->setName('Test Sender')
->setContactName('Test Sender cc')
->setEmail('[email protected]')
->setPhone('+37062166025')
->setStreet('Uosių g')
->setStreetNo(24)
->setCity('Kaunas')
->setPostalCode('51446')
->setCountry('LT');
$pickup = new \NeriBa\DpdApiLib\Pickup\Pickup();
$pickup
->setPallets([(new \NeriBa\DpdApiLib\Pickup\Package\Pallet())->setWeight(150)->setCount(1)])
->setAddress($pickupAddress)
->setPickupDate('2022-10-12')
->setPickupTime('11:00', '15:00');
$dpd->createPickup($pickup);
// additional parameters are possible as an array e.g ['limit'=> 10]
// Parameters list: https://esiunta.dpd.lt/api/#/Pickup/50e315fc1327d9f9a55db05ef66b4b48
$dpd->getPickups();
// additional parameters are possible as an array e.g ['country' => 'LT','zip' => 51336]
// Parameters list: https://esiunta.dpd.lt/api/#/Pickup%20timeframes/e092e35374638c464b1e0b3eaa7513d9
$dpd->getPickupTimeFrames(['country' => 'LT','zip' => 51336]);
$dpd->getProblems(123456);
// additional parameters are possible as an array e.g ['pknr' => '05808021421108','show_all' => 1]
// Parameters list: https://esiunta.dpd.lt/api#/Status/ede44d1ca4e3e15955d44ecc42970e3c
$dpd->getTrackingStatus(['pknr' => '05808021421108']);
// additional parameters are possible as an array e.g ['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']
// Parameters list: https://esiunta.dpd.lt/api#/Status/8d78b691726ba36b76c5960067c1370c
$dpd->subscribeToParcel(['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']);
// additional parameters are possible as an array e.g ['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']
// Parameters list: https://esiunta.dpd.lt/api#/Status/915e1bfce8f27458cfb3f27f78326866
$dpd->unsubscribeToParcel(['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']);
- LT - Lithuania production (default).
- LV - Latvia production.
- EE - Estonia production.
NOTE: Now tracking working without authorization,although the documentation says that it is used Bearer.
$apiKey = '';
// By default, second parameter is Lithuanian production environment
$tracking = new \NeriBa\DpdApiLib\Tracking($apiKey,'LT');
$tracking->getTracking(['05808021421108','05808021421105']);
The MIT License (MIT). Please see License File for more information.