viewrium 0.1.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.
- viewrium-2.1.0/.gitignore +58 -0
- viewrium-2.1.0/.python-version +1 -0
- viewrium-2.1.0/LICENSE +202 -0
- viewrium-2.1.0/PKG-INFO +316 -0
- viewrium-2.1.0/README.md +290 -0
- viewrium-2.1.0/package.json +13 -0
- viewrium-2.1.0/pyproject.toml +65 -0
- viewrium-2.1.0/src/viewrium/__init__.py +225 -0
- viewrium-2.1.0/src/viewrium/_client.py +485 -0
- viewrium-2.1.0/src/viewrium/_errors.py +103 -0
- viewrium-2.1.0/src/viewrium/_models.py +901 -0
- viewrium-2.1.0/src/viewrium/py.typed +0 -0
- viewrium-2.1.0/tests/test_client.py +361 -0
- viewrium-2.1.0/tests/test_import.py +5 -0
- viewrium-2.1.0/turbo.json +10 -0
- viewrium-2.1.0/uv.lock +476 -0
- viewrium-0.1.0/.gitignore +0 -52
- viewrium-0.1.0/CHANGELOG.md +0 -7
- viewrium-0.1.0/PKG-INFO +0 -164
- viewrium-0.1.0/README.md +0 -142
- viewrium-0.1.0/pyproject.toml +0 -34
- viewrium-0.1.0/viewrium/__init__.py +0 -94
- viewrium-0.1.0/viewrium/_client.py +0 -320
- viewrium-0.1.0/viewrium/_errors.py +0 -57
- viewrium-0.1.0/viewrium/_object.py +0 -45
- viewrium-0.1.0/viewrium/resources/__init__.py +0 -22
- viewrium-0.1.0/viewrium/resources/api_key.py +0 -66
- viewrium-0.1.0/viewrium/resources/model.py +0 -476
- viewrium-0.1.0/viewrium/resources/tag.py +0 -28
- viewrium-0.1.0/viewrium/resources/usage.py +0 -50
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
.venv/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
|
|
7
|
+
# Build outputs
|
|
8
|
+
dist/
|
|
9
|
+
.next/
|
|
10
|
+
out/
|
|
11
|
+
build/
|
|
12
|
+
*.tsbuildinfo
|
|
13
|
+
.source/
|
|
14
|
+
.turbo/
|
|
15
|
+
.vercel/
|
|
16
|
+
.workflow-data/
|
|
17
|
+
.playground/
|
|
18
|
+
# apps/web/scripts/embed-bundle.ts copies the built @repo/embed here at build time
|
|
19
|
+
apps/web/public/v1/
|
|
20
|
+
|
|
21
|
+
# Python tooling caches
|
|
22
|
+
.pytest_cache/
|
|
23
|
+
.mypy_cache/
|
|
24
|
+
.ruff_cache/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
|
|
27
|
+
# Test artifacts
|
|
28
|
+
coverage/
|
|
29
|
+
playwright-report/
|
|
30
|
+
test-results/
|
|
31
|
+
.drift-tmp/
|
|
32
|
+
|
|
33
|
+
# Env - only *.example files are committed
|
|
34
|
+
.env
|
|
35
|
+
.env.*
|
|
36
|
+
!.env.local.example
|
|
37
|
+
!.env.local.test.example
|
|
38
|
+
!.env.staging.local.example
|
|
39
|
+
|
|
40
|
+
# Editor / OS noise
|
|
41
|
+
.DS_Store
|
|
42
|
+
Thumbs.db
|
|
43
|
+
.idea/
|
|
44
|
+
*.swp
|
|
45
|
+
|
|
46
|
+
# credentials for the heinimex catalog experiment
|
|
47
|
+
notes/experiments/heinimex-catalog/.gdrive-key.json
|
|
48
|
+
|
|
49
|
+
# Next.js writes this file itself and rewrites it on every mode switch: `next build`
|
|
50
|
+
# points it at .next/types/routes.d.ts, `next dev` at .next/dev/types/routes.d.ts. Tracking
|
|
51
|
+
# it means a permanent phantom diff that flips whenever you run the other command. Every
|
|
52
|
+
# Next app here runs `next typegen` before `tsc` (see each package.json), and Vercel's build
|
|
53
|
+
# regenerates it too, so nothing ever reads a copy that git would have supplied.
|
|
54
|
+
next-env.d.ts
|
|
55
|
+
|
|
56
|
+
# Agent worktrees (Claude Code); never tracked, never committed - the directories are
|
|
57
|
+
# throwaway checkouts and their node_modules.
|
|
58
|
+
.claude/worktrees/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
viewrium-2.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Viewrium, Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
viewrium-2.1.0/PKG-INFO
ADDED
|
@@ -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
|