imejis 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.
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.egg-info/
3
+ .venv/
4
+ .mypy_cache/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ dist/
8
+ build/
9
+ uv.lock
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ First release.
6
+
7
+ - `Imejis` (sync) and `AsyncImejis` clients, with an API key (render key) or an OAuth access token.
8
+ - `designs.list()`, `designs.iterate()`, `designs.search()`, `designs.config()`, `designs.fields()`, `designs.sizes()`.
9
+ - `render()` (bytes), `render_to_url()` (public URL), `render_signed_url()` (expiring URL).
10
+ - `render_all_sizes()` and `render_bulk()` (up to 25 renders a call).
11
+ - Typed errors, retries with backoff, timeouts.
imejis-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 imejis
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.
imejis-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,217 @@
1
+ Metadata-Version: 2.5
2
+ Name: imejis
3
+ Version: 0.1.0
4
+ Summary: Official imejis SDK for Python: list designs, read their editable fields and render images (bytes, public URLs, signed URLs, every size at once).
5
+ Project-URL: Homepage, https://imejis.io
6
+ Project-URL: Documentation, https://imejis.io/docs
7
+ Project-URL: Source, https://github.com/imejis/imejis-python
8
+ Project-URL: Issues, https://github.com/imejis/imejis-python/issues
9
+ Author-email: imejis <support@imejis.io>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: image api,image generation,imejis,og image,render,sdk
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Topic :: Multimedia :: Graphics
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.9
21
+ Requires-Dist: httpx<1,>=0.24
22
+ Provides-Extra: dev
23
+ Requires-Dist: mypy>=1.10; extra == 'dev'
24
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
25
+ Requires-Dist: pytest>=8; extra == 'dev'
26
+ Requires-Dist: ruff>=0.5; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # imejis for Python
30
+
31
+ The official [imejis](https://imejis.io) SDK. Turn a design into an image with
32
+ your own text, images and data: get the bytes, a public URL, an expiring
33
+ signed URL, or every size of the design at once.
34
+
35
+ - Sync and async clients, fully typed
36
+ - Python 3.9+, built on `httpx`
37
+ - Retries, timeouts and typed errors built in
38
+
39
+ ```bash
40
+ pip install imejis
41
+ ```
42
+
43
+ ## Quick start
44
+
45
+ Create a render key under **Settings > API keys** in imejis, and copy a
46
+ design's render code from its API panel (it looks like `etpd-V1CzPXpw`).
47
+
48
+ ```python
49
+ from imejis import Imejis
50
+
51
+ imejis = Imejis(api_key="...") # or set IMEJIS_API_KEY
52
+
53
+ image = imejis.render(
54
+ "etpd-V1CzPXpw",
55
+ {"title.text": "Summer sale", "photo.image": "https://example.com/shoes.jpg"},
56
+ )
57
+ image.save("sale.png")
58
+ ```
59
+
60
+ ## Authentication
61
+
62
+ | Credential | Argument | What it can do |
63
+ | ------------------ | -------------- | ----------------------------------------------------------------------- |
64
+ | Render key | `api_key` | Render any design in its workspace |
65
+ | OAuth access token | `access_token` | Everything: list and search designs, read fields and sizes, and render |
66
+
67
+ With an access token the SDK finds one of the account's render keys (or
68
+ creates one named `imejis SDK`) the first time it renders, and reuses it. Use
69
+ an access token when you act for an imejis user, for example in an app or an
70
+ AI agent that signed them in with OAuth; see
71
+ [api.imejis.io/auth.md](https://api.imejis.io/auth.md).
72
+
73
+ ## Render
74
+
75
+ Overrides are keyed `layer.property`, the dot paths `designs.fields()`
76
+ returns. Nested dicts work too: `{"title": {"text": "Hi", "color": "#fff"}}`.
77
+ Anything you leave out keeps the design's value.
78
+
79
+ ```python
80
+ # Bytes (nothing stored)
81
+ image = imejis.render(
82
+ "etpd-V1CzPXpw",
83
+ {"title.text": "Hi"},
84
+ format="jpeg", # png (default), jpeg, webp or pdf
85
+ quality=85, # 1-100, for jpeg
86
+ size="story", # one of the design's sizes; omit for the main size
87
+ )
88
+ image.data # bytes
89
+ image.content_type # "image/jpeg"
90
+ image.warnings # e.g. an override key that matched no layer
91
+
92
+ # A public, permanent URL hosted by imejis
93
+ url = imejis.render_to_url("etpd-V1CzPXpw", {"title.text": "Hi"}).url
94
+
95
+ # A private URL that expires (minutes, 1 to 10080; default 60)
96
+ signed = imejis.render_signed_url("etpd-V1CzPXpw", expires_in=30)
97
+ signed.url, signed.expires_at
98
+ ```
99
+
100
+ With an access token you can pass the design id from `designs.list()`
101
+ instead of the render code; the SDK looks the code up once and caches it.
102
+
103
+ ### Every size at once
104
+
105
+ ```python
106
+ result = imejis.render_all_sizes("etpd-V1CzPXpw", {"title.text": "Hi"})
107
+ for r in result.results:
108
+ print(r.size, r.url if r.ok else r.error)
109
+ ```
110
+
111
+ Without `sizes`, it renders the main size plus every other size of the
112
+ design. Name them to pick some: `sizes=["master", "story"]`. Pass
113
+ `delivery="signed"` (and `expires_in`) for expiring URLs.
114
+
115
+ ### Bulk
116
+
117
+ Up to 25 renders of any designs, sizes and values in one call, returned in
118
+ input order. A failed item does not stop the others.
119
+
120
+ ```python
121
+ from imejis import BulkItem
122
+
123
+ batch = imejis.render_bulk(
124
+ [
125
+ BulkItem(design="etpd-V1CzPXpw", overrides={"title.text": "Alice"}),
126
+ {"design": "etpd-V1CzPXpw", "overrides": {"title.text": "Bob"}, "size": "story"},
127
+ ],
128
+ format="webp",
129
+ )
130
+ print(batch.succeeded, batch.failed)
131
+ ```
132
+
133
+ ## Designs
134
+
135
+ These need an access token.
136
+
137
+ ```python
138
+ page = imejis.designs.list(page=1, limit=50) # newest first
139
+ for design in imejis.designs.iterate():
140
+ print(design.name)
141
+
142
+ matches = imejis.designs.search("summer sale") # exact names first
143
+
144
+ config = imejis.designs.config(page.designs[0].id)
145
+ config.render_code # "etpd-V1CzPXpw"
146
+ config.fields # [FieldSpec(key="title.text", kind="text", default_value="Hello", ...)]
147
+ config.sizes # [SizeVariation(id="master", name="Master", width=1200, height=630), ...]
148
+ ```
149
+
150
+ ## Async
151
+
152
+ `AsyncImejis` has the same methods, awaited:
153
+
154
+ ```python
155
+ import asyncio
156
+ from imejis import AsyncImejis
157
+
158
+ async def main() -> None:
159
+ async with AsyncImejis(api_key="...") as imejis:
160
+ images = await asyncio.gather(
161
+ *(imejis.render_to_url("etpd-V1CzPXpw", {"title.text": n}) for n in ["Ann", "Ben"])
162
+ )
163
+ print([i.url for i in images])
164
+
165
+ asyncio.run(main())
166
+ ```
167
+
168
+ ## Errors
169
+
170
+ Every failure is an `ImejisError` with `status`, `body` and `request_id`.
171
+ Catch the common cases by type:
172
+
173
+ ```python
174
+ from imejis import AuthenticationError, NotFoundError, RateLimitError
175
+
176
+ try:
177
+ imejis.render("etpd-V1CzPXpw")
178
+ except RateLimitError:
179
+ ... # the workspace's render quota is used up
180
+ except NotFoundError:
181
+ ... # wrong render code, or a design in another workspace
182
+ except AuthenticationError:
183
+ ... # bad or expired key / token
184
+ ```
185
+
186
+ | Class | When |
187
+ | ----------------------- | ------------------------------------------------------- |
188
+ | `BadRequestError` | 400 |
189
+ | `AuthenticationError` | 401 |
190
+ | `PermissionDeniedError` | 403 |
191
+ | `NotFoundError` | 404 |
192
+ | `GoneError` | 410, a design from the retired editor |
193
+ | `RateLimitError` | 429, render quota used up |
194
+ | `InternalServerError` | 5xx |
195
+ | `ConnectionError` | no response; `TimeoutError` when `timeout` passed |
196
+ | `ImejisConfigError` | the SDK was called wrongly (checked before any request) |
197
+
198
+ ## Options
199
+
200
+ ```python
201
+ Imejis(
202
+ api_key="...",
203
+ access_token="...",
204
+ timeout=60.0, # seconds per request
205
+ max_retries=2, # network errors, 5xx, and 429 with Retry-After
206
+ render_key_name="imejis SDK", # the key an access token reuses or creates
207
+ http_client=httpx.Client(), # proxies, custom transports, tests
208
+ )
209
+ ```
210
+
211
+ A 429 for a spent render quota is not retried, since waiting a few seconds
212
+ cannot help. Each render (and each item of a bulk call) uses one render from
213
+ the workspace's quota; failed renders are refunded.
214
+
215
+ ## License
216
+
217
+ MIT
imejis-0.1.0/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # imejis for Python
2
+
3
+ The official [imejis](https://imejis.io) SDK. Turn a design into an image with
4
+ your own text, images and data: get the bytes, a public URL, an expiring
5
+ signed URL, or every size of the design at once.
6
+
7
+ - Sync and async clients, fully typed
8
+ - Python 3.9+, built on `httpx`
9
+ - Retries, timeouts and typed errors built in
10
+
11
+ ```bash
12
+ pip install imejis
13
+ ```
14
+
15
+ ## Quick start
16
+
17
+ Create a render key under **Settings > API keys** in imejis, and copy a
18
+ design's render code from its API panel (it looks like `etpd-V1CzPXpw`).
19
+
20
+ ```python
21
+ from imejis import Imejis
22
+
23
+ imejis = Imejis(api_key="...") # or set IMEJIS_API_KEY
24
+
25
+ image = imejis.render(
26
+ "etpd-V1CzPXpw",
27
+ {"title.text": "Summer sale", "photo.image": "https://example.com/shoes.jpg"},
28
+ )
29
+ image.save("sale.png")
30
+ ```
31
+
32
+ ## Authentication
33
+
34
+ | Credential | Argument | What it can do |
35
+ | ------------------ | -------------- | ----------------------------------------------------------------------- |
36
+ | Render key | `api_key` | Render any design in its workspace |
37
+ | OAuth access token | `access_token` | Everything: list and search designs, read fields and sizes, and render |
38
+
39
+ With an access token the SDK finds one of the account's render keys (or
40
+ creates one named `imejis SDK`) the first time it renders, and reuses it. Use
41
+ an access token when you act for an imejis user, for example in an app or an
42
+ AI agent that signed them in with OAuth; see
43
+ [api.imejis.io/auth.md](https://api.imejis.io/auth.md).
44
+
45
+ ## Render
46
+
47
+ Overrides are keyed `layer.property`, the dot paths `designs.fields()`
48
+ returns. Nested dicts work too: `{"title": {"text": "Hi", "color": "#fff"}}`.
49
+ Anything you leave out keeps the design's value.
50
+
51
+ ```python
52
+ # Bytes (nothing stored)
53
+ image = imejis.render(
54
+ "etpd-V1CzPXpw",
55
+ {"title.text": "Hi"},
56
+ format="jpeg", # png (default), jpeg, webp or pdf
57
+ quality=85, # 1-100, for jpeg
58
+ size="story", # one of the design's sizes; omit for the main size
59
+ )
60
+ image.data # bytes
61
+ image.content_type # "image/jpeg"
62
+ image.warnings # e.g. an override key that matched no layer
63
+
64
+ # A public, permanent URL hosted by imejis
65
+ url = imejis.render_to_url("etpd-V1CzPXpw", {"title.text": "Hi"}).url
66
+
67
+ # A private URL that expires (minutes, 1 to 10080; default 60)
68
+ signed = imejis.render_signed_url("etpd-V1CzPXpw", expires_in=30)
69
+ signed.url, signed.expires_at
70
+ ```
71
+
72
+ With an access token you can pass the design id from `designs.list()`
73
+ instead of the render code; the SDK looks the code up once and caches it.
74
+
75
+ ### Every size at once
76
+
77
+ ```python
78
+ result = imejis.render_all_sizes("etpd-V1CzPXpw", {"title.text": "Hi"})
79
+ for r in result.results:
80
+ print(r.size, r.url if r.ok else r.error)
81
+ ```
82
+
83
+ Without `sizes`, it renders the main size plus every other size of the
84
+ design. Name them to pick some: `sizes=["master", "story"]`. Pass
85
+ `delivery="signed"` (and `expires_in`) for expiring URLs.
86
+
87
+ ### Bulk
88
+
89
+ Up to 25 renders of any designs, sizes and values in one call, returned in
90
+ input order. A failed item does not stop the others.
91
+
92
+ ```python
93
+ from imejis import BulkItem
94
+
95
+ batch = imejis.render_bulk(
96
+ [
97
+ BulkItem(design="etpd-V1CzPXpw", overrides={"title.text": "Alice"}),
98
+ {"design": "etpd-V1CzPXpw", "overrides": {"title.text": "Bob"}, "size": "story"},
99
+ ],
100
+ format="webp",
101
+ )
102
+ print(batch.succeeded, batch.failed)
103
+ ```
104
+
105
+ ## Designs
106
+
107
+ These need an access token.
108
+
109
+ ```python
110
+ page = imejis.designs.list(page=1, limit=50) # newest first
111
+ for design in imejis.designs.iterate():
112
+ print(design.name)
113
+
114
+ matches = imejis.designs.search("summer sale") # exact names first
115
+
116
+ config = imejis.designs.config(page.designs[0].id)
117
+ config.render_code # "etpd-V1CzPXpw"
118
+ config.fields # [FieldSpec(key="title.text", kind="text", default_value="Hello", ...)]
119
+ config.sizes # [SizeVariation(id="master", name="Master", width=1200, height=630), ...]
120
+ ```
121
+
122
+ ## Async
123
+
124
+ `AsyncImejis` has the same methods, awaited:
125
+
126
+ ```python
127
+ import asyncio
128
+ from imejis import AsyncImejis
129
+
130
+ async def main() -> None:
131
+ async with AsyncImejis(api_key="...") as imejis:
132
+ images = await asyncio.gather(
133
+ *(imejis.render_to_url("etpd-V1CzPXpw", {"title.text": n}) for n in ["Ann", "Ben"])
134
+ )
135
+ print([i.url for i in images])
136
+
137
+ asyncio.run(main())
138
+ ```
139
+
140
+ ## Errors
141
+
142
+ Every failure is an `ImejisError` with `status`, `body` and `request_id`.
143
+ Catch the common cases by type:
144
+
145
+ ```python
146
+ from imejis import AuthenticationError, NotFoundError, RateLimitError
147
+
148
+ try:
149
+ imejis.render("etpd-V1CzPXpw")
150
+ except RateLimitError:
151
+ ... # the workspace's render quota is used up
152
+ except NotFoundError:
153
+ ... # wrong render code, or a design in another workspace
154
+ except AuthenticationError:
155
+ ... # bad or expired key / token
156
+ ```
157
+
158
+ | Class | When |
159
+ | ----------------------- | ------------------------------------------------------- |
160
+ | `BadRequestError` | 400 |
161
+ | `AuthenticationError` | 401 |
162
+ | `PermissionDeniedError` | 403 |
163
+ | `NotFoundError` | 404 |
164
+ | `GoneError` | 410, a design from the retired editor |
165
+ | `RateLimitError` | 429, render quota used up |
166
+ | `InternalServerError` | 5xx |
167
+ | `ConnectionError` | no response; `TimeoutError` when `timeout` passed |
168
+ | `ImejisConfigError` | the SDK was called wrongly (checked before any request) |
169
+
170
+ ## Options
171
+
172
+ ```python
173
+ Imejis(
174
+ api_key="...",
175
+ access_token="...",
176
+ timeout=60.0, # seconds per request
177
+ max_retries=2, # network errors, 5xx, and 429 with Retry-After
178
+ render_key_name="imejis SDK", # the key an access token reuses or creates
179
+ http_client=httpx.Client(), # proxies, custom transports, tests
180
+ )
181
+ ```
182
+
183
+ A 429 for a spent render quota is not retried, since waiting a few seconds
184
+ cannot help. Each render (and each item of a bulk call) uses one render from
185
+ the workspace's quota; failed renders are refunded.
186
+
187
+ ## License
188
+
189
+ MIT
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "imejis"
7
+ dynamic = ["version"]
8
+ description = "Official imejis SDK for Python: list designs, read their editable fields and render images (bytes, public URLs, signed URLs, every size at once)."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ authors = [{ name = "imejis", email = "support@imejis.io" }]
14
+ keywords = ["imejis", "image generation", "image api", "og image", "render", "sdk"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Topic :: Multimedia :: Graphics",
22
+ "Typing :: Typed",
23
+ ]
24
+ dependencies = ["httpx>=0.24,<1"]
25
+
26
+ [project.urls]
27
+ Homepage = "https://imejis.io"
28
+ Documentation = "https://imejis.io/docs"
29
+ Source = "https://github.com/imejis/imejis-python"
30
+ Issues = "https://github.com/imejis/imejis-python/issues"
31
+
32
+ [project.optional-dependencies]
33
+ dev = ["pytest>=8", "pytest-asyncio>=0.23", "mypy>=1.10", "ruff>=0.5"]
34
+
35
+ [tool.hatch.version]
36
+ path = "src/imejis/_version.py"
37
+
38
+ [tool.hatch.build.targets.wheel]
39
+ packages = ["src/imejis"]
40
+
41
+ [tool.hatch.build.targets.sdist]
42
+ include = ["src/imejis", "tests", "README.md", "CHANGELOG.md", "LICENSE"]
43
+
44
+ [tool.pytest.ini_options]
45
+ testpaths = ["tests"]
46
+ asyncio_mode = "auto"
47
+ asyncio_default_fixture_loop_scope = "function"
48
+
49
+ [tool.mypy]
50
+ strict = true
51
+ files = ["src/imejis"]
52
+
53
+ [tool.ruff]
54
+ line-length = 120
55
+ target-version = "py39"
56
+
57
+ [tool.ruff.lint]
58
+ select = ["E", "F", "W", "I", "B"]
@@ -0,0 +1,62 @@
1
+ """Official imejis SDK for Python: list designs, read their fields and render images."""
2
+
3
+ from ._client import AsyncDesigns, AsyncImejis, Designs, Imejis
4
+ from ._core import BULK_MAX_ITEMS, EXPIRES_IN_MAX_MINUTES, RENDER_FORMATS
5
+ from ._errors import (
6
+ AuthenticationError,
7
+ BadRequestError,
8
+ ConnectionError,
9
+ GoneError,
10
+ ImejisConfigError,
11
+ ImejisError,
12
+ InternalServerError,
13
+ NotFoundError,
14
+ PermissionDeniedError,
15
+ RateLimitError,
16
+ TimeoutError,
17
+ )
18
+ from ._types import (
19
+ BulkItem,
20
+ BulkResponse,
21
+ BulkResult,
22
+ DesignConfig,
23
+ DesignPage,
24
+ DesignSummary,
25
+ FieldSpec,
26
+ RenderedImage,
27
+ SizeVariation,
28
+ StoredRender,
29
+ )
30
+ from ._version import __version__
31
+
32
+ __all__ = [
33
+ "AsyncDesigns",
34
+ "AsyncImejis",
35
+ "AuthenticationError",
36
+ "BULK_MAX_ITEMS",
37
+ "BadRequestError",
38
+ "BulkItem",
39
+ "BulkResponse",
40
+ "BulkResult",
41
+ "ConnectionError",
42
+ "Designs",
43
+ "DesignConfig",
44
+ "DesignPage",
45
+ "DesignSummary",
46
+ "EXPIRES_IN_MAX_MINUTES",
47
+ "FieldSpec",
48
+ "GoneError",
49
+ "Imejis",
50
+ "ImejisConfigError",
51
+ "ImejisError",
52
+ "InternalServerError",
53
+ "NotFoundError",
54
+ "PermissionDeniedError",
55
+ "RENDER_FORMATS",
56
+ "RateLimitError",
57
+ "RenderedImage",
58
+ "SizeVariation",
59
+ "StoredRender",
60
+ "TimeoutError",
61
+ "__version__",
62
+ ]