Python client SDK for the MyOnlineStore Connect API
Project description
MyOnlineStore Connect API — Python Client
A typed Python SDK for the MyOnlineStore Connect API, providing sync and async access to all API endpoints with Pydantic-validated models.
PyPI package name:
myonlinestore-connectPython import name:myonlinestore
Installation
pip install myonlinestore-connect
Then import it in Python with:
import myonlinestore
Or install from source:
pip install -e .
Quick start
from myonlinestore import ConnectClient
client = ConnectClient(
store_token="your-store-token",
partner_token="your-partner-token", # optional
)
# List articles
page = client.articles.list(limit=20)
for article in page.items:
print(f"{article.name} — {article.price}")
# Get a single order
order = client.orders.get(order_number=12345)
print(order.debtor.email)
client.close()
Async usage
Every method has an async counterpart prefixed with a:
import asyncio
from myonlinestore import ConnectClient
async def main():
async with ConnectClient(store_token="your-token") as client:
page = await client.articles.alist(limit=50)
order = await client.orders.aget(order_number=12345)
asyncio.run(main())
Pagination
List endpoints return a PaginatedResponse with built-in page tracking:
page = client.articles.list(limit=100, offset=0)
print(page.has_next) # True if more pages exist
print(page.next_offset) # offset for the next page
To iterate all items automatically:
from myonlinestore.pagination import iterate_all
for article in iterate_all(client.articles.list, page_size=100):
process(article)
Async iteration:
from myonlinestore.pagination import aiterate_all
async for article in aiterate_all(client.articles.alist, page_size=100):
await process(article)
Available resources
| Resource | Accessor | Key methods |
|---|---|---|
| Articles | client.articles |
list, get, create, update, delete, count, upload_image, delete_image |
| Orders | client.orders |
list, get, create, update, count, create_credit, list_payments, create_payment, create_payment_raw, update_payment, delete_payment |
| Customers | client.customers |
list, get, create, update, delete, list_addresses, get_address, create_address, update_address, delete_address |
| Categories | client.categories |
list, get, create, update, count, list_articles |
| Discount codes | client.discount_codes |
list, get, create, update, delete |
| Newsletter | client.newsletter |
list, get, create, update, delete, count |
| Order statuses | client.order_statuses |
list |
| Payment gateways | client.payment_gateways |
list, list_for_store |
| Shipping methods | client.shipping_methods |
list |
| Store info | client.store |
get |
| Offline locations | client.offline_locations |
list, get |
| Tax policy | client.tax_policy |
list, get |
| Article fields | client.article_fields |
create, delete |
| Article lists | client.article_lists |
get, add, remove |
| Article list options | client.article_list_options |
create, delete |
Note:
list_articleson categories returnsArticleLimitedobjects (id, name, uuid, is_main only).create_payment_rawreturns the full API response dict including the payment redirect URL.
Configuration
from myonlinestore import ConnectClient, ConnectConfig
config = ConnectConfig(
store_token="xxx",
partner_token="yyy",
api_version="1", # "1" (stable) or "2-beta"
language="en_GB", # response language
timeout=60.0, # default timeout (seconds)
connect_timeout=5.0, # TCP connect timeout
read_timeout=30.0, # response read timeout
pool_timeout=30.0, # pool acquire timeout
max_connections=100, # connection pool size
max_keepalive=20, # keep-alive connections
default_limit=50, # default page size
max_retries=3, # retry attempts (0 to disable)
max_retry_delay=60.0, # cap on retry backoff (seconds)
idempotency_key_header="Idempotency-Key", # None to disable
)
client = ConnectClient(config=config)
Retry and resilience
The SDK automatically retries on transient errors (429, 500, 502, 503, 504, and connection/timeout errors) using exponential backoff with full jitter:
delay = random(0, min(max_retry_delay, 0.5 * 2^attempt))
Key behaviors:
- Retry-After headers are respected on 429 responses (both numeric seconds and HTTP-date formats).
- POST and PATCH are only retried when idempotency keys are enabled, preventing duplicate mutations.
- Idempotency keys are auto-injected as UUIDs on POST/PATCH requests via the
Idempotency-Keyheader. - Set
max_retries=0to disable retries entirely.
Error handling
All API errors raise typed exceptions:
from myonlinestore import (
ConnectError, # base class
AuthenticationError, # 401/403
NotFoundError, # 404
ValidationError, # 422
RateLimitError, # 429 (includes retry_after attribute)
ServerError, # 5xx
)
try:
article = client.articles.get(article_id=99999)
except NotFoundError:
print("Article not found")
except RateLimitError as e:
print(f"Rate limited — retry after {e.retry_after}s")
except AuthenticationError:
print("Check your API token")
All exceptions carry status_code, body, and a compact __repr__ for logging.
Logging
The SDK logs via Python's standard logging module under the "myonlinestore" logger:
import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger("myonlinestore").setLevel(logging.DEBUG)
Log levels used:
- DEBUG — request method, URL, and (redacted) params
- INFO — retries, rate-limit pauses, Retry-After delays
Auth tokens are automatically redacted in all log output.
API version support
The SDK defaults to API v1. To use the v2-beta:
client = ConnectClient(store_token="xxx", api_version="2-beta")
Type safety
The SDK is fully typed with PEP 561 support (py.typed marker included). All models use Pydantic v2 with:
snake_casePython fields withcamelCasealiases for API compatibilityextra="ignore"to silently drop unknown fields (forward-compatible)- Compact
__repr__on all models showing only non-None fields
Works out of the box with mypy, pyright, and IDE autocomplete.
Requirements
- Python 3.10+
- httpx >=0.24.0, <1.0
- pydantic >=2.0.0, <3.0
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 myonlinestore_connect-1.0.1.tar.gz.
File metadata
- Download URL: myonlinestore_connect-1.0.1.tar.gz
- Upload date:
- Size: 33.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e12e314846db84713af8bd0cb4ac96e6041dcb3d844a177731902bbca709f71
|
|
| MD5 |
cfb812a3ec47ed1cfe9084ed269d928b
|
|
| BLAKE2b-256 |
850cebefca4ea542716983536345050af74e980cb4bff9a87dfd40a4d1a54fe0
|
Provenance
The following attestation bundles were made for myonlinestore_connect-1.0.1.tar.gz:
Publisher:
publish.yml on eibrahimov/myonlinestore-connect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
myonlinestore_connect-1.0.1.tar.gz -
Subject digest:
2e12e314846db84713af8bd0cb4ac96e6041dcb3d844a177731902bbca709f71 - Sigstore transparency entry: 1186780228
- Sigstore integration time:
-
Permalink:
eibrahimov/myonlinestore-connect@76f90b5c7892842e5e63963d23a31e0df7d7d897 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/eibrahimov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@76f90b5c7892842e5e63963d23a31e0df7d7d897 -
Trigger Event:
push
-
Statement type:
File details
Details for the file myonlinestore_connect-1.0.1-py3-none-any.whl.
File metadata
- Download URL: myonlinestore_connect-1.0.1-py3-none-any.whl
- Upload date:
- Size: 31.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ab77c8d1f338c0add1216a55270759459d3e9b453c627b3ec3d114d5c1ffc37
|
|
| MD5 |
ee4c90bfb36399dcb97a8fd5cc0228da
|
|
| BLAKE2b-256 |
5182c5d4223e9a114c20cf0835d03d3306e754e229018cb8fe1f7854a8fa9a20
|
Provenance
The following attestation bundles were made for myonlinestore_connect-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on eibrahimov/myonlinestore-connect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
myonlinestore_connect-1.0.1-py3-none-any.whl -
Subject digest:
6ab77c8d1f338c0add1216a55270759459d3e9b453c627b3ec3d114d5c1ffc37 - Sigstore transparency entry: 1186780245
- Sigstore integration time:
-
Permalink:
eibrahimov/myonlinestore-connect@76f90b5c7892842e5e63963d23a31e0df7d7d897 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/eibrahimov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@76f90b5c7892842e5e63963d23a31e0df7d7d897 -
Trigger Event:
push
-
Statement type: