Skip to main content

No project description provided

Project description

Unofficial Shipengine

The unofficial Python module for ShipEngine API.

Tests

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:

  1. 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)
  1. 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)
  1. 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.

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

unofficial_shipengine-0.1.0.tar.gz (52.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unofficial_shipengine-0.1.0-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file unofficial_shipengine-0.1.0.tar.gz.

File metadata

  • Download URL: unofficial_shipengine-0.1.0.tar.gz
  • Upload date:
  • Size: 52.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.2 Windows/11

File hashes

Hashes for unofficial_shipengine-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a3ed34e97427db46db526b9289ae0e8734123f74afe66d6dcaef455a473cda45
MD5 acf7de6e9890808119779ea8e2d3f003
BLAKE2b-256 05ce9d109eed4cd1079484aaf4eaeceb76719acd62bdbd6f1a66324dfc29f069

See more details on using hashes here.

File details

Details for the file unofficial_shipengine-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for unofficial_shipengine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b57cb7402bb2fa51d52eea1c7ba4ddb9002cab6bce930b7ed2294f2b26b0ddfb
MD5 bf09a2ca0052f65d01a4825770828112
BLAKE2b-256 80a497f3ae504b91768b30b94d9cac2a827d7f4cc8329df3bcd4c940d11b1b2d

See more details on using hashes here.

Supported by

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