Python reference (tryyoursize)
Esta página aún no está disponible en tu idioma.
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.
Install
Section titled “Install”pip install tryyoursizenpm install @tryyoursize/nodeInitialize
Section titled “Initialize”import osimport tryyoursize
tys = tryyoursize.TryYourSize(os.environ["TRYYOURSIZE_SECRET_KEY"], max_retries=2, timeout=30.0)import TryYourSize from "@tryyoursize/node";
const tys = new TryYourSize(process.env.TRYYOURSIZE_SECRET_KEY!, { maxRetries: 2, // network errors, timeouts, 429, 5xx timeoutMs: 30_000,});Every method maps to one HTTP operation of the HTTP API reference. Errors are typed: see Errors and the API error codes.
Client
Section titled “Client”TryYourSize() |
Creates a client for one secret or restricted key. |
mode |
“test” or “live”, from the key prefix (“unknown” for other formats). |
Recommendations
Section titled “Recommendations”recommendations.create() |
The shopper’s size for up to 25 products (SKUs), from a browser SDK handle. |
Products
Section titled “Products”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
Section titled “Garments”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
Section titled “Fit groups”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. |
Outcomes
Section titled “Outcomes”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 log
Section titled “Audit log”audit_events.list() |
The audit log of the key’s organization, newest first. |
Webhooks
Section titled “Webhooks”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. |
Pagination and errors
Section titled “Pagination and errors”ListPage |
One page of a list. |
Errors |
Every exception is a TryYourSizeError. |
¿Te ha resultado útil esta página?
Gracias. Leemos todas las respuestas.