Skip to content

Python reference (tryyoursize)

SDKtryyoursizev0.1.0

The official Python SDK for the TryYourSize server API: no third-party dependencies (standard library only), Python 3.9+, fully typed (py.typed). Use it on your server with a secret key (sk_test_… / sk_live_…) or a restricted key (rk_…); publishable keys (pk_…) are refused. Responses are plain dicts typed with TypedDicts generated from our OpenAPI spec.

Terminal window
pip install tryyoursize
import os
import tryyoursize
tys = tryyoursize.TryYourSize(os.environ["TRYYOURSIZE_SECRET_KEY"], max_retries=2, timeout=30.0)

Every method maps to one HTTP operation of the HTTP API reference. Errors are typed: see Errors and the API error codes.

TryYourSize() Creates a client for one secret or restricted key.
mode “test” or “live”, from the key prefix (“unknown” for other formats).
recommendations.create() The shopper’s size for up to 25 products (SKUs), from a browser SDK handle.
products.list() The store’s products, newest first.
products.create() Create a product.
products.retrieve() A product by its TryYourSize ID or its SKU.
products.update() Replace the SKU, name and category (all three required).
products.size_map.retrieve() A product’s size map (Studio size → your size label).
products.size_map.save() Replace the size map, e.g.
products.garments.list() Garment versions of a product, newest first (has_more is always false).
products.garments.create_draft() Start a draft version: sizes, points of measure (mm) per size, grading, fabric.
garments.retrieve() A garment version.
garments.update_draft() Replace a draft’s content.
garments.publish() Publish a complete draft (same checks as Studio; 422 lists what is missing).
fit_groups.list() Fit groups, cursor-paginated.
fit_groups.create() Create a fit group: one garment shared by several products (colourways, prints).
fit_groups.retrieve() A fit group.
fit_groups.link_products() Move products into the fit group; they then use its garment.
orders.create() Record an order (idempotent by order id; re-sending updates it).
returns.create() Record a return of an order line (idempotent by return id and line).
audit_events.list() The audit log of the key’s organization, newest first.
Webhook.construct_event() Verify the signature, then return the parsed event envelope.
Webhook.verify_signature() Return True or raise SignatureVerificationError.
Webhook.generate_test_header() A valid TYS-Signature value, for your own tests.
ListPage One page of a list.
Errors Every exception is a TryYourSizeError.

Was this page helpful?