Skip to main content

Async Python wrapper for the ShipStation API

Project description

ShipStation Interaction / Automation

Type-Check Linting Code style: black Validation: Pydantic v2 Python 3.11.14 PyPI - Version PyPI - License

Async Python client for ShipStation V1 and V2 APIs with full type hints.

Install

pip

pip install AsyncShipStation

Manual

git clone git@github.com:sudoDeVinci/AsyncShipStation.git
cd AsyncShipStation
pip install -r requirements.txt

Setup

from AsyncShipStation import ShipStationClient

# Configure with both V1 and V2 credentials
ShipStationClient.configure(
    v2_key="your_v2_api_key",
    v1_key="your_v1_api_key",
    v1_secret="your_v1_secret",
)

Client Lifecycle

The library uses a shared httpx.AsyncClient under the hood. You have two options for managing it:

Option 1: Let it auto-start (simple)

The client starts automatically on first request. Just remember to close it when done:

import asyncio
import os
from dotenv import load_dotenv
from AsyncShipStation import ShipStationClient, InventoryPortal

load_dotenv()
API_KEY: str | None = os.getenv("API_KEY")

async def main() -> None:
    ShipStationClient.configure(api_key=API_KEY)

    # Connection pool starts on first request
    status, warehouses = await InventoryPortal.list_warehouses(page_size=10)
    print(f"Status: {status}, Warehouses: {warehouses}")
    
    ...

    # Clean up when done
    await ShipStationClient.close()


if __name__ == "__main__":
    asyncio.run(main())

Option 2: Use the async context manager (recommended)

Scoped usage where you want automatic cleanup:

import asyncio
import os
from dotenv import load_dotenv
from AsyncShipStation import ShipStationClient, InventoryPortal

load_dotenv()
API_KEY: str | None = os.getenv("API_KEY")

async def main() -> None:
    ShipStationClient.configure(api_key=API_KEY)

    async with InventoryPortal.scoped_client() as _:
        status, warehouses = await InventoryPortal.list_warehouses(page_size=10)
        print(f"Status: {status}, Warehouses: {warehouses}")
        
        ...
     
        # Client closes automatically when exiting the context

if __name__ == "__main__":
    asyncio.run(main())

Concurrent Requests

The client uses connection pooling, so concurrent requests share connections efficiently:

import asyncio
from AsyncShipStation import (
    BatchPortal,
    InventoryPortal,
    LabelPortal,
    ShipStationClient,
)

        ...

ShipStationClient.configure(api_key=API_KEY)
async with ShipStationClient.scoped_client() as _:
    results = await asyncio.gather(
        InventoryPortal.list_warehouses(),
        InventoryPortal.list(),
        BatchPortal.list(),
        LabelPortal.list(),
    )

for status, data in results:
    if status in (200, 207, 201):
        print(f"Success :: {data}")
    else:
        print(f"Error :: {data}")
    
        ...

Rate Limiting

Accounts that send too many requests in quick succession will receive a 429 Too Many Requests error response and include a Retry-After header with the number of seconds to wait for. By default we get 200 requests per minute. ShipStation has bulk op endpoints. These only count as a single request.

Endpoints

/batches Process labels in bulk and receive a large number of labels and customs forms in bulk responses. Batching is ideal for workflows that need to process hundreds or thousands of labels quickly. 200

/carriers Retreive useful details about the carriers connected to your accounts, including carrier IDs, service IDs, advanced options, and available carrier package types.

/fulfillments Manage fulfillments which represent completed shipments. Create fulfillments to mark orders as shipped with tracking information and notify customers and marketplaces.

/inventory Manage inventory, adjust quantities, and handle warehouses and locations.

/labels Purchase and print shipping labels for any carrier active on your account. The labels endpoint also supports creating return labels, voiding labels, and getting label details like tracking.

/manifests A manifest is a document that provides a list of the day's shipments. It typically contains a barcode that allows the pickup driver to scan a single document to register all shipments, rather than scanning each shipment individually.

/rates (V2) Calculate and estimate shipping rates across multiple carriers. Supports both full rate calculation with shipment details and quick rate estimates.

/shipments (V2) Create, retrieve, and manage shipments. Includes support for getting rates, adding/removing tags, and cancellation.

/tags (V2) Manage tags for organizing shipments and orders. Create, list, and delete tags.

/warehouses (V2) Retrieve warehouse information including origin addresses for shipments.

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

asyncshipstation-0.2.0.0.tar.gz (42.7 kB view details)

Uploaded Source

Built Distribution

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

asyncshipstation-0.2.0.0-py3-none-any.whl (64.7 kB view details)

Uploaded Python 3

File details

Details for the file asyncshipstation-0.2.0.0.tar.gz.

File metadata

  • Download URL: asyncshipstation-0.2.0.0.tar.gz
  • Upload date:
  • Size: 42.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for asyncshipstation-0.2.0.0.tar.gz
Algorithm Hash digest
SHA256 e0c0466cbf1bd85ec3fd92827ab04660695c3ad705781be9c9caec114d066aa8
MD5 351ba5615a0e6e469dd97c3454865553
BLAKE2b-256 1ab6320b2f6c6a06dde41db5ddb83e066196a04fa7fbbe5b5399b332fb8dd2bd

See more details on using hashes here.

File details

Details for the file asyncshipstation-0.2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for asyncshipstation-0.2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38d4ceeffafadd88b94df6c27730640222c65ec374831f1d19f5a2e361395cc7
MD5 bb0d15de87c7ea3842e7d607be5074e4
BLAKE2b-256 2c6fc3a80cb7a732d41687aabd1ddb7255723c2381f2abeb038d5855ff294068

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