Async Python client for the PlentyMarkets REST API
Project description
pyPlentyAPI
Async Python client for the PlentyMarkets REST API.
Features
- Async-first: Built on
httpx.AsyncClientfor high-performance async/await support. - Lazy-loaded modules: Access
orders,items,stock, andcontactsas properties ofPlentyClient. - Auto-refreshing auth: Tokens are refreshed automatically when within 60 seconds of expiry.
- Comprehensive error handling: Custom exceptions for HTTP status codes (e.g.,
NotFoundError,RateLimitError). - Pagination support: Async generators for iterating across all pages of results.
- Type hints: Full type annotations for IDE support and static analysis.
Installation
pip install plentymarkets-api-client
Or with uv:
uv add plentymarkets-api-client
Quickstart
import asyncio
from plentymarkets import PlentyClient
async def main():
async with PlentyClient(username="your_username", password="your_password") as client:
# Fetch an order by ID
order = await client.orders.get(123)
print(order)
# List all items (paginated)
async for item in client.items.paginate_items():
print(item)
asyncio.run(main())
Modules
| Module | Description | Key Methods |
|---|---|---|
| Orders | Manage orders and order statuses. | get(), list(), create(), update_status(), paginate_orders() |
| Items | Manage items and item variants. | get(), list(), create(), update(), paginate_items() |
| Stock | Manage stock across warehouses. | get_by_warehouse(), correct(), paginate_stock() |
| Contacts | Manage customer and supplier data. | get(), list(), create(), update(), paginate_contacts() |
Authentication
- Initialize
PlentyClientwith your PlentyMarkets username and password. - The client automatically logs in and manages the
accessTokenlifecycle. - Tokens are sent as
Authorization: Bearer <token>in all requests. - If a 401 error occurs, the client attempts to re-login once before failing.
Error Handling
Custom exceptions are raised for HTTP errors:
AuthError: 401 UnauthorizedNotFoundError: 404 Not FoundRateLimitError: 429 Too Many RequestsServerError: 5xx Server ErrorsConnectionError: Network failures
Example:
try:
order = await client.orders.get(99999)
except plentymarkets.NotFoundError:
print("Order not found")
except plentymarkets.RateLimitError:
print("Rate limit exceeded")
Pagination
Use async generators to iterate across all pages:
async for order in client.orders.paginate_orders():
print(order)
Development
Setup
uv sync --extra dev
uv run pre-commit install --hook-type commit-msg
Running Tests
uv run pytest # Unit tests
uv run pytest -m integration # Integration tests (requires live credentials)
License
MIT
Project details
Release history Release notifications | RSS feed
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 plentymarkets_api_client-0.1.2.tar.gz.
File metadata
- Download URL: plentymarkets_api_client-0.1.2.tar.gz
- Upload date:
- Size: 49.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b30d43cc12aa39c25a8fa3921d969b786722434b2ae2949ea894dd74f055c52
|
|
| MD5 |
435078ddb6142664c8865e182ec7620b
|
|
| BLAKE2b-256 |
7f487d7ae221e3a568a7cbda115bed0ecbbfb7285e612c4335e70e16b3c127c0
|
File details
Details for the file plentymarkets_api_client-0.1.2-py3-none-any.whl.
File metadata
- Download URL: plentymarkets_api_client-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fb479e30b8d015500649f45e9d57ac51eb46616f2ed2ff2798329a22d64c4df
|
|
| MD5 |
6d883bc1db2f42a53fbc4c0eff42ffa4
|
|
| BLAKE2b-256 |
4d3bcbefcc6f757b9323a542b070963dde55baa00ea9d379d2815060b5267303
|