Unofficial Shipengine
The unofficial Python module for ShipEngine API.
The Unofficial ShipEngine client provides a simple interface for interacting with the ShipEngine API. It enables users to manage shipments, carriers, batches, warehouses, labels, and tracking.
Installation
To install, you can use pip:
pip install unofficial-shipengine-python
Usage
Initialization
from unofficial_shipengine.unofficial_shipengine import UnofficialShipEngine
# Initialize the client with a configuration
client = UnofficialShipEngine(config)
Configuration
The UnofficialShipEngine client object requires an API key to communicate with the ShipEngine API. The configuration can be provided in three formats:
- An instance of
UnofficialShipEngineConfig:
from unofficial_shipengine.unofficial_shipengine import UnofficialShipEngine, UnofficialShipEngineConfig
config = UnofficialShipEngineConfig(api_key='your_api_key', retries=3, backoff_factor=0.5)
client = UnofficialShipEngine(config)
- A dictionary containing configuration parameters:
from unofficial_shipengine.unofficial_shipengine import UnofficialShipEngine
config_dict = {
'api_key': 'your_api_key',
'retries': 3,
'backoff_factor': 0.5
}
client = UnofficialShipEngine(config_dict)
- A string representing just the API key (other parameters will default):
from unofficial_shipengine.unofficial_shipengine import UnofficialShipEngine
client = UnofficialShipEngine("your_api_key")
Services
Once initialized, the client provides access to various services:
shipments: Manage shipments.carriers: Manage carriers.batches: Manage batches of shipments.warehouses: Manage warehouses.labels: Manage labels for shipments.tracking: Track shipments.
Example usage:
# Create a shipment
from unofficial_shipengine.unofficial_shipengine import UnofficialShipEngine
from unofficial_shipengine.core.shipments.models import ShipmentRequest
from unofficial_shipengine.core.batches.models import BatchRequest, ProcessLabels
client = UnofficialShipEngine("your_api_key")
shipment_request = ShipmentRequest(...)
shipment = client.shipments.create_shipment(shipment_request)
# Create a batch
batch_request = BatchRequest(...)
batch = client.batches.create_batch(batch_request)
# Add the shipment to the batch
client.batches.add_to_batch(batch, shipments=[shipment])
# Process the batch
client.batches.process_labels(batch, ProcessLabels(...))
# Refetch the batch to either check processing status or download labels
batch = client.batches.get_by_id(batch.batch_id)
Documentation
ShipmentService
The ShipmentService provides methods for interacting with shipment-related endpoints in the ShipEngine API.
Methods
create_shipment(shipment_request: Union[ShipmentRequest, list[ShipmentRequest]]) -> Union[Shipment, list[Shipment]]: Creates a shipment or a list of shipments.get_by_id(shipment_id: str) -> Shipment: Retrieves a shipment by its ID.get_by_external_id(external_shipment_id: str) -> Shipment: Retrieves a shipment by its external ID.update_shipment(shipment: Shipment) -> Shipment: Updates an existing shipment.cancel_shipment(shipment: Union[Shipment, str]) -> None: Cancels a shipment.
CarrierService
The CarrierService provides methods for interacting with carrier-related endpoints in the ShipEngine API.
Methods
get_carriers() -> list[Carrier]: Retrieves a list of carriers.get_by_id(carrier_id: str) -> Carrier: Retrieves a carrier by its ID.add_funds(carrier: Union[Carrier, str], amount: float, currency: str = "usd") -> CarrierBalance: Adds funds to a carrier account.
BatchService
The BatchService provides methods for interacting with batch-related endpoints in the ShipEngine API.
Methods
create_batch(batch_shipments: list[str]) -> Batch: Creates a batch of shipments.get_by_id(batch_id: str) -> Batch: Retrieves a batch by its ID.add_shipments_to_batch(batch_id: str, shipment_ids: list[str]) -> Batch: Adds shipments to an existing batch.remove_shipments_from_batch(batch_id: str, shipment_ids: list[str]) -> Batch: Removes shipments from a batch.
WarehouseService
The WarehouseService provides methods for interacting with warehouse-related endpoints in the ShipEngine API.
Methods
create_warehouse(warehouse_request: WarehouseRequest) -> Warehouse: Creates a warehouse.delete_warehouse(warehouse: Union[Warehouse, str]) -> None: Deletes a warehouse.get_by_id(warehouse_id: str) -> Warehouse: Retrieves a warehouse by its ID.
LabelService
The LabelService provides methods for interacting with label-related endpoints in the ShipEngine API.
Methods
purchase_label(label_request: LabelRequest) -> Label: Purchases a shipping label.create_return_label(label: Union[Label, str], return_label_request: ReturnLabelRequest) -> Label: Creates a return label for an existing label.get_by_id(label_id: str) -> Label: Retrieves a label by its ID.get_label_tracking_info(label: Union[Label, str]) -> TrackingInformation: Retrieves tracking information for a label.
TrackingService
The TrackingService provides methods for interacting with tracking-related endpoints in the ShipEngine API.
Methods
get_tracking_information(carrier_code: str, tracking_number: str) -> TrackingInformation: Retrieves tracking information for a package.start_tracking_package(carrier_code: str, tracking_number: str) -> None: Starts tracking a package.stop_tracking_package(carrier_code: str, tracking_number: str) -> None: Stops tracking a package.
For detailed documentation on methods and parameters, refer to the source code or the official ShipEngine API documentation.
Metadata
Release files for unofficial-shipengine 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| unofficial_shipengine-0.1.0.tar.gz | 52.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| unofficial_shipengine-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 78.6 kB
Release files / unofficial_shipengine-0.1.0.tar.gz
| Download URL | unofficial_shipengine-0.1.0.tar.gz |
|---|---|
| Size | 52.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3ed34e97427db46db526b9289ae0e8734123f74afe66d6dcaef455a473cda45
|
|
BLAKE2b-256 checksum How to use checksums |
05ce9d109eed4cd1079484aaf4eaeceb76719acd62bdbd6f1a66324dfc29f069
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.2 Windows/11
|
Release files / unofficial_shipengine-0.1.0-py3-none-any.whl
| Download URL | unofficial_shipengine-0.1.0-py3-none-any.whl |
|---|---|
| Size | 26.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b57cb7402bb2fa51d52eea1c7ba4ddb9002cab6bce930b7ed2294f2b26b0ddfb
|
|
BLAKE2b-256 checksum How to use checksums |
80a497f3ae504b91768b30b94d9cac2a827d7f4cc8329df3bcd4c940d11b1b2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.2 Windows/11
|