ddukddak 1.0.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.
ddukddak-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ddukddak
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.
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: ddukddak
3
+ Version: 1.0.0
4
+ Summary: Python SDK for the Ddukddak image and video generation API
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://ddukddak.studio
7
+ Project-URL: Documentation, https://ddukddak.studio/quick-start
8
+ Requires-Python: >=3.8
9
+ License-File: LICENSE
10
+ Requires-Dist: requests>=2.20.0
11
+ Dynamic: license-file
@@ -0,0 +1,185 @@
1
+ # ddukddak
2
+
3
+ Official Python SDK for the [Ddukddak](https://ddukddak.studio) image and video generation API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install ddukddak
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from ddukddak import Ddukddak
15
+
16
+ client = Ddukddak("your-api-key")
17
+
18
+ # Generate an image from a template
19
+ image = client.images.create(
20
+ template="template-uid",
21
+ properties={"title": "Hello World"},
22
+ )
23
+
24
+ print(image)
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Initialize
30
+
31
+ ```python
32
+ client = Ddukddak("your-api-key")
33
+
34
+ # With custom options
35
+ client = Ddukddak(
36
+ "your-api-key",
37
+ base_url="https://api.ddukddak.studio/v1",
38
+ timeout=30,
39
+ )
40
+ ```
41
+
42
+ ### Authentication
43
+
44
+ ```python
45
+ # Verify your API key
46
+ result = client.auth.test()
47
+ ```
48
+
49
+ ### Account
50
+
51
+ ```python
52
+ account = client.account.get()
53
+ ```
54
+
55
+ ### Templates
56
+
57
+ ```python
58
+ # List templates
59
+ templates = client.templates.list(page=1, limit=25)
60
+
61
+ # Get a specific template
62
+ template = client.templates.get("template-uid")
63
+ ```
64
+
65
+ ### Images
66
+
67
+ ```python
68
+ # Create an image
69
+ image = client.images.create(
70
+ template="template-uid",
71
+ properties={"title": "Sale Banner", "price": "$9.99"},
72
+ transparent=False,
73
+ )
74
+
75
+ # Create and wait for completion
76
+ image = client.images.create_and_wait(
77
+ template="template-uid",
78
+ properties={"title": "Sale Banner"},
79
+ )
80
+
81
+ # List images
82
+ images = client.images.list(page=1, limit=25)
83
+
84
+ # Get a specific image
85
+ image = client.images.get("image-uid")
86
+ ```
87
+
88
+ ### Videos
89
+
90
+ ```python
91
+ # Create a video
92
+ video = client.videos.create(
93
+ template="template-uid",
94
+ input_media_url="https://example.com/video.mp4",
95
+ properties={"subtitle": "Hello"},
96
+ )
97
+
98
+ # Create and wait for completion
99
+ video = client.videos.create_and_wait(
100
+ template="template-uid",
101
+ input_media_url="https://example.com/video.mp4",
102
+ )
103
+
104
+ # List videos
105
+ videos = client.videos.list()
106
+
107
+ # Get a specific video
108
+ video = client.videos.get("video-uid")
109
+ ```
110
+
111
+ ### AI Images
112
+
113
+ ```python
114
+ # Generate an AI image
115
+ image = client.ai_images.create(
116
+ prompt="A sunset over the ocean",
117
+ model="gemini",
118
+ aspect_ratio="16:9",
119
+ )
120
+
121
+ # Generate and wait for completion
122
+ image = client.ai_images.create_and_wait(
123
+ prompt="A sunset over the ocean",
124
+ )
125
+ ```
126
+
127
+ ### AI Videos
128
+
129
+ ```python
130
+ # Generate an AI video
131
+ video = client.ai_videos.create(
132
+ prompt="A cat walking on the beach",
133
+ model="minimax",
134
+ aspect_ratio="16:9",
135
+ duration=5,
136
+ )
137
+
138
+ # Generate and wait for completion
139
+ video = client.ai_videos.create_and_wait(
140
+ prompt="A cat walking on the beach",
141
+ )
142
+ ```
143
+
144
+ ## Error Handling
145
+
146
+ ```python
147
+ from ddukddak import (
148
+ Ddukddak,
149
+ AuthenticationError,
150
+ ValidationError,
151
+ RateLimitError,
152
+ )
153
+
154
+ try:
155
+ image = client.images.create(template="uid")
156
+ except AuthenticationError:
157
+ # Invalid API key (401)
158
+ pass
159
+ except ValidationError:
160
+ # Bad request (400)
161
+ pass
162
+ except RateLimitError:
163
+ # Too many requests (429)
164
+ pass
165
+ ```
166
+
167
+ All exception classes:
168
+
169
+ | Class | Status Code | Description |
170
+ |-------|------------|-------------|
171
+ | `AuthenticationError` | 401 | Invalid or missing API key |
172
+ | `ValidationError` | 400 | Invalid request parameters |
173
+ | `QuotaExceededError` | 402 | Usage quota exceeded |
174
+ | `PlanRestrictedError` | 403 | Feature not available on current plan |
175
+ | `NotFoundError` | 404 | Resource not found |
176
+ | `RateLimitError` | 429 | Rate limit exceeded |
177
+ | `DdukddakError` | * | Base exception class |
178
+
179
+ ## Requirements
180
+
181
+ - Python >= 3.8
182
+
183
+ ## License
184
+
185
+ [MIT](LICENSE)
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ddukddak"
7
+ version = "1.0.0"
8
+ description = "Python SDK for the Ddukddak image and video generation API"
9
+ requires-python = ">=3.8"
10
+ license = "MIT"
11
+ dependencies = ["requests>=2.20.0"]
12
+
13
+ [project.urls]
14
+ Homepage = "https://ddukddak.studio"
15
+ Documentation = "https://ddukddak.studio/quick-start"
16
+
17
+ [tool.setuptools.packages.find]
18
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,22 @@
1
+ from .client import Ddukddak
2
+ from .exceptions import (
3
+ DdukddakError,
4
+ AuthenticationError,
5
+ RateLimitError,
6
+ NotFoundError,
7
+ ValidationError,
8
+ PlanRestrictedError,
9
+ QuotaExceededError,
10
+ )
11
+
12
+ __version__ = "0.1.0"
13
+ __all__ = [
14
+ "Ddukddak",
15
+ "DdukddakError",
16
+ "AuthenticationError",
17
+ "RateLimitError",
18
+ "NotFoundError",
19
+ "ValidationError",
20
+ "PlanRestrictedError",
21
+ "QuotaExceededError",
22
+ ]
@@ -0,0 +1,232 @@
1
+ import time
2
+
3
+ import requests
4
+
5
+ from .exceptions import (
6
+ DdukddakError,
7
+ AuthenticationError,
8
+ ValidationError,
9
+ QuotaExceededError,
10
+ PlanRestrictedError,
11
+ NotFoundError,
12
+ RateLimitError,
13
+ )
14
+
15
+ _ERROR_MAP = {
16
+ 400: ValidationError,
17
+ 401: AuthenticationError,
18
+ 402: QuotaExceededError,
19
+ 403: PlanRestrictedError,
20
+ 404: NotFoundError,
21
+ 429: RateLimitError,
22
+ }
23
+
24
+
25
+ class _Resource:
26
+ def __init__(self, client):
27
+ self._client = client
28
+
29
+ def _request(self, method, path, **kwargs):
30
+ return self._client._request(method, path, **kwargs)
31
+
32
+
33
+ class AuthResource(_Resource):
34
+ def test(self):
35
+ return self._request("GET", "/auth")
36
+
37
+
38
+ class AccountResource(_Resource):
39
+ def get(self):
40
+ return self._request("GET", "/account")
41
+
42
+
43
+ class TemplatesResource(_Resource):
44
+ def list(self, page=1, limit=25):
45
+ return self._request("GET", "/templates", params={"page": page, "limit": limit})
46
+
47
+ def get(self, uid):
48
+ return self._request("GET", f"/templates/{uid}")
49
+
50
+
51
+ class ImagesResource(_Resource):
52
+ def create(self, template, properties=None, webhook_url=None, transparent=False):
53
+ body = {"template": template}
54
+ if properties:
55
+ body["properties"] = properties
56
+ if webhook_url:
57
+ body["webhook_url"] = webhook_url
58
+ if transparent:
59
+ body["transparent"] = transparent
60
+ return self._request("POST", "/images", json=body)
61
+
62
+ def list(self, page=1, limit=25):
63
+ return self._request("GET", "/images", params={"page": page, "limit": limit})
64
+
65
+ def get(self, uid):
66
+ return self._request("GET", f"/images/{uid}")
67
+
68
+ def create_and_wait(self, template, properties=None, transparent=False, poll_interval=3, timeout=300):
69
+ result = self.create(template, properties=properties, transparent=transparent)
70
+ if result.get("status") in ("completed", "failed"):
71
+ return result
72
+ return self._poll(result["uid"], poll_interval, timeout)
73
+
74
+ def _poll(self, uid, interval, timeout):
75
+ start = time.time()
76
+ while time.time() - start < timeout:
77
+ result = self.get(uid)
78
+ if result.get("status") in ("completed", "failed"):
79
+ return result
80
+ time.sleep(interval)
81
+ raise DdukddakError(f"Polling timed out after {timeout}s for image {uid}")
82
+
83
+
84
+ class VideosResource(_Resource):
85
+ def create(self, template, input_media_url, properties=None, audio_url=None, webhook_url=None):
86
+ body = {"template": template, "input_media_url": input_media_url}
87
+ if properties:
88
+ body["properties"] = properties
89
+ if audio_url:
90
+ body["audio_url"] = audio_url
91
+ if webhook_url:
92
+ body["webhook_url"] = webhook_url
93
+ return self._request("POST", "/videos", json=body)
94
+
95
+ def list(self, page=1, limit=25):
96
+ return self._request("GET", "/videos", params={"page": page, "limit": limit})
97
+
98
+ def get(self, uid):
99
+ return self._request("GET", f"/videos/{uid}")
100
+
101
+ def create_and_wait(self, template, input_media_url, properties=None, audio_url=None, poll_interval=5, timeout=600):
102
+ result = self.create(template, input_media_url, properties=properties, audio_url=audio_url)
103
+ if result.get("status") in ("completed", "failed"):
104
+ return result
105
+ return self._poll(result["uid"], poll_interval, timeout)
106
+
107
+ def _poll(self, uid, interval, timeout):
108
+ start = time.time()
109
+ while time.time() - start < timeout:
110
+ result = self.get(uid)
111
+ if result.get("status") in ("completed", "failed"):
112
+ return result
113
+ time.sleep(interval)
114
+ raise DdukddakError(f"Polling timed out after {timeout}s for video {uid}")
115
+
116
+
117
+ class AiImagesResource(_Resource):
118
+ def create(self, prompt=None, model=None, aspect_ratio=None, image_size=None, settings=None, template=None, webhook_url=None):
119
+ body = {}
120
+ if prompt:
121
+ body["prompt"] = prompt
122
+ if model:
123
+ body["model"] = model
124
+ if aspect_ratio:
125
+ body["aspect_ratio"] = aspect_ratio
126
+ if image_size:
127
+ body["image_size"] = image_size
128
+ if settings:
129
+ body["settings"] = settings
130
+ if template:
131
+ body["template"] = template
132
+ if webhook_url:
133
+ body["webhook_url"] = webhook_url
134
+ return self._request("POST", "/ai/images", json=body)
135
+
136
+ def list(self, page=1, limit=25):
137
+ return self._request("GET", "/ai/images", params={"page": page, "limit": limit})
138
+
139
+ def get(self, uid):
140
+ return self._request("GET", f"/ai/images/{uid}")
141
+
142
+ def create_and_wait(self, prompt=None, model=None, aspect_ratio=None, image_size=None, settings=None, template=None, poll_interval=3, timeout=300):
143
+ result = self.create(prompt=prompt, model=model, aspect_ratio=aspect_ratio, image_size=image_size, settings=settings, template=template)
144
+ if result.get("status") in ("completed", "failed"):
145
+ return result
146
+ return self._poll(result["uid"], poll_interval, timeout)
147
+
148
+ def _poll(self, uid, interval, timeout):
149
+ start = time.time()
150
+ while time.time() - start < timeout:
151
+ result = self.get(uid)
152
+ if result.get("status") in ("completed", "failed"):
153
+ return result
154
+ time.sleep(interval)
155
+ raise DdukddakError(f"Polling timed out after {timeout}s for AI image {uid}")
156
+
157
+
158
+ class AiVideosResource(_Resource):
159
+ def create(self, prompt, model=None, aspect_ratio=None, resolution=None, duration=None, webhook_url=None):
160
+ body = {"prompt": prompt}
161
+ if model:
162
+ body["model"] = model
163
+ if aspect_ratio:
164
+ body["aspect_ratio"] = aspect_ratio
165
+ if resolution:
166
+ body["resolution"] = resolution
167
+ if duration:
168
+ body["duration"] = duration
169
+ if webhook_url:
170
+ body["webhook_url"] = webhook_url
171
+ return self._request("POST", "/ai/videos", json=body)
172
+
173
+ def list(self, page=1, limit=25):
174
+ return self._request("GET", "/ai/videos", params={"page": page, "limit": limit})
175
+
176
+ def get(self, uid):
177
+ return self._request("GET", f"/ai/videos/{uid}")
178
+
179
+ def create_and_wait(self, prompt, model=None, aspect_ratio=None, resolution=None, duration=None, poll_interval=5, timeout=600):
180
+ result = self.create(prompt, model=model, aspect_ratio=aspect_ratio, resolution=resolution, duration=duration)
181
+ if result.get("status") in ("completed", "failed"):
182
+ return result
183
+ return self._poll(result["uid"], poll_interval, timeout)
184
+
185
+ def _poll(self, uid, interval, timeout):
186
+ start = time.time()
187
+ while time.time() - start < timeout:
188
+ result = self.get(uid)
189
+ if result.get("status") in ("completed", "failed"):
190
+ return result
191
+ time.sleep(interval)
192
+ raise DdukddakError(f"Polling timed out after {timeout}s for AI video {uid}")
193
+
194
+
195
+ class Ddukddak:
196
+ def __init__(self, api_key, base_url="https://api.ddukddak.studio/v1", timeout=30):
197
+ self.api_key = api_key
198
+ self.base_url = base_url.rstrip("/")
199
+ self.timeout = timeout
200
+
201
+ self.auth = AuthResource(self)
202
+ self.account = AccountResource(self)
203
+ self.templates = TemplatesResource(self)
204
+ self.images = ImagesResource(self)
205
+ self.videos = VideosResource(self)
206
+ self.ai_images = AiImagesResource(self)
207
+ self.ai_videos = AiVideosResource(self)
208
+
209
+ def _request(self, method, path, **kwargs):
210
+ url = f"{self.base_url}{path}"
211
+ headers = {
212
+ "Authorization": f"Bearer {self.api_key}",
213
+ "Content-Type": "application/json",
214
+ }
215
+ if "headers" in kwargs:
216
+ headers.update(kwargs.pop("headers"))
217
+
218
+ response = requests.request(
219
+ method, url, headers=headers, timeout=self.timeout, **kwargs
220
+ )
221
+
222
+ if response.status_code >= 400:
223
+ try:
224
+ data = response.json()
225
+ except ValueError:
226
+ data = {}
227
+ error_code = data.get("error", "unknown_error")
228
+ message = data.get("message", response.text)
229
+ exc_class = _ERROR_MAP.get(response.status_code, DdukddakError)
230
+ raise exc_class(message, status_code=response.status_code, error_code=error_code)
231
+
232
+ return response.json()
@@ -0,0 +1,30 @@
1
+ class DdukddakError(Exception):
2
+ def __init__(self, message, status_code=None, error_code=None):
3
+ super().__init__(message)
4
+ self.message = message
5
+ self.status_code = status_code
6
+ self.error_code = error_code
7
+
8
+
9
+ class AuthenticationError(DdukddakError):
10
+ pass
11
+
12
+
13
+ class ValidationError(DdukddakError):
14
+ pass
15
+
16
+
17
+ class QuotaExceededError(DdukddakError):
18
+ pass
19
+
20
+
21
+ class PlanRestrictedError(DdukddakError):
22
+ pass
23
+
24
+
25
+ class NotFoundError(DdukddakError):
26
+ pass
27
+
28
+
29
+ class RateLimitError(DdukddakError):
30
+ pass
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: ddukddak
3
+ Version: 1.0.0
4
+ Summary: Python SDK for the Ddukddak image and video generation API
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://ddukddak.studio
7
+ Project-URL: Documentation, https://ddukddak.studio/quick-start
8
+ Requires-Python: >=3.8
9
+ License-File: LICENSE
10
+ Requires-Dist: requests>=2.20.0
11
+ Dynamic: license-file
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ddukddak/__init__.py
5
+ src/ddukddak/client.py
6
+ src/ddukddak/exceptions.py
7
+ src/ddukddak.egg-info/PKG-INFO
8
+ src/ddukddak.egg-info/SOURCES.txt
9
+ src/ddukddak.egg-info/dependency_links.txt
10
+ src/ddukddak.egg-info/requires.txt
11
+ src/ddukddak.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.20.0
@@ -0,0 +1 @@
1
+ ddukddak