purplship is a multi-carrier shipping SDK.
The key features are:
- Unified API: A standardized set of models representing the common shipping data (
Address,Parcel,Shipment...) - Intuitive API: A library that abstracts and unifies the typical shipping API services (
Rating,Shipping,Tracking...) - Multi-carrier: Integrate purplship once and connect to multiple shipping carrier APIs
- Custom carrier: A framework to integrate a shipping carrier services within hours instead of months
Requirements
Python 3.7+
Installation
# install purplship core
pip install purplship
# eg: install the purplship canadapost extention
pip install purplship.canadapost
Additional carrier extensions
purplship.aramexpurplship.australiapostpurplship.canadapostpurplship.canparpurplship.dhl-expresspurplship.dhl-universalpurplship.dicompurplship.fedexpurplship.purolatorpurplship.royalmailpurplship.sendlepurplship.sf-expresspurplship.tntpurplship.upspurplship.uspspurplship.usps-internationalpurplship.yanwenpurplship.yunexpress
Usage
Rates Fetching
- Fetch shipping rates
import purplship
from purplship.core.models import Address, Parcel, RateRequest
from purplship.mappers.canadapost.settings import Settings
# Initialize a carrier gateway
canadapost = purplship.gateway["canadapost"].create(
Settings(
username="6e93d53968881714",
password="0bfa9fcb9853d1f51ee57a",
customer_number="2004381",
contract_id="42708517",
test=True
)
)
# Fetching shipment rates
# Provide the shipper's address
shipper = Address(
postal_code="V6M2V9",
city="Vancouver",
country_code="CA",
state_code="BC",
address_line1="5840 Oak St"
)
# Provide the recipient's address
recipient = Address(
postal_code="E1C4Z8",
city="Moncton",
country_code="CA",
state_code="NB",
residential=False,
address_line1="125 Church St"
)
# Specify your package dimensions and weight
parcel = Parcel(
height=3.0,
length=6.0,
width=3.0,
weight=0.5,
weight_unit='KG',
dimension_unit='CM'
)
# Prepare a rate request
rate_request = RateRequest(
shipper=shipper,
recipient=recipient,
parcels=[parcel],
services=["canadapost_xpresspost"],
)
# Send a rate request using a carrier gateway
response = purplship.Rating.fetch(rate_request).from_(canadapost)
# Parse the returned response
rates, messages = response.parse()
print(rates)
# [
# RateDetails(
# carrier_name="canadapost",
# carrier_id="canadapost",
# currency="CAD",
# transit_days=2,
# service="canadapost_xpresspost",
# discount=1.38,
# base_charge=12.26,
# total_charge=13.64,
# duties_and_taxes=0.0,
# extra_charges=[
# ChargeDetails(name="Automation discount", amount=-0.37, currency="CAD"),
# ChargeDetails(name="Fuel surcharge", amount=1.75, currency="CAD"),
# ],
# meta=None,
# id=None,
# )
# ]
Resources
Metadata
Release files for purplship 2022.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| purplship-2022.2-py3-none-any.whl | Python 3 | none | any | Details |
Release files / purplship-2022.2-py3-none-any.whl
| Download URL | purplship-2022.2-py3-none-any.whl |
|---|---|
| Size | 43.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d0e630730b8d02b2fba29905c71eada94a20728e8011f5bf266f7a705813881c
|
|
BLAKE2b-256 checksum How to use checksums |
86e7a4c9ab4edf50bb032b7ce2d970c0881678f6209fedf7b19504bea476c68a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.6
|