A Python client for the Shippingbo API.
Project description
shippingboapy
An async Python SDK for the ShippingBo API.
shippingboapy is a faithful, low-level wrapper around the ShippingBo REST API. The SDK structure mirrors the actual API endpoints rather than introducing ergonomic abstractions that hide them.
⚠️ Alpha: this SDK is in early development. The public API may change before v1.0.
Installation
pip install shippingboapy
Requirements
- Python 3.10+
Usage
Initialization
If you already have an access token and refresh token:
from shippingboapy import Client
client = Client(
access_token="your_access_token",
refresh_token="your_refresh_token",
app_id="your_app_id",
api_version="your_api_version",
client_id="your_client_id",
client_secret="your_client_secret",
)
OAuth — first-time authentication
If you don't have tokens yet, use the OAuth flow with an authorization code:
from shippingboapy import Client
client = await Client.from_auth_code(
auth_code="your_auth_code",
app_id="your_app_id",
api_version="your_api_version",
client_id="your_client_id",
client_secret="your_client_secret",
redirect_uri="your_redirect_uri",
)
Context manager
async with Client(...) as client:
products = await client.products.list()
Or with explicit cleanup:
client = Client(...)
try:
products = await client.products.list()
finally:
await client.close()
Configuration
client.set_config(
timeout=30,
max_retries=3,
retry_backoff_factor=0.5,
api_url="https://app.shippingbo.com",
)
Products
List products
products = await client.products.list()
With filters:
products = await client.products.list(
limit=50,
offset=0,
is_pack=False,
search=[("user-ref", "eq", "123456")],
sort=[("updated_at": "asc")],
)
Get a product
product = await client.products.get(product_id=123)
Create a product
from shippingboapy import ProductCreate
product = await client.products.create(
ProductCreate(
user_ref="MY-REF-001",
title="My Product",
weight=500,
width=200,
length=300,
height=100,
)
)
Orders
List orders
orders = await client.orders.list(limit=50)
Get an order
order = await client.orders.get(order_id=456)
Create an order
from shippingboapy import OrderCreate, OrderItemCreate
order = await client.orders.create(
OrderCreate(
product_source= "product_src_str",
source="source"
title="Order Title"
...
)
)
Token refresh
Token refresh is handled automatically on 401 responses. After any request, the current tokens are accessible on the client:
client.token.access_token
client.token.refresh_token
Persisting refreshed tokens
To persist tokens after an automatic refresh, register a callback at init:
async def save_tokens(access_token: str, refresh_token: str):
# Persist to your database, file, or any storage
await db.save(access_token=access_token, refresh_token=refresh_token)
client = Client(
access_token="your_access_token",
refresh_token="your_refresh_token",
...,
on_token_refresh=save_tokens,
)
Token storage is intentionally left to the caller, the SDK does not persist tokens itself.
Error handling
The SDK raises typed exceptions for predictable failure modes:
ShippingboAPYException
├── AuthenticationError
│ ├── TokenExpiredError
│ └── TokenRefreshError
└── APIRequestError # exposes .status_code and .message
├── BadRequestError # 400
├── UnauthorizedError # 401
├── ForbiddenError # 403
├── NotFoundError # 404
├── RateLimitError # 429
├── ServerError # 5xx
└── UnexpectedError # any other status
from shippingboapy import TokenRefreshError, ShippingBoAPIError
try:
await client.products.get(product_id=123)
except TokenRefreshError:
# Re-authenticate the user
...
except ShippingBoAPIError as e:
print(e.status_code, e.message)
Available Resources
| Resource | Status |
|---|---|
| Products | ✅ Available |
| Orders | ✅ Available |
| Addresses | ✅ Available |
| Address Labels | ✅ Available |
| Order Tags | ✅ Available |
| Order Documents | ✅ Available |
| Stock Variations | 🚧 Planned |
| Suppliers | 🚧 Planned |
Missing a resource? Contributions are welcome — see CONTRIBUTING.md.
License
MIT — see LICENSE.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shippingboapy-0.1.3.tar.gz.
File metadata
- Download URL: shippingboapy-0.1.3.tar.gz
- Upload date:
- Size: 39.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb6567f7b84088fd2a73e5501e8856f1a874c529b9d3a112fcee46fc8be0c600
|
|
| MD5 |
68d7445ef9fe4ca3dd42cffa2f57e9af
|
|
| BLAKE2b-256 |
6ac55a14636b820b5e3868b78a4517ee5de7c2869485e344a38864ae86b866c6
|
File details
Details for the file shippingboapy-0.1.3-py3-none-any.whl.
File metadata
- Download URL: shippingboapy-0.1.3-py3-none-any.whl
- Upload date:
- Size: 50.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3895a2cf34b6e0988ef4af8f0a5a88c85dfc5b83a2118361a0099729e848ee3
|
|
| MD5 |
59c9b2aa647c0af4011d2fdb14575045
|
|
| BLAKE2b-256 |
6f409c65af020335bbf2f043c5f4adfed8dc47be6a6097385fcbda8d50a55ffa
|