DPD API Wrapper
Project description
pydpd
A DPD API wrapper (UK only)
Create DPD shipments and generate parcel labels from within your application or webapp.
You will need a valid DPD account and have API access enabled (which can be done by calling 0121 275 7336)
Features
- Check available services for a shipment
- Create a shipment
- Generate labels in HTML, PDF, PNG or the raw printer data
What's not possible
- Collections
- Swaps
- Extended Liability
- Internation Shipments
Installation
Download and install can be done through PyPi
pip install pydpd
or
git clone https://github.com/lewis-morris/pydpd
cd pydpd
pip install -e .
IMPORTANT NOTE
If you want to generate PDF or PNG versions of your labels you will have to install some additional software
Linux / Ubuntu
sudo apt-get install wkhtmltopdf
sudo apt-get install wkhtmltoimage
Windows
When installing wkhtmltopdf and wkhtmltoimage on windows you need to set an environment variable to point to the wkhtmltopdf or wkhtmltoimage executable. You should be able to find extensive documentation to this online, but I won't provide a link to this to avoid dead links etc.
Pending Features
- Parcel Tracking
How to use
Minimal working example
from pydpd import DPD, Parcel, Address
#create sender object
sender = Address(**{"name": "Mr Ship",
"organisation": "SuperShipCo",
"address1": "Ship Street",
"address2": "Shipton",
"postcode": "BR5 3DX"})
#create dpd object
dpd = DPD("[your dpd username]","[your dpd password]","[your dpd acc no]", sender)
#create a parcel definition
my_parcel = Parcel(**{"weight": 10,
"pcs": 2,
"name": "Boris",
"address1": "10 Downing Street",
"address2": "London",
"postcode": "SW1A 2AB"})
#book the delivery with "1^12" service - (Next day) returns a delivery object
my_delivery = dpd.create_delivery(my_parcel,"1^12")
#get dpd PIL image label
my_delivery.get_png_labels(2)[0]
Full Example
I always find it best to learn by example so follow this jupyter notebook to see the flow.
All classes have doc strings, so you can always check there if you get stuck.
Contact
If you have any issues or just want to chat you can always email me at lewis.morris@gmail.com or open an issue.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pydpd-0.1.4.12.tar.gz
.
File metadata
- Download URL: pydpd-0.1.4.12.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55c5b2a8b7c196f187e15e59ec6d96e0fb1f98ed373d8abab8995c3a0fdefce8 |
|
MD5 | 7b45f28e205a89eb06394c3aa692979c |
|
BLAKE2b-256 | 60d7a419e508e1e7a286d67eba9b4da09f65c6e8e24098b20998fce5970a8f69 |
File details
Details for the file pydpd-0.1.4.12-py3-none-any.whl
.
File metadata
- Download URL: pydpd-0.1.4.12-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c28dc260bbb6535c23a95885ee9863c30281c7b5247d6c6e5a6a775c6487e360 |
|
MD5 | 0f01866390548c79928330c84cd99334 |
|
BLAKE2b-256 | e2735b585c1943f56b6c7fa1f9c49cefa031e04c43c13a3b0b6ddfcb541512a1 |