viewrium 2.0.0__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,7 @@ test-results/
35
35
  .env.*
36
36
  !.env.local.example
37
37
  !.env.local.test.example
38
+ !.env.staging.local.example
38
39
 
39
40
  # Editor / OS noise
40
41
  .DS_Store
@@ -0,0 +1,316 @@
1
+ Metadata-Version: 2.5
2
+ Name: viewrium
3
+ Version: 2.1.0
4
+ Summary: Official Python client for the Viewrium API: AR and 3D product visualization for furniture retailers.
5
+ Project-URL: Homepage, https://www.viewrium.com
6
+ Project-URL: Documentation, https://www.viewrium.com/docs/sdks/python
7
+ Project-URL: API reference, https://www.viewrium.com/docs/api-reference
8
+ Author: Viewrium
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: 3d,api-client,ar,augmented-reality,ecommerce,furniture,glb,product-visualization,sdk,viewrium
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Internet :: WWW/HTTP
19
+ Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.12
23
+ Requires-Dist: httpx>=0.28
24
+ Requires-Dist: pydantic>=2.7
25
+ Description-Content-Type: text/markdown
26
+
27
+ # viewrium
28
+
29
+ The official Python SDK for the [Viewrium](https://www.viewrium.com) API.
30
+
31
+ Viewrium is AR and 3D product visualization for furniture retailers: it turns product photos, a
32
+ video, a product page URL or an existing 3D file into catalog images, a GLB model and an
33
+ embeddable 3D/AR viewer. This package is a typed, synchronous client for the Viewrium `/v1` REST
34
+ API: create products, review and publish them, export images, manage webhooks and API keys, and
35
+ read usage analytics.
36
+
37
+ - Documentation: https://www.viewrium.com/docs
38
+ - SDK reference: https://www.viewrium.com/docs/sdks/python
39
+ - Dashboard: https://www.viewrium.com
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ pip install viewrium
45
+ ```
46
+
47
+ Or with uv:
48
+
49
+ ```bash
50
+ uv add viewrium
51
+ ```
52
+
53
+ Requires Python 3.12+. Requests and responses are pydantic v2 models.
54
+
55
+ ## Authentication
56
+
57
+ Every request is authenticated with an API key, sent as `Authorization: Bearer <key>`. The SDK
58
+ sets the header for you.
59
+
60
+ - **Secret keys (`sk_`)** are for servers. They can do everything their scopes allow. Never ship
61
+ one to a browser, a mobile app or a public repository. This SDK is meant for secret keys.
62
+ - **Publishable keys (`pk_`)** are safe in a browser but are origin-gated and limited to reading a
63
+ single published product, minting its model ticket and sending analytics beacons. An
64
+ organization with no allowed domains configured has its publishable keys refused everywhere. They power the
65
+ [`<viewrium-viewer>` embed](https://www.viewrium.com/docs/embed), which is how a model is shown on
66
+ a storefront.
67
+
68
+ Create keys in the dashboard under **Settings -> Advanced -> API keys**. A secret key is shown
69
+ exactly once, on create. See [Authentication](https://www.viewrium.com/docs/authentication) for
70
+ scopes.
71
+
72
+ ```python
73
+ import os
74
+
75
+ from viewrium import Viewrium
76
+
77
+ client = Viewrium(os.environ["VIEWRIUM_API_KEY"])
78
+ ```
79
+
80
+ Options:
81
+
82
+ ```python
83
+ client = Viewrium(
84
+ "sk_live_...",
85
+ base_url="https://api.viewrium.com", # default
86
+ timeout=30.0, # seconds; the default
87
+ )
88
+ ```
89
+
90
+ `products.create` runs the product analysis synchronously, which can take well over 30 seconds.
91
+ Pass a longer `timeout` (for example `timeout=300.0`) to a client that creates products.
92
+
93
+ The client is a context manager that closes its HTTP connection on exit:
94
+
95
+ ```python
96
+ with Viewrium("sk_live_...") as client:
97
+ page = client.products.list()
98
+ ```
99
+
100
+ ## Quickstart
101
+
102
+ `products.create` is the single generation entrypoint. Supply exactly one source: `image_urls`,
103
+ `video_url`, `source_url` (a product page) or `model_url` (an existing 3D file). Sources are URLs
104
+ that Viewrium fetches, so they must be publicly reachable.
105
+
106
+ A fresh request **parks**: it returns a `ProductParked` with the plan, the 3D model verdict, the
107
+ price in credits and a `resume_token`, and nothing is written. Posting the token back commits the
108
+ quote, starts the run and returns the `Product`.
109
+
110
+ ```python
111
+ import os
112
+ import time
113
+
114
+ from viewrium import (
115
+ ModelDimensions,
116
+ ProductCreateRequest,
117
+ ProductDraft,
118
+ ProductParked,
119
+ ProductUpdateRequest,
120
+ Viewrium,
121
+ )
122
+
123
+ with Viewrium(os.environ["VIEWRIUM_API_KEY"], timeout=300.0) as client:
124
+ # 1. Quote
125
+ result = client.products.create(
126
+ ProductCreateRequest(
127
+ image_urls=[
128
+ "https://cdn.example.com/chair-front.jpg",
129
+ "https://cdn.example.com/chair-side.jpg",
130
+ ],
131
+ draft=ProductDraft(
132
+ title="Oak dining chair",
133
+ custom_id="sku-oak-chair",
134
+ dimensions=ModelDimensions(height=92),
135
+ ),
136
+ )
137
+ )
138
+
139
+ # 2. Commit
140
+ if isinstance(result, ProductParked):
141
+ print(result.cost.total_credits, len(result.plan), result.model.allowed)
142
+ result = client.products.create(ProductCreateRequest(resume_token=result.resume_token))
143
+ assert not isinstance(result, ProductParked) # a resume always commits
144
+
145
+ # 3. Wait for the run (prefer webhooks in production)
146
+ product = result
147
+ while product.display_status == "generating":
148
+ time.sleep(5)
149
+ product = client.products.retrieve(product.id)
150
+ print(product.display_status, product.model.status if product.model else None)
151
+
152
+ # 4. Publish
153
+ client.products.update(product.id, ProductUpdateRequest(published=True))
154
+ ```
155
+
156
+ A resume may still edit the `draft` (title, price, tags, dimensions). It may not change the order
157
+ or the overrides: the quote is immutable, and changing what gets generated means a new request.
158
+ A `resume_token` expires after 7 days. A `model_url` source never parks; it commits straight away.
159
+
160
+ Only the fields you set on a request model are sent, so an explicit `None` (for example on an
161
+ image patch, where it clears an override) is different from leaving a field out.
162
+
163
+ See [How generation works](https://www.viewrium.com/docs/generation) and
164
+ [the quote and commit guide](https://www.viewrium.com/docs/guides/quote-and-commit).
165
+
166
+ ## Resources
167
+
168
+ | Resource | Methods |
169
+ |---|---|
170
+ | `client.products` | `create`, `list`, `retrieve`, `update`, `delete`, `batch_delete`, `publish`, `tags`, `review`, `update_image`, `update_model`, `rescale`, `create_ticket`, `order`, `export` |
171
+ | `client.api_keys` | `list`, `create`, `revoke` |
172
+ | `client.usage` | `get` |
173
+ | `client.webhooks` | `list`, `create`, `retrieve`, `update`, `delete`, `list_deliveries` |
174
+ | `client.projects` | `list`, `retrieve` |
175
+ | `client.beacon` | `send` |
176
+ | `client` | `health()` |
177
+
178
+ Request models (`ProductCreateRequest`, `ProductDraft`, `ProductUpdateRequest`, `ProductFilters`,
179
+ `WebhookEndpointCreateRequest`, ...), response models (`Product`, `ProductParked`, `ModelPlan`,
180
+ `ProductCost`, `UsageResponse`, ...) and enums (`DisplayStatus`, `ListScope`, `ProductSortField`,
181
+ `SortOrder`, `UsageEventType`, ...) are all importable from the top-level `viewrium` package.
182
+
183
+ ### Showing a model: tickets
184
+
185
+ No response carries a URL for a 3D model file - not the product, not a webhook. The only way to a
186
+ model's bytes is a **ticket**: a single-use URL that serves the GLB once and expires within a
187
+ minute (60 s for `view`, 30 s for `ar`). Mint one right before the viewer loads and hand the URL
188
+ straight to the page; never store it.
189
+
190
+ ```python
191
+ from viewrium import TicketKind, TicketRequest
192
+
193
+ ticket = client.products.create_ticket(
194
+ product_id,
195
+ # the page that will load the model; one of your allowed domains
196
+ TicketRequest(kind=TicketKind.VIEW, origin="https://shop.example.com"),
197
+ )
198
+ print(ticket.url, ticket.expires_at)
199
+ ```
200
+
201
+ A `view` ticket streams only to a request from its `origin`. An `ar` ticket is for Android's Scene
202
+ Viewer, which downloads the file outside the page: mint it on the AR tap. Minting is rate limited
203
+ per IP and per product (429).
204
+
205
+ ### Listing and filtering
206
+
207
+ The catalog filters are one `ProductFilters` object, shared by `list`, `tags` and `export`. Paging
208
+ and sorting are keyword arguments on `list`.
209
+
210
+ ```python
211
+ from viewrium import DisplayStatus, ProductFilters, ProductSortField, SortOrder
212
+
213
+ page = client.products.list(
214
+ ProductFilters(status=[DisplayStatus.PUBLISHED], tag=["chairs"], q="oak"),
215
+ limit=50,
216
+ sort=ProductSortField.CREATED_AT,
217
+ order=SortOrder.DESC,
218
+ )
219
+ for product in page.data:
220
+ print(product.id, product.title, product.display_status)
221
+ ```
222
+
223
+ ### Exporting images
224
+
225
+ `products.export` returns a ZIP of finished images as bytes (the 3D model is never included).
226
+ When more images need finishing than one request can do, it returns a `ProductExportQueued`
227
+ instead: the images are finished in the background, a download link is emailed, and the same call
228
+ returns the archive once they are done.
229
+
230
+ ```python
231
+ from viewrium import ProductExportQueued, ProductFilters
232
+
233
+ archive = client.products.export(ProductFilters(tag=["chairs"]))
234
+ if isinstance(archive, ProductExportQueued):
235
+ print("finishing", archive.to_finish, "images; a link goes to", archive.notify_email)
236
+ else:
237
+ with open("catalog.zip", "wb") as f:
238
+ f.write(archive)
239
+ ```
240
+
241
+ ### Analytics
242
+
243
+ ```python
244
+ from datetime import UTC, datetime, timedelta
245
+
246
+ end = datetime.now(UTC)
247
+ usage = client.usage.get(
248
+ start=end - timedelta(days=90),
249
+ end=end,
250
+ granularity="day",
251
+ group_by="product",
252
+ )
253
+ for row in usage.by_product:
254
+ print(row.title, row.totals)
255
+ ```
256
+
257
+ Traffic from your own team is excluded unless you pass `include_internal=True`.
258
+
259
+ ## Errors
260
+
261
+ Non-2xx responses raise a `ViewriumError` subclass. Every error exposes `status`, `code`,
262
+ `message` and `details` from the API's error envelope.
263
+
264
+ ```python
265
+ from viewrium import (
266
+ APIConnectionError,
267
+ AuthenticationError,
268
+ ConflictError,
269
+ PaymentRequiredError,
270
+ ProductCreateRequest,
271
+ RateLimitError,
272
+ ViewriumError,
273
+ )
274
+
275
+ try:
276
+ client.products.create(ProductCreateRequest(image_urls=["https://cdn.example.com/chair.jpg"]))
277
+ except AuthenticationError:
278
+ ... # 401: missing or invalid key
279
+ except PaymentRequiredError as err:
280
+ ... # 402: the plan does not allow this; err.details["reason"] says why
281
+ except ConflictError:
282
+ ... # 409: e.g. a duplicate custom_id or a replayed resume_token
283
+ except RateLimitError:
284
+ ... # 429: rate limited, or code "quota_exceeded" when credits run out
285
+ except APIConnectionError:
286
+ ... # the request never reached the API, or timed out
287
+ except ViewriumError as err:
288
+ print(err.status, err.code, err.message, err.details)
289
+ ```
290
+
291
+ | HTTP | Exception |
292
+ |---|---|
293
+ | 400 | `BadRequestError` |
294
+ | 401 | `AuthenticationError` |
295
+ | 402 | `PaymentRequiredError` |
296
+ | 403 | `PermissionDeniedError` |
297
+ | 404 | `NotFoundError` |
298
+ | 409 | `ConflictError` |
299
+ | 422 | `UnprocessableEntityError` |
300
+ | 429 | `RateLimitError` |
301
+ | 5xx | `ServerError` |
302
+ | none | `APIConnectionError` |
303
+
304
+ The SDK does not retry. On a `RateLimitError`, back off and retry with an exponential delay.
305
+
306
+ ## Links
307
+
308
+ - [Quickstart](https://www.viewrium.com/docs/quickstart)
309
+ - [Python SDK reference](https://www.viewrium.com/docs/sdks/python)
310
+ - [Webhooks](https://www.viewrium.com/docs/webhooks)
311
+ - [API reference](https://www.viewrium.com/docs/api-reference)
312
+ - Support: support@viewrium.com
313
+
314
+ ## License
315
+
316
+ Apache-2.0
@@ -0,0 +1,290 @@
1
+ # viewrium
2
+
3
+ The official Python SDK for the [Viewrium](https://www.viewrium.com) API.
4
+
5
+ Viewrium is AR and 3D product visualization for furniture retailers: it turns product photos, a
6
+ video, a product page URL or an existing 3D file into catalog images, a GLB model and an
7
+ embeddable 3D/AR viewer. This package is a typed, synchronous client for the Viewrium `/v1` REST
8
+ API: create products, review and publish them, export images, manage webhooks and API keys, and
9
+ read usage analytics.
10
+
11
+ - Documentation: https://www.viewrium.com/docs
12
+ - SDK reference: https://www.viewrium.com/docs/sdks/python
13
+ - Dashboard: https://www.viewrium.com
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install viewrium
19
+ ```
20
+
21
+ Or with uv:
22
+
23
+ ```bash
24
+ uv add viewrium
25
+ ```
26
+
27
+ Requires Python 3.12+. Requests and responses are pydantic v2 models.
28
+
29
+ ## Authentication
30
+
31
+ Every request is authenticated with an API key, sent as `Authorization: Bearer <key>`. The SDK
32
+ sets the header for you.
33
+
34
+ - **Secret keys (`sk_`)** are for servers. They can do everything their scopes allow. Never ship
35
+ one to a browser, a mobile app or a public repository. This SDK is meant for secret keys.
36
+ - **Publishable keys (`pk_`)** are safe in a browser but are origin-gated and limited to reading a
37
+ single published product, minting its model ticket and sending analytics beacons. An
38
+ organization with no allowed domains configured has its publishable keys refused everywhere. They power the
39
+ [`<viewrium-viewer>` embed](https://www.viewrium.com/docs/embed), which is how a model is shown on
40
+ a storefront.
41
+
42
+ Create keys in the dashboard under **Settings -> Advanced -> API keys**. A secret key is shown
43
+ exactly once, on create. See [Authentication](https://www.viewrium.com/docs/authentication) for
44
+ scopes.
45
+
46
+ ```python
47
+ import os
48
+
49
+ from viewrium import Viewrium
50
+
51
+ client = Viewrium(os.environ["VIEWRIUM_API_KEY"])
52
+ ```
53
+
54
+ Options:
55
+
56
+ ```python
57
+ client = Viewrium(
58
+ "sk_live_...",
59
+ base_url="https://api.viewrium.com", # default
60
+ timeout=30.0, # seconds; the default
61
+ )
62
+ ```
63
+
64
+ `products.create` runs the product analysis synchronously, which can take well over 30 seconds.
65
+ Pass a longer `timeout` (for example `timeout=300.0`) to a client that creates products.
66
+
67
+ The client is a context manager that closes its HTTP connection on exit:
68
+
69
+ ```python
70
+ with Viewrium("sk_live_...") as client:
71
+ page = client.products.list()
72
+ ```
73
+
74
+ ## Quickstart
75
+
76
+ `products.create` is the single generation entrypoint. Supply exactly one source: `image_urls`,
77
+ `video_url`, `source_url` (a product page) or `model_url` (an existing 3D file). Sources are URLs
78
+ that Viewrium fetches, so they must be publicly reachable.
79
+
80
+ A fresh request **parks**: it returns a `ProductParked` with the plan, the 3D model verdict, the
81
+ price in credits and a `resume_token`, and nothing is written. Posting the token back commits the
82
+ quote, starts the run and returns the `Product`.
83
+
84
+ ```python
85
+ import os
86
+ import time
87
+
88
+ from viewrium import (
89
+ ModelDimensions,
90
+ ProductCreateRequest,
91
+ ProductDraft,
92
+ ProductParked,
93
+ ProductUpdateRequest,
94
+ Viewrium,
95
+ )
96
+
97
+ with Viewrium(os.environ["VIEWRIUM_API_KEY"], timeout=300.0) as client:
98
+ # 1. Quote
99
+ result = client.products.create(
100
+ ProductCreateRequest(
101
+ image_urls=[
102
+ "https://cdn.example.com/chair-front.jpg",
103
+ "https://cdn.example.com/chair-side.jpg",
104
+ ],
105
+ draft=ProductDraft(
106
+ title="Oak dining chair",
107
+ custom_id="sku-oak-chair",
108
+ dimensions=ModelDimensions(height=92),
109
+ ),
110
+ )
111
+ )
112
+
113
+ # 2. Commit
114
+ if isinstance(result, ProductParked):
115
+ print(result.cost.total_credits, len(result.plan), result.model.allowed)
116
+ result = client.products.create(ProductCreateRequest(resume_token=result.resume_token))
117
+ assert not isinstance(result, ProductParked) # a resume always commits
118
+
119
+ # 3. Wait for the run (prefer webhooks in production)
120
+ product = result
121
+ while product.display_status == "generating":
122
+ time.sleep(5)
123
+ product = client.products.retrieve(product.id)
124
+ print(product.display_status, product.model.status if product.model else None)
125
+
126
+ # 4. Publish
127
+ client.products.update(product.id, ProductUpdateRequest(published=True))
128
+ ```
129
+
130
+ A resume may still edit the `draft` (title, price, tags, dimensions). It may not change the order
131
+ or the overrides: the quote is immutable, and changing what gets generated means a new request.
132
+ A `resume_token` expires after 7 days. A `model_url` source never parks; it commits straight away.
133
+
134
+ Only the fields you set on a request model are sent, so an explicit `None` (for example on an
135
+ image patch, where it clears an override) is different from leaving a field out.
136
+
137
+ See [How generation works](https://www.viewrium.com/docs/generation) and
138
+ [the quote and commit guide](https://www.viewrium.com/docs/guides/quote-and-commit).
139
+
140
+ ## Resources
141
+
142
+ | Resource | Methods |
143
+ |---|---|
144
+ | `client.products` | `create`, `list`, `retrieve`, `update`, `delete`, `batch_delete`, `publish`, `tags`, `review`, `update_image`, `update_model`, `rescale`, `create_ticket`, `order`, `export` |
145
+ | `client.api_keys` | `list`, `create`, `revoke` |
146
+ | `client.usage` | `get` |
147
+ | `client.webhooks` | `list`, `create`, `retrieve`, `update`, `delete`, `list_deliveries` |
148
+ | `client.projects` | `list`, `retrieve` |
149
+ | `client.beacon` | `send` |
150
+ | `client` | `health()` |
151
+
152
+ Request models (`ProductCreateRequest`, `ProductDraft`, `ProductUpdateRequest`, `ProductFilters`,
153
+ `WebhookEndpointCreateRequest`, ...), response models (`Product`, `ProductParked`, `ModelPlan`,
154
+ `ProductCost`, `UsageResponse`, ...) and enums (`DisplayStatus`, `ListScope`, `ProductSortField`,
155
+ `SortOrder`, `UsageEventType`, ...) are all importable from the top-level `viewrium` package.
156
+
157
+ ### Showing a model: tickets
158
+
159
+ No response carries a URL for a 3D model file - not the product, not a webhook. The only way to a
160
+ model's bytes is a **ticket**: a single-use URL that serves the GLB once and expires within a
161
+ minute (60 s for `view`, 30 s for `ar`). Mint one right before the viewer loads and hand the URL
162
+ straight to the page; never store it.
163
+
164
+ ```python
165
+ from viewrium import TicketKind, TicketRequest
166
+
167
+ ticket = client.products.create_ticket(
168
+ product_id,
169
+ # the page that will load the model; one of your allowed domains
170
+ TicketRequest(kind=TicketKind.VIEW, origin="https://shop.example.com"),
171
+ )
172
+ print(ticket.url, ticket.expires_at)
173
+ ```
174
+
175
+ A `view` ticket streams only to a request from its `origin`. An `ar` ticket is for Android's Scene
176
+ Viewer, which downloads the file outside the page: mint it on the AR tap. Minting is rate limited
177
+ per IP and per product (429).
178
+
179
+ ### Listing and filtering
180
+
181
+ The catalog filters are one `ProductFilters` object, shared by `list`, `tags` and `export`. Paging
182
+ and sorting are keyword arguments on `list`.
183
+
184
+ ```python
185
+ from viewrium import DisplayStatus, ProductFilters, ProductSortField, SortOrder
186
+
187
+ page = client.products.list(
188
+ ProductFilters(status=[DisplayStatus.PUBLISHED], tag=["chairs"], q="oak"),
189
+ limit=50,
190
+ sort=ProductSortField.CREATED_AT,
191
+ order=SortOrder.DESC,
192
+ )
193
+ for product in page.data:
194
+ print(product.id, product.title, product.display_status)
195
+ ```
196
+
197
+ ### Exporting images
198
+
199
+ `products.export` returns a ZIP of finished images as bytes (the 3D model is never included).
200
+ When more images need finishing than one request can do, it returns a `ProductExportQueued`
201
+ instead: the images are finished in the background, a download link is emailed, and the same call
202
+ returns the archive once they are done.
203
+
204
+ ```python
205
+ from viewrium import ProductExportQueued, ProductFilters
206
+
207
+ archive = client.products.export(ProductFilters(tag=["chairs"]))
208
+ if isinstance(archive, ProductExportQueued):
209
+ print("finishing", archive.to_finish, "images; a link goes to", archive.notify_email)
210
+ else:
211
+ with open("catalog.zip", "wb") as f:
212
+ f.write(archive)
213
+ ```
214
+
215
+ ### Analytics
216
+
217
+ ```python
218
+ from datetime import UTC, datetime, timedelta
219
+
220
+ end = datetime.now(UTC)
221
+ usage = client.usage.get(
222
+ start=end - timedelta(days=90),
223
+ end=end,
224
+ granularity="day",
225
+ group_by="product",
226
+ )
227
+ for row in usage.by_product:
228
+ print(row.title, row.totals)
229
+ ```
230
+
231
+ Traffic from your own team is excluded unless you pass `include_internal=True`.
232
+
233
+ ## Errors
234
+
235
+ Non-2xx responses raise a `ViewriumError` subclass. Every error exposes `status`, `code`,
236
+ `message` and `details` from the API's error envelope.
237
+
238
+ ```python
239
+ from viewrium import (
240
+ APIConnectionError,
241
+ AuthenticationError,
242
+ ConflictError,
243
+ PaymentRequiredError,
244
+ ProductCreateRequest,
245
+ RateLimitError,
246
+ ViewriumError,
247
+ )
248
+
249
+ try:
250
+ client.products.create(ProductCreateRequest(image_urls=["https://cdn.example.com/chair.jpg"]))
251
+ except AuthenticationError:
252
+ ... # 401: missing or invalid key
253
+ except PaymentRequiredError as err:
254
+ ... # 402: the plan does not allow this; err.details["reason"] says why
255
+ except ConflictError:
256
+ ... # 409: e.g. a duplicate custom_id or a replayed resume_token
257
+ except RateLimitError:
258
+ ... # 429: rate limited, or code "quota_exceeded" when credits run out
259
+ except APIConnectionError:
260
+ ... # the request never reached the API, or timed out
261
+ except ViewriumError as err:
262
+ print(err.status, err.code, err.message, err.details)
263
+ ```
264
+
265
+ | HTTP | Exception |
266
+ |---|---|
267
+ | 400 | `BadRequestError` |
268
+ | 401 | `AuthenticationError` |
269
+ | 402 | `PaymentRequiredError` |
270
+ | 403 | `PermissionDeniedError` |
271
+ | 404 | `NotFoundError` |
272
+ | 409 | `ConflictError` |
273
+ | 422 | `UnprocessableEntityError` |
274
+ | 429 | `RateLimitError` |
275
+ | 5xx | `ServerError` |
276
+ | none | `APIConnectionError` |
277
+
278
+ The SDK does not retry. On a `RateLimitError`, back off and retry with an exponential delay.
279
+
280
+ ## Links
281
+
282
+ - [Quickstart](https://www.viewrium.com/docs/quickstart)
283
+ - [Python SDK reference](https://www.viewrium.com/docs/sdks/python)
284
+ - [Webhooks](https://www.viewrium.com/docs/webhooks)
285
+ - [API reference](https://www.viewrium.com/docs/api-reference)
286
+ - Support: support@viewrium.com
287
+
288
+ ## License
289
+
290
+ Apache-2.0
@@ -0,0 +1,65 @@
1
+ [project]
2
+ name = "viewrium"
3
+ version = "2.1.0"
4
+ description = "Official Python client for the Viewrium API: AR and 3D product visualization for furniture retailers."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Viewrium" }]
9
+ requires-python = ">=3.12"
10
+ keywords = [
11
+ "viewrium",
12
+ "sdk",
13
+ "api-client",
14
+ "3d",
15
+ "ar",
16
+ "augmented-reality",
17
+ "glb",
18
+ "product-visualization",
19
+ "furniture",
20
+ "ecommerce",
21
+ ]
22
+ classifiers = [
23
+ "Development Status :: 5 - Production/Stable",
24
+ "Intended Audience :: Developers",
25
+ "Operating System :: OS Independent",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3 :: Only",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Topic :: Internet :: WWW/HTTP",
30
+ "Topic :: Multimedia :: Graphics :: 3D Modeling",
31
+ "Topic :: Software Development :: Libraries :: Python Modules",
32
+ "Typing :: Typed",
33
+ ]
34
+ dependencies = ["httpx>=0.28", "pydantic>=2.7"]
35
+
36
+ [project.urls]
37
+ Homepage = "https://www.viewrium.com"
38
+ Documentation = "https://www.viewrium.com/docs/sdks/python"
39
+ "API reference" = "https://www.viewrium.com/docs/api-reference"
40
+
41
+ [dependency-groups]
42
+ dev = ["pytest>=9.1", "ruff>=0.15", "mypy>=2.3"]
43
+
44
+ [build-system]
45
+ requires = ["hatchling"]
46
+ build-backend = "hatchling.build"
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/viewrium"]
50
+
51
+ [tool.ruff]
52
+ line-length = 100
53
+ target-version = "py312"
54
+ src = ["src"]
55
+
56
+ [tool.ruff.lint]
57
+ select = ["E", "F", "I", "UP", "B"]
58
+
59
+ [tool.mypy]
60
+ python_version = "3.12"
61
+ strict = true
62
+ files = ["src"]
63
+
64
+ [tool.pytest.ini_options]
65
+ testpaths = ["tests"]
@@ -98,6 +98,9 @@ from ._models import (
98
98
  TagCount,
99
99
  TagMatch,
100
100
  TagsResponse,
101
+ Ticket,
102
+ TicketKind,
103
+ TicketRequest,
101
104
  UsageBucket,
102
105
  UsageDuration,
103
106
  UsageEventType,
@@ -115,7 +118,7 @@ from ._models import (
115
118
  WidthAxis,
116
119
  )
117
120
 
118
- __version__ = "2.0.0"
121
+ __version__ = "2.1.0"
119
122
 
120
123
  __all__ = [
121
124
  "__version__",
@@ -208,6 +211,9 @@ __all__ = [
208
211
  "UsageResponse",
209
212
  "TagCount",
210
213
  "TagsResponse",
214
+ "Ticket",
215
+ "TicketKind",
216
+ "TicketRequest",
211
217
  "WebhookEndpoint",
212
218
  "WebhookEndpointListResponse",
213
219
  "WebhookEndpointCreateResponse",
@@ -48,6 +48,8 @@ from ._models import (
48
48
  ReviewStatus,
49
49
  SortOrder,
50
50
  TagsResponse,
51
+ Ticket,
52
+ TicketRequest,
51
53
  UsageEventType,
52
54
  UsageResponse,
53
55
  WebhookDeliveryListResponse,
@@ -315,6 +317,14 @@ class ProductsResource:
315
317
  "POST", f"/v1/products/{product_id}/model/rescale", Product, json=_body(request)
316
318
  )
317
319
 
320
+ def create_ticket(self, product_id: str, request: TicketRequest) -> Ticket:
321
+ """POST /v1/products/{id}/tickets - a single-use URL for the product's 3D file, the ONLY
322
+ way to its bytes (no response carries a model file URL). It works once, until
323
+ ``expires_at``. With a secret key, pass ``origin``: the page that will load the model."""
324
+ return self._client.request(
325
+ "POST", f"/v1/products/{product_id}/tickets", Ticket, json=_body(request)
326
+ )
327
+
318
328
  def order(self, product_id: str, request: ProductOrderRequest) -> ProductOrderParked:
319
329
  """POST /v1/products/{id}/order - order the missing half. It PARKS: commit the
320
330
  returned token with ``create``."""
@@ -288,6 +288,23 @@ class ProductRescaleRequest(_Base):
288
288
  width_axis: WidthAxis | None = None
289
289
 
290
290
 
291
+ class TicketKind(StrEnum):
292
+ """What a model ticket is for: ``view`` (the page itself) or ``ar`` (Android's Scene Viewer,
293
+ which downloads the file outside the page)."""
294
+
295
+ VIEW = "view"
296
+ AR = "ar"
297
+
298
+
299
+ class TicketRequest(_Base):
300
+ """``products.create_ticket`` body. ``origin`` is for a SERVER minting on a page's behalf
301
+ (a secret key): the origin of the page that will load the model, one of your allowed
302
+ domains. A publishable-key ticket is bound to the request's own Origin instead."""
303
+
304
+ kind: TicketKind
305
+ origin: str | None = None
306
+
307
+
291
308
  class ProductOrderRequest(_Base):
292
309
  """POST /v1/products/{id}/order - order the missing half (images onto a model-only
293
310
  product, or a model onto an images one). It PARKS: the additions and their cost come back
@@ -594,12 +611,12 @@ class ProductImage(_Base):
594
611
 
595
612
 
596
613
  class ProductModel(_Base):
597
- """The product's 3D model row."""
614
+ """The product's 3D model row. It carries NO file URL: the bytes are reached only through a
615
+ single-use ticket, ``products.create_ticket``."""
598
616
 
599
617
  id: str
600
618
  status: AssetStatus
601
619
  review_status: ReviewStatus = ReviewStatus.PENDING
602
- glb_url: str | None = None
603
620
  thumbnail_url: str | None = None
604
621
  scale_factor: float | None = None
605
622
  width_axis: WidthAxis | None = None
@@ -689,13 +706,23 @@ class Product(ProductSummary):
689
706
  class PublicProduct(_Base):
690
707
  """What a PUBLISHABLE key receives from ``products.retrieve`` - an explicit allow-list,
691
708
  because pk keys ship inside the embed in browser-visible JS. Only a PUBLISHED product with
692
- a READY model is served at all."""
709
+ a READY model is served at all. The model file is reached through ``products.create_ticket``."""
693
710
 
694
711
  id: str
695
712
  title: str
696
- model_url: str | None = None
697
713
  thumbnail_url: str | None = None
698
714
  model_status: AssetStatus | None = None
715
+ wall_mounted: bool = False
716
+
717
+
718
+ class Ticket(_Base):
719
+ """A single-use URL for the product's 3D file (``model/gltf-binary``). It works ONCE, until
720
+ ``expires_at`` (60 s for ``view``, 30 s for ``ar``), and a ``view`` ticket only from its bound
721
+ origin. Hand it to the viewer at once; never store it."""
722
+
723
+ url: str
724
+ kind: TicketKind
725
+ expires_at: datetime
699
726
 
700
727
 
701
728
  class ProductListResponse(_Base):
@@ -30,6 +30,8 @@ from viewrium import (
30
30
  ProductRescaleRequest,
31
31
  ProductStatus,
32
32
  ReviewStatus,
33
+ TicketKind,
34
+ TicketRequest,
33
35
  UnprocessableEntityError,
34
36
  Viewrium,
35
37
  ViewriumError,
@@ -170,6 +172,24 @@ def test_rescale_sends_an_explicit_width_axis() -> None:
170
172
  assert json.loads(rec.request.content) == {"width": 100.0, "width_axis": "x"}
171
173
 
172
174
 
175
+ def test_create_ticket_posts_the_kind_and_origin_and_parses_the_ticket() -> None:
176
+ body = {
177
+ "url": "https://api.viewrium.com/m/t",
178
+ "kind": "ar",
179
+ "expires_at": "2026-10-16T12:00:00Z",
180
+ }
181
+ client, rec = make_client(httpx.Response(200, json=body))
182
+ ticket = client.products.create_ticket(
183
+ "p1", TicketRequest(kind=TicketKind.AR, origin="https://shop.example.com")
184
+ )
185
+
186
+ assert rec.request is not None
187
+ assert str(rec.request.url) == "https://api.viewrium.com/v1/products/p1/tickets"
188
+ assert json.loads(rec.request.content) == {"kind": "ar", "origin": "https://shop.example.com"}
189
+ assert ticket.kind is TicketKind.AR
190
+ assert ticket.url == "https://api.viewrium.com/m/t"
191
+
192
+
173
193
  def test_products_list_serializes_the_catalog_filters() -> None:
174
194
  body = {"data": [], "total": 0, "limit": 50, "offset": 0}
175
195
  client, rec = make_client(httpx.Response(200, json=body))
@@ -2,4 +2,4 @@ import viewrium
2
2
 
3
3
 
4
4
  def test_import() -> None:
5
- assert viewrium.__version__ == "2.0.0"
5
+ assert viewrium.__version__ == "2.1.0"
@@ -448,7 +448,7 @@ wheels = [
448
448
 
449
449
  [[package]]
450
450
  name = "viewrium"
451
- version = "2.0.0"
451
+ version = "2.1.0"
452
452
  source = { editable = "." }
453
453
  dependencies = [
454
454
  { name = "httpx" },
viewrium-2.0.0/PKG-INFO DELETED
@@ -1,17 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: viewrium
3
- Version: 2.0.0
4
- Summary: Official Viewrium Python SDK
5
- License-Expression: Apache-2.0
6
- License-File: LICENSE
7
- Requires-Python: >=3.12
8
- Requires-Dist: httpx>=0.28
9
- Requires-Dist: pydantic>=2.7
10
- Description-Content-Type: text/markdown
11
-
12
- # viewrium (Python SDK)
13
-
14
- Published `viewrium` on PyPI. Standalone uv project - `pyproject.toml` is the real config; the
15
- `package.json` here is only a Turborepo shim (lint/typecheck/test/build via `uv run`).
16
-
17
- Published by `.github/workflows/publish-sdk-python.yml` (`uv build` + PyPI publish).
viewrium-2.0.0/README.md DELETED
@@ -1,6 +0,0 @@
1
- # viewrium (Python SDK)
2
-
3
- Published `viewrium` on PyPI. Standalone uv project - `pyproject.toml` is the real config; the
4
- `package.json` here is only a Turborepo shim (lint/typecheck/test/build via `uv run`).
5
-
6
- Published by `.github/workflows/publish-sdk-python.yml` (`uv build` + PyPI publish).
@@ -1,35 +0,0 @@
1
- [project]
2
- name = "viewrium"
3
- version = "2.0.0"
4
- description = "Official Viewrium Python SDK"
5
- readme = "README.md"
6
- license = "Apache-2.0"
7
- license-files = ["LICENSE"]
8
- requires-python = ">=3.12"
9
- dependencies = ["httpx>=0.28", "pydantic>=2.7"]
10
-
11
- [dependency-groups]
12
- dev = ["pytest>=9.1", "ruff>=0.15", "mypy>=2.3"]
13
-
14
- [build-system]
15
- requires = ["hatchling"]
16
- build-backend = "hatchling.build"
17
-
18
- [tool.hatch.build.targets.wheel]
19
- packages = ["src/viewrium"]
20
-
21
- [tool.ruff]
22
- line-length = 100
23
- target-version = "py312"
24
- src = ["src"]
25
-
26
- [tool.ruff.lint]
27
- select = ["E", "F", "I", "UP", "B"]
28
-
29
- [tool.mypy]
30
- python_version = "3.12"
31
- strict = true
32
- files = ["src"]
33
-
34
- [tool.pytest.ini_options]
35
- testpaths = ["tests"]
File without changes
File without changes
File without changes
File without changes
File without changes