sudomock 0.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.
- sudomock-0.1.0/.gitignore +32 -0
- sudomock-0.1.0/LICENSE +21 -0
- sudomock-0.1.0/PKG-INFO +254 -0
- sudomock-0.1.0/README.md +216 -0
- sudomock-0.1.0/pyproject.toml +91 -0
- sudomock-0.1.0/src/sudomock/__init__.py +88 -0
- sudomock-0.1.0/src/sudomock/_http.py +247 -0
- sudomock-0.1.0/src/sudomock/async_client.py +288 -0
- sudomock-0.1.0/src/sudomock/client.py +297 -0
- sudomock-0.1.0/src/sudomock/exceptions.py +99 -0
- sudomock-0.1.0/src/sudomock/models.py +186 -0
- sudomock-0.1.0/src/sudomock/py.typed +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
|
|
7
|
+
# Distribution / packaging
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
*.egg
|
|
12
|
+
|
|
13
|
+
# Virtual environments
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
env/
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.idea/
|
|
20
|
+
.vscode/
|
|
21
|
+
*.swp
|
|
22
|
+
*.swo
|
|
23
|
+
|
|
24
|
+
# Testing
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.coverage
|
|
27
|
+
htmlcov/
|
|
28
|
+
.mypy_cache/
|
|
29
|
+
|
|
30
|
+
# OS
|
|
31
|
+
.DS_Store
|
|
32
|
+
Thumbs.db
|
sudomock-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SudoMock Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
sudomock-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sudomock
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the SudoMock Mockup Generator API
|
|
5
|
+
Project-URL: Homepage, https://sudomock.com
|
|
6
|
+
Project-URL: Documentation, https://docs.sudomock.com
|
|
7
|
+
Project-URL: Repository, https://github.com/sudomock/sudomock-python
|
|
8
|
+
Project-URL: Issues, https://github.com/sudomock/sudomock-python/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/sudomock/sudomock-python/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: SudoMock Labs <hello@sudomock.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: api,mockup,product-mockup,psd,sdk,sudomock
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Requires-Dist: httpx<1.0.0,>=0.27.0
|
|
28
|
+
Requires-Dist: pydantic<3.0.0,>=2.7.0
|
|
29
|
+
Requires-Dist: tenacity<10.0.0,>=9.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: coverage>=7.6.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: mypy>=1.13.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest>=8.3.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: respx>=0.22.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# SudoMock Python SDK
|
|
40
|
+
|
|
41
|
+
Official Python client for the [SudoMock](https://sudomock.com) Mockup Generator API.
|
|
42
|
+
|
|
43
|
+
Generate photorealistic product mockups from PSD templates or AI-powered rendering -- all from your Python code.
|
|
44
|
+
|
|
45
|
+
[](https://pypi.org/project/sudomock/)
|
|
46
|
+
[](https://pypi.org/project/sudomock/)
|
|
47
|
+
[](LICENSE)
|
|
48
|
+
[](https://github.com/sudomock/sudomock-python/actions)
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install sudomock
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from sudomock import SudoMock
|
|
60
|
+
|
|
61
|
+
# 1. Create a client (or set SUDOMOCK_API_KEY env var)
|
|
62
|
+
client = SudoMock(api_key="sm_your_api_key")
|
|
63
|
+
|
|
64
|
+
# 2. List your mockup templates
|
|
65
|
+
mockups = client.mockups.list(limit=10)
|
|
66
|
+
for m in mockups.mockups:
|
|
67
|
+
print(f"{m.name} ({m.uuid})")
|
|
68
|
+
|
|
69
|
+
# 3. Render a mockup with your artwork
|
|
70
|
+
render = client.renders.create(
|
|
71
|
+
mockup_uuid=mockups.mockups[0].uuid,
|
|
72
|
+
smart_objects=[{
|
|
73
|
+
"uuid": mockups.mockups[0].smart_objects[0].uuid,
|
|
74
|
+
"asset": {"url": "https://example.com/your-design.png"},
|
|
75
|
+
}],
|
|
76
|
+
)
|
|
77
|
+
print(render.url) # https://cdn.sudomock.com/renders/.../render.webp
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Async Usage
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
import asyncio
|
|
84
|
+
from sudomock import AsyncSudoMock
|
|
85
|
+
|
|
86
|
+
async def main():
|
|
87
|
+
async with AsyncSudoMock(api_key="sm_your_api_key") as client:
|
|
88
|
+
mockups = await client.mockups.list()
|
|
89
|
+
render = await client.renders.create(
|
|
90
|
+
mockup_uuid=mockups.mockups[0].uuid,
|
|
91
|
+
smart_objects=[{
|
|
92
|
+
"uuid": mockups.mockups[0].smart_objects[0].uuid,
|
|
93
|
+
"asset": {"url": "https://example.com/design.png"},
|
|
94
|
+
}],
|
|
95
|
+
)
|
|
96
|
+
print(render.url)
|
|
97
|
+
|
|
98
|
+
asyncio.run(main())
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## AI Rendering (No PSD Required)
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from sudomock import SudoMock
|
|
105
|
+
|
|
106
|
+
client = SudoMock(api_key="sm_your_api_key")
|
|
107
|
+
|
|
108
|
+
# AI automatically detects the print area and applies perspective
|
|
109
|
+
render = client.ai.render(
|
|
110
|
+
source_url="https://example.com/product-photo.jpg",
|
|
111
|
+
artwork_url="https://example.com/your-design.png",
|
|
112
|
+
product_type="t-shirt", # optional hint
|
|
113
|
+
)
|
|
114
|
+
print(render.url)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Error Handling
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from sudomock import SudoMock
|
|
121
|
+
from sudomock.exceptions import (
|
|
122
|
+
AuthenticationError,
|
|
123
|
+
InsufficientCreditsError,
|
|
124
|
+
RateLimitError,
|
|
125
|
+
NotFoundError,
|
|
126
|
+
ValidationError,
|
|
127
|
+
ServerError,
|
|
128
|
+
SudoMockError, # base class for all errors
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
client = SudoMock(api_key="sm_your_api_key")
|
|
132
|
+
|
|
133
|
+
try:
|
|
134
|
+
render = client.renders.create(
|
|
135
|
+
mockup_uuid="...",
|
|
136
|
+
smart_objects=[...],
|
|
137
|
+
)
|
|
138
|
+
except AuthenticationError:
|
|
139
|
+
print("Invalid API key")
|
|
140
|
+
except InsufficientCreditsError as e:
|
|
141
|
+
print(f"Out of credits. Resets at: {e.credits_reset_at}")
|
|
142
|
+
except RateLimitError as e:
|
|
143
|
+
print(f"Rate limited. Retry after: {e.retry_after}s")
|
|
144
|
+
except NotFoundError:
|
|
145
|
+
print("Mockup not found")
|
|
146
|
+
except ValidationError:
|
|
147
|
+
print("Invalid request parameters")
|
|
148
|
+
except ServerError:
|
|
149
|
+
print("Server error, will be retried automatically")
|
|
150
|
+
except SudoMockError as e:
|
|
151
|
+
print(f"Unexpected error: {e.message} (HTTP {e.status_code})")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Account & Credits
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from sudomock import SudoMock
|
|
158
|
+
|
|
159
|
+
client = SudoMock(api_key="sm_your_api_key")
|
|
160
|
+
account = client.account.get()
|
|
161
|
+
|
|
162
|
+
print(f"Plan: {account.subscription.plan}")
|
|
163
|
+
print(f"Credits remaining: {account.usage.credits_remaining}")
|
|
164
|
+
print(f"Credits limit: {account.usage.credits_limit}")
|
|
165
|
+
print(f"Period ends: {account.subscription.current_period_end}")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Configuration
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from sudomock import SudoMock
|
|
172
|
+
|
|
173
|
+
client = SudoMock(
|
|
174
|
+
api_key="sm_your_api_key", # or SUDOMOCK_API_KEY env var
|
|
175
|
+
base_url="https://api.sudomock.com", # default
|
|
176
|
+
timeout=30.0, # default request timeout (seconds)
|
|
177
|
+
render_timeout=120.0, # render request timeout (seconds)
|
|
178
|
+
max_retries=3, # retry on 429/5xx (exponential backoff)
|
|
179
|
+
)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## API Reference
|
|
183
|
+
|
|
184
|
+
### Mockups
|
|
185
|
+
|
|
186
|
+
| Method | Description |
|
|
187
|
+
|--------|-------------|
|
|
188
|
+
| `client.mockups.list(limit=, offset=, search=)` | List mockup templates |
|
|
189
|
+
| `client.mockups.get(uuid)` | Get mockup details |
|
|
190
|
+
| `client.mockups.delete(uuid)` | Delete a mockup |
|
|
191
|
+
|
|
192
|
+
### Renders
|
|
193
|
+
|
|
194
|
+
| Method | Description |
|
|
195
|
+
|--------|-------------|
|
|
196
|
+
| `client.renders.create(mockup_uuid=, smart_objects=, export_options=, export_label=)` | Render a mockup |
|
|
197
|
+
|
|
198
|
+
### AI
|
|
199
|
+
|
|
200
|
+
| Method | Description |
|
|
201
|
+
|--------|-------------|
|
|
202
|
+
| `client.ai.render(source_url=, artwork_url=, product_type=, ...)` | AI-powered render |
|
|
203
|
+
|
|
204
|
+
### Account
|
|
205
|
+
|
|
206
|
+
| Method | Description |
|
|
207
|
+
|--------|-------------|
|
|
208
|
+
| `client.account.get()` | Get account info, credits, subscription |
|
|
209
|
+
|
|
210
|
+
### Export Options
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
export_options = {
|
|
214
|
+
"image_format": "webp", # "webp", "png", "jpg"
|
|
215
|
+
"image_size": 1920, # max dimension in pixels
|
|
216
|
+
"quality": 95, # 1-100 (for webp/jpg)
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Smart Object Configuration
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
smart_objects = [{
|
|
224
|
+
"uuid": "smart-object-uuid",
|
|
225
|
+
"asset": {
|
|
226
|
+
"url": "https://example.com/design.png",
|
|
227
|
+
"fit": "fill", # "fill", "fit", "stretch"
|
|
228
|
+
"rotate": 0, # degrees
|
|
229
|
+
"position": {"top": 100, "left": 100},
|
|
230
|
+
"size": {"width": 800, "height": 600},
|
|
231
|
+
},
|
|
232
|
+
"color": {
|
|
233
|
+
"hex": "#FFFFFF",
|
|
234
|
+
"blending_mode": "multiply",
|
|
235
|
+
},
|
|
236
|
+
}]
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Requirements
|
|
240
|
+
|
|
241
|
+
- Python 3.9+
|
|
242
|
+
- [httpx](https://www.python-httpx.org/) for HTTP
|
|
243
|
+
- [Pydantic v2](https://docs.pydantic.dev/) for response models
|
|
244
|
+
- [tenacity](https://tenacity.readthedocs.io/) for retry logic
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
MIT -- see [LICENSE](LICENSE).
|
|
249
|
+
|
|
250
|
+
## Links
|
|
251
|
+
|
|
252
|
+
- [SudoMock Website](https://sudomock.com)
|
|
253
|
+
- [API Documentation](https://docs.sudomock.com)
|
|
254
|
+
- [Dashboard](https://app.sudomock.com)
|
sudomock-0.1.0/README.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# SudoMock Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python client for the [SudoMock](https://sudomock.com) Mockup Generator API.
|
|
4
|
+
|
|
5
|
+
Generate photorealistic product mockups from PSD templates or AI-powered rendering -- all from your Python code.
|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/sudomock/)
|
|
8
|
+
[](https://pypi.org/project/sudomock/)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://github.com/sudomock/sudomock-python/actions)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install sudomock
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from sudomock import SudoMock
|
|
22
|
+
|
|
23
|
+
# 1. Create a client (or set SUDOMOCK_API_KEY env var)
|
|
24
|
+
client = SudoMock(api_key="sm_your_api_key")
|
|
25
|
+
|
|
26
|
+
# 2. List your mockup templates
|
|
27
|
+
mockups = client.mockups.list(limit=10)
|
|
28
|
+
for m in mockups.mockups:
|
|
29
|
+
print(f"{m.name} ({m.uuid})")
|
|
30
|
+
|
|
31
|
+
# 3. Render a mockup with your artwork
|
|
32
|
+
render = client.renders.create(
|
|
33
|
+
mockup_uuid=mockups.mockups[0].uuid,
|
|
34
|
+
smart_objects=[{
|
|
35
|
+
"uuid": mockups.mockups[0].smart_objects[0].uuid,
|
|
36
|
+
"asset": {"url": "https://example.com/your-design.png"},
|
|
37
|
+
}],
|
|
38
|
+
)
|
|
39
|
+
print(render.url) # https://cdn.sudomock.com/renders/.../render.webp
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Async Usage
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import asyncio
|
|
46
|
+
from sudomock import AsyncSudoMock
|
|
47
|
+
|
|
48
|
+
async def main():
|
|
49
|
+
async with AsyncSudoMock(api_key="sm_your_api_key") as client:
|
|
50
|
+
mockups = await client.mockups.list()
|
|
51
|
+
render = await client.renders.create(
|
|
52
|
+
mockup_uuid=mockups.mockups[0].uuid,
|
|
53
|
+
smart_objects=[{
|
|
54
|
+
"uuid": mockups.mockups[0].smart_objects[0].uuid,
|
|
55
|
+
"asset": {"url": "https://example.com/design.png"},
|
|
56
|
+
}],
|
|
57
|
+
)
|
|
58
|
+
print(render.url)
|
|
59
|
+
|
|
60
|
+
asyncio.run(main())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## AI Rendering (No PSD Required)
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from sudomock import SudoMock
|
|
67
|
+
|
|
68
|
+
client = SudoMock(api_key="sm_your_api_key")
|
|
69
|
+
|
|
70
|
+
# AI automatically detects the print area and applies perspective
|
|
71
|
+
render = client.ai.render(
|
|
72
|
+
source_url="https://example.com/product-photo.jpg",
|
|
73
|
+
artwork_url="https://example.com/your-design.png",
|
|
74
|
+
product_type="t-shirt", # optional hint
|
|
75
|
+
)
|
|
76
|
+
print(render.url)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Error Handling
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from sudomock import SudoMock
|
|
83
|
+
from sudomock.exceptions import (
|
|
84
|
+
AuthenticationError,
|
|
85
|
+
InsufficientCreditsError,
|
|
86
|
+
RateLimitError,
|
|
87
|
+
NotFoundError,
|
|
88
|
+
ValidationError,
|
|
89
|
+
ServerError,
|
|
90
|
+
SudoMockError, # base class for all errors
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
client = SudoMock(api_key="sm_your_api_key")
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
render = client.renders.create(
|
|
97
|
+
mockup_uuid="...",
|
|
98
|
+
smart_objects=[...],
|
|
99
|
+
)
|
|
100
|
+
except AuthenticationError:
|
|
101
|
+
print("Invalid API key")
|
|
102
|
+
except InsufficientCreditsError as e:
|
|
103
|
+
print(f"Out of credits. Resets at: {e.credits_reset_at}")
|
|
104
|
+
except RateLimitError as e:
|
|
105
|
+
print(f"Rate limited. Retry after: {e.retry_after}s")
|
|
106
|
+
except NotFoundError:
|
|
107
|
+
print("Mockup not found")
|
|
108
|
+
except ValidationError:
|
|
109
|
+
print("Invalid request parameters")
|
|
110
|
+
except ServerError:
|
|
111
|
+
print("Server error, will be retried automatically")
|
|
112
|
+
except SudoMockError as e:
|
|
113
|
+
print(f"Unexpected error: {e.message} (HTTP {e.status_code})")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Account & Credits
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from sudomock import SudoMock
|
|
120
|
+
|
|
121
|
+
client = SudoMock(api_key="sm_your_api_key")
|
|
122
|
+
account = client.account.get()
|
|
123
|
+
|
|
124
|
+
print(f"Plan: {account.subscription.plan}")
|
|
125
|
+
print(f"Credits remaining: {account.usage.credits_remaining}")
|
|
126
|
+
print(f"Credits limit: {account.usage.credits_limit}")
|
|
127
|
+
print(f"Period ends: {account.subscription.current_period_end}")
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Configuration
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from sudomock import SudoMock
|
|
134
|
+
|
|
135
|
+
client = SudoMock(
|
|
136
|
+
api_key="sm_your_api_key", # or SUDOMOCK_API_KEY env var
|
|
137
|
+
base_url="https://api.sudomock.com", # default
|
|
138
|
+
timeout=30.0, # default request timeout (seconds)
|
|
139
|
+
render_timeout=120.0, # render request timeout (seconds)
|
|
140
|
+
max_retries=3, # retry on 429/5xx (exponential backoff)
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## API Reference
|
|
145
|
+
|
|
146
|
+
### Mockups
|
|
147
|
+
|
|
148
|
+
| Method | Description |
|
|
149
|
+
|--------|-------------|
|
|
150
|
+
| `client.mockups.list(limit=, offset=, search=)` | List mockup templates |
|
|
151
|
+
| `client.mockups.get(uuid)` | Get mockup details |
|
|
152
|
+
| `client.mockups.delete(uuid)` | Delete a mockup |
|
|
153
|
+
|
|
154
|
+
### Renders
|
|
155
|
+
|
|
156
|
+
| Method | Description |
|
|
157
|
+
|--------|-------------|
|
|
158
|
+
| `client.renders.create(mockup_uuid=, smart_objects=, export_options=, export_label=)` | Render a mockup |
|
|
159
|
+
|
|
160
|
+
### AI
|
|
161
|
+
|
|
162
|
+
| Method | Description |
|
|
163
|
+
|--------|-------------|
|
|
164
|
+
| `client.ai.render(source_url=, artwork_url=, product_type=, ...)` | AI-powered render |
|
|
165
|
+
|
|
166
|
+
### Account
|
|
167
|
+
|
|
168
|
+
| Method | Description |
|
|
169
|
+
|--------|-------------|
|
|
170
|
+
| `client.account.get()` | Get account info, credits, subscription |
|
|
171
|
+
|
|
172
|
+
### Export Options
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
export_options = {
|
|
176
|
+
"image_format": "webp", # "webp", "png", "jpg"
|
|
177
|
+
"image_size": 1920, # max dimension in pixels
|
|
178
|
+
"quality": 95, # 1-100 (for webp/jpg)
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Smart Object Configuration
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
smart_objects = [{
|
|
186
|
+
"uuid": "smart-object-uuid",
|
|
187
|
+
"asset": {
|
|
188
|
+
"url": "https://example.com/design.png",
|
|
189
|
+
"fit": "fill", # "fill", "fit", "stretch"
|
|
190
|
+
"rotate": 0, # degrees
|
|
191
|
+
"position": {"top": 100, "left": 100},
|
|
192
|
+
"size": {"width": 800, "height": 600},
|
|
193
|
+
},
|
|
194
|
+
"color": {
|
|
195
|
+
"hex": "#FFFFFF",
|
|
196
|
+
"blending_mode": "multiply",
|
|
197
|
+
},
|
|
198
|
+
}]
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Requirements
|
|
202
|
+
|
|
203
|
+
- Python 3.9+
|
|
204
|
+
- [httpx](https://www.python-httpx.org/) for HTTP
|
|
205
|
+
- [Pydantic v2](https://docs.pydantic.dev/) for response models
|
|
206
|
+
- [tenacity](https://tenacity.readthedocs.io/) for retry logic
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT -- see [LICENSE](LICENSE).
|
|
211
|
+
|
|
212
|
+
## Links
|
|
213
|
+
|
|
214
|
+
- [SudoMock Website](https://sudomock.com)
|
|
215
|
+
- [API Documentation](https://docs.sudomock.com)
|
|
216
|
+
- [Dashboard](https://app.sudomock.com)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sudomock"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for the SudoMock Mockup Generator API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "SudoMock Labs", email = "hello@sudomock.com" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["mockup", "api", "sdk", "sudomock", "product-mockup", "psd"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
28
|
+
"Topic :: Multimedia :: Graphics",
|
|
29
|
+
]
|
|
30
|
+
dependencies = [
|
|
31
|
+
"httpx>=0.27.0,<1.0.0",
|
|
32
|
+
"pydantic>=2.7.0,<3.0.0",
|
|
33
|
+
"tenacity>=9.0.0,<10.0.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://sudomock.com"
|
|
38
|
+
Documentation = "https://docs.sudomock.com"
|
|
39
|
+
Repository = "https://github.com/sudomock/sudomock-python"
|
|
40
|
+
Issues = "https://github.com/sudomock/sudomock-python/issues"
|
|
41
|
+
Changelog = "https://github.com/sudomock/sudomock-python/blob/main/CHANGELOG.md"
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest>=8.3.0",
|
|
46
|
+
"pytest-asyncio>=0.24.0",
|
|
47
|
+
"respx>=0.22.0",
|
|
48
|
+
"ruff>=0.8.0",
|
|
49
|
+
"mypy>=1.13.0",
|
|
50
|
+
"coverage>=7.6.0",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[tool.hatch.build.targets.sdist]
|
|
54
|
+
include = ["src/sudomock"]
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build.targets.wheel]
|
|
57
|
+
packages = ["src/sudomock"]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
asyncio_mode = "auto"
|
|
62
|
+
|
|
63
|
+
[tool.ruff]
|
|
64
|
+
target-version = "py39"
|
|
65
|
+
line-length = 100
|
|
66
|
+
src = ["src", "tests"]
|
|
67
|
+
|
|
68
|
+
[tool.ruff.lint]
|
|
69
|
+
select = [
|
|
70
|
+
"E", # pycodestyle errors
|
|
71
|
+
"W", # pycodestyle warnings
|
|
72
|
+
"F", # pyflakes
|
|
73
|
+
"I", # isort
|
|
74
|
+
"UP", # pyupgrade
|
|
75
|
+
"B", # flake8-bugbear
|
|
76
|
+
"SIM", # flake8-simplify
|
|
77
|
+
"TCH", # flake8-type-checking
|
|
78
|
+
]
|
|
79
|
+
ignore = [
|
|
80
|
+
"SIM117", # nested with -- parenthesized form requires Python 3.10+
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[tool.mypy]
|
|
84
|
+
python_version = "3.9"
|
|
85
|
+
strict = true
|
|
86
|
+
warn_return_any = true
|
|
87
|
+
warn_unused_configs = true
|
|
88
|
+
|
|
89
|
+
[[tool.mypy.overrides]]
|
|
90
|
+
module = "tenacity.*"
|
|
91
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""SudoMock Python SDK -- official client for the SudoMock Mockup Generator API.
|
|
2
|
+
|
|
3
|
+
Quick start::
|
|
4
|
+
|
|
5
|
+
from sudomock import SudoMock
|
|
6
|
+
|
|
7
|
+
client = SudoMock(api_key="sm_xxx")
|
|
8
|
+
mockups = client.mockups.list()
|
|
9
|
+
render = client.renders.create(
|
|
10
|
+
mockup_uuid=mockups.mockups[0].uuid,
|
|
11
|
+
smart_objects=[{
|
|
12
|
+
"uuid": mockups.mockups[0].smart_objects[0].uuid,
|
|
13
|
+
"asset": {"url": "https://example.com/design.png"},
|
|
14
|
+
}],
|
|
15
|
+
)
|
|
16
|
+
print(render.url)
|
|
17
|
+
|
|
18
|
+
For async usage::
|
|
19
|
+
|
|
20
|
+
from sudomock import AsyncSudoMock
|
|
21
|
+
|
|
22
|
+
async with AsyncSudoMock(api_key="sm_xxx") as client:
|
|
23
|
+
mockups = await client.mockups.list()
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
import importlib.metadata
|
|
29
|
+
|
|
30
|
+
from .async_client import AsyncSudoMock
|
|
31
|
+
from .client import SudoMock
|
|
32
|
+
from .exceptions import (
|
|
33
|
+
AuthenticationError,
|
|
34
|
+
InsufficientCreditsError,
|
|
35
|
+
NotFoundError,
|
|
36
|
+
RateLimitError,
|
|
37
|
+
ServerError,
|
|
38
|
+
SudoMockError,
|
|
39
|
+
ValidationError,
|
|
40
|
+
)
|
|
41
|
+
from .models import (
|
|
42
|
+
Account,
|
|
43
|
+
AccountInfo,
|
|
44
|
+
AIRender,
|
|
45
|
+
ApiKeyInfo,
|
|
46
|
+
Mockup,
|
|
47
|
+
MockupList,
|
|
48
|
+
PrintFile,
|
|
49
|
+
Render,
|
|
50
|
+
Size,
|
|
51
|
+
SmartObject,
|
|
52
|
+
Subscription,
|
|
53
|
+
Usage,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
__version__ = importlib.metadata.version("sudomock")
|
|
58
|
+
except importlib.metadata.PackageNotFoundError:
|
|
59
|
+
__version__ = "0.0.0-dev"
|
|
60
|
+
|
|
61
|
+
__all__ = [
|
|
62
|
+
# Clients
|
|
63
|
+
"SudoMock",
|
|
64
|
+
"AsyncSudoMock",
|
|
65
|
+
# Models
|
|
66
|
+
"Account",
|
|
67
|
+
"AccountInfo",
|
|
68
|
+
"AIRender",
|
|
69
|
+
"ApiKeyInfo",
|
|
70
|
+
"Mockup",
|
|
71
|
+
"MockupList",
|
|
72
|
+
"PrintFile",
|
|
73
|
+
"Render",
|
|
74
|
+
"Size",
|
|
75
|
+
"SmartObject",
|
|
76
|
+
"Subscription",
|
|
77
|
+
"Usage",
|
|
78
|
+
# Exceptions
|
|
79
|
+
"SudoMockError",
|
|
80
|
+
"AuthenticationError",
|
|
81
|
+
"InsufficientCreditsError",
|
|
82
|
+
"NotFoundError",
|
|
83
|
+
"RateLimitError",
|
|
84
|
+
"ServerError",
|
|
85
|
+
"ValidationError",
|
|
86
|
+
# Meta
|
|
87
|
+
"__version__",
|
|
88
|
+
]
|