Skip to main content

Itella SmartPost API wrapper for humans 📦

Project description

aiosmartpost - Itella SmartPost API wrapper for humans 📦

WORK IN PROGRESS! NOT READY FOR PRODUCTION USE

Official SmartPost API Docs

This solution:

  • has both async and sync API
  • has 100% type-annotated code
  • is tested in real-world project in Estonia

Quickstart

Examples use async version of Client, but you can use import below instead and remove await keywords:

from smartpost.sync import Client

Fetch list of available Estonian destinations:

>>> from smartpost import Client
>>> client = Client("user", "pass")  # credentials can be omitted in this case
>>> await client.get_ee_terminals()
[Destination(place_id=101, name='Viljandi Männimäe Selver', ...), ...]

Add new shipment order and get A5 PDF with label for it:

>>> from smartpost import Client
>>> from smartpost.errors import ShipmentOrderError
>>> from smartpost.models import Recipient, EETerminalDestination, ShipmentOrder
>>> client = Client("user", "pass")
>>> recipient = Recipient("John Doe", "+37255555555", "john.doe@example.com")
>>> terminal = EETerminalDestination(102)
>>> order_id = 547
>>> order = ShipmentOrder(recipient, terminal, reference=str(order_id))
>>> try:
>>>     orders_info = await client.add_shipment_orders([order])
>>> except ShipmentOrderError as exc:
>>>     print("Failed to add shipment order:")
>>>     for error_details in exc.errors:
>>>         print(f"Order #{error_details['reference']} error: {str(error_details)}")
>>>
>>> orders_info
[OrderInfo(barcode='XXXXXXXXXXXXXXXX', reference=None, sender=None, doorcode=None)]


>>> pdf_bytes = await client.get_labels_pdf("A5", [orders_info[0].barcode])
>>> with open("/tmp/test.pdf", "wb") as file:
...   file.write(pdf_bytes)
... 
57226

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiosmartpost-0.3.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

aiosmartpost-0.3.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file aiosmartpost-0.3.1.tar.gz.

File metadata

  • Download URL: aiosmartpost-0.3.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aiosmartpost-0.3.1.tar.gz
Algorithm Hash digest
SHA256 90ea2b87746421fb82af2c255158b308c4fb4de3cc4fd79512b960cfd5d5ee37
MD5 fc957e956c55839d5cca39b71cd68d5a
BLAKE2b-256 646f5c9ffd93b8b981fe9ae484e8a0927dda3b8f12fa841f1dc14178d2a624d4

See more details on using hashes here.

File details

Details for the file aiosmartpost-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: aiosmartpost-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aiosmartpost-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd14c3595e9b2f2e0c2fb8fe79afca44dbd7f06e454dbacff93aabaebe1e7cd1
MD5 4c1b84e62dd7322ebbf579b750d84506
BLAKE2b-256 8b09bd6043cf779020ffd189f86eb24fe254471602645db402afb17b84b3d565

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page