Giter Club home page Giter Club logo

purplship's Introduction

Purplship

Purplship - The Open Source multi-carrier shipping SDK

CI License: AGPL v3 Code style: black Codacy Badge

Puprlship is a modern development kit that simplifies the integration of shipping carriers services into an app.

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, Pickup, 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

For a complete shipping management REST API with a dashboard checkout purplship-server.

Requirements

Python 3.6+

Installation

# install purplship core
pip install purplship

# install the purplship canadapost extention
pip install purplship.canadapost

Additional extensions:

Available carriers
  • purplship.aramex
  • purplship.australiapost
  • purplship.canadapost
  • purplship.canpar
  • purplship.dhl-express
  • purplship.dhl-universal
  • purplship.dicom
  • purplship.fedex-express
  • purplship.purolator-courier
  • purplship.royalmail
  • purplship.sendle
  • purplship.sf-express
  • purplship.ups-package
  • purplship.usps
  • purplship.yanwen
  • purplship.yunexpress

Usage

  • 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="username",
        password="password",
        customer_number="123456789",
        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],
)

# 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

Contributing

We encourage you to contribute to Purplship! Please check out the Contributing to Purplship guide for guidelines about how to proceed. Join us!

Do you want to extend Purplship and integrate a custom carrier, check out Extending Purplship

License

This project is licensed under the terms of the LGPL v3 license. Please see LICENSE.md for licensing details.

Authors

purplship's People

Contributors

danh91 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.