orshot 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.
orshot-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: orshot
3
+ Version: 0.1.0
4
+ Summary: Orshot API SDK for Python.
5
+ Author-email: Rishi Mohan <iamrishi.ms@gmail.com>
6
+ Project-URL: Homepage, https://orshot.com
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: requests>=2.27.1
13
+
14
+ # Orshot API Python SDK
15
+
16
+ View on pypi.org: [pypi.org/project/orshot](https://pypi.org/project/orshot/)
17
+
18
+ ## Installation
19
+
20
+ ```
21
+ pip install orshot
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ If you don't have your API key, get one from [orshot.com](https://orshot.com).
27
+
28
+ ### Initialise
29
+
30
+ ```python
31
+ os = orshot.Orshot('YOUR_ORSHOT_API_KEY')
32
+ ```
33
+
34
+ ### Render from template
35
+
36
+ ```python
37
+ response = os.render_from_template({'template_id': 'open-graph-image-1', 'modifications': {'title': 'From python sdk new'}, 'response_type': 'base64', 'response_format': 'png'})
38
+ print(response['data'])
39
+ ```
40
+
41
+ ### Generate signed URL
42
+
43
+ ```python
44
+ response = os.generate_signed_url({'template_id': 'open-graph-image-1', 'modifications': {'title': 'From python sdk new'}, 'render_type': 'images', 'response_format': 'png', 'expires_at': 1744276943})
45
+ print(response['data'])
46
+ ```
47
+
48
+ ## Example
49
+
50
+ ### `Base64` response format
51
+
52
+ ```python
53
+ import orshot
54
+
55
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
56
+ modifications = {
57
+ 'title': 'From Orshot Python SDK',
58
+ 'description': 'Create Visuals and Automate Image Generation'
59
+ }
60
+ response = os.render_from_template({
61
+ 'template_id': 'open-graph-image-1',
62
+ 'modifications': modifications,
63
+ 'response_type': 'base64',
64
+ 'response_format': 'png'
65
+ })
66
+ print(response)
67
+ ```
68
+
69
+ Base64 output
70
+
71
+ ```
72
+ {
73
+ 'data': {
74
+ 'content': 'data:image/png;base64,iVBORw0KGgoAAA',
75
+ 'format': 'png',
76
+ 'type': 'base64',
77
+ 'responseTime': 3208.03
78
+ }
79
+ }
80
+ ```
81
+
82
+ ### `Binary` response format
83
+
84
+ ```python
85
+ from io import BytesIO
86
+
87
+ import orshot
88
+ from PIL import Image
89
+
90
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
91
+ modifications = {
92
+ 'title': 'From Orshot Python SDK',
93
+ 'description': 'Create Visuals and Automate Image Generation'
94
+ }
95
+ response = os.render_from_template({
96
+ 'template_id': 'open-graph-image-1',
97
+ 'modifications': modifications,
98
+ 'response_type': 'binary',
99
+ 'response_format': 'png'
100
+ })
101
+
102
+ with Image.open(BytesIO(response.content)) as im:
103
+ im.save('og.png')
104
+ ```
105
+
106
+ This example writes the binary image to the file `og.png`
107
+
108
+ ### `URL` response format
109
+
110
+ ```python
111
+ import orshot
112
+
113
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
114
+ modifications = {
115
+ 'title': 'From Orshot Python SDK',
116
+ 'description': 'Create Visuals and Automate Image Generation'
117
+ }
118
+ response = os.render_from_template({
119
+ 'template_id': 'open-graph-image-1',
120
+ 'modifications': modifications,
121
+ 'response_type': 'url',
122
+ 'response_format': 'png'
123
+ })
124
+ print(response)
125
+ ```
126
+
127
+ URL output
128
+
129
+ ```
130
+ {
131
+ 'data': {
132
+ 'content': 'https://storage.orshot.com/00632982-fd46-44ff-9a61-f52cdf1b8e62/images/AuBgAsKzLJl.png',
133
+ 'type': 'url',
134
+ 'format': 'png',
135
+ 'responseTime': 3387.08
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### Signed URL
141
+
142
+ ```python
143
+ import orshot
144
+
145
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
146
+ modifications = {
147
+ 'title': 'From Orshot Python SDK',
148
+ 'description': 'Create Visuals and Automate Image Generation'
149
+ }
150
+
151
+ response = os.generate_signed_url({
152
+ 'template_id': 'open-graph-image-1',
153
+ 'modifications': modifications,
154
+ 'render_type': 'images',
155
+ 'response_format': 'png',
156
+ 'expires_at': 1744276943
157
+ })
158
+ print(response)
159
+ ```
160
+
161
+ Output
162
+
163
+ ```
164
+ {
165
+ "data": {
166
+ "url": "https://api.orshot.com/v1/generate/images?expiresAt=1744276943&id=28&templateId=open-graph-image-1&title=From%20python%20sdk%20new&signature=fa4ea0aa4cf05bd9b836be031dccfc26abf41dcc623561ac262c75b658f725f1"
167
+ }
168
+ }
169
+ ```
170
+
171
+ ## render_from_template
172
+
173
+ Use this function to generate an image.
174
+
175
+ | argument | required | description |
176
+ |----------|----------|-------------|
177
+ | `template_id` | Yes | ID of the template (`open-graph-image-1`, `tweet-image-1`, `beautify-screenshot-1`) |
178
+ | `modifications` | Yes | Modifications for the selected template. |
179
+ | `response_type` | No | `base64`, `binary`, `url` (Defaults to `base64`). |
180
+ | `response_format` | No | `png`, `webp`, `pdf`, `jpg`, `jpeg` (Defaults to `png`) |
181
+
182
+ For available templates and their modifications refer [Orshot Templates Page](https://orshot.com/templates)
183
+
184
+ ## generate_signed_url
185
+
186
+ Use this function to get a signed URL.
187
+
188
+ | argument | required | description |
189
+ |----------|----------|-------------|
190
+ | `template_id` | Yes | ID of the template (`open-graph-image-1`, `tweet-image-1`, `beautify-screenshot-1`) |
191
+ | `modifications` | Yes | Modifications for the selected template. |
192
+ | `expires_at` | Yes | Expires at time in UNIX timestamp (Integer) |
193
+ | `render_type` | No | `images`, `pdfs` (Defaults to `images`). |
194
+ | `response_format` | No | `png`, `webp`, `pdf`, `jpg`, `jpeg` (Defaults to `png`) |
195
+
196
+ ## Local development and testing
197
+
198
+ Install `uv` - https://docs.astral.sh/uv/getting-started/installation/#installation-methods
199
+
200
+ `uv venv` to create the virtual environment.
201
+
202
+ Uninstall before building and installing again
203
+
204
+ `uv pip uninstall orshot`
205
+
206
+ Build
207
+
208
+ `python -m build`
209
+
210
+ To install the package locally for testing
211
+
212
+ `uv pip install dist/orshot-0.2.1-py3-none-any.whl`
213
+
214
+ You can create a `test.py` file with a sample code to render an image.
orshot-0.1.0/README.md ADDED
@@ -0,0 +1,201 @@
1
+ # Orshot API Python SDK
2
+
3
+ View on pypi.org: [pypi.org/project/orshot](https://pypi.org/project/orshot/)
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ pip install orshot
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ If you don't have your API key, get one from [orshot.com](https://orshot.com).
14
+
15
+ ### Initialise
16
+
17
+ ```python
18
+ os = orshot.Orshot('YOUR_ORSHOT_API_KEY')
19
+ ```
20
+
21
+ ### Render from template
22
+
23
+ ```python
24
+ response = os.render_from_template({'template_id': 'open-graph-image-1', 'modifications': {'title': 'From python sdk new'}, 'response_type': 'base64', 'response_format': 'png'})
25
+ print(response['data'])
26
+ ```
27
+
28
+ ### Generate signed URL
29
+
30
+ ```python
31
+ response = os.generate_signed_url({'template_id': 'open-graph-image-1', 'modifications': {'title': 'From python sdk new'}, 'render_type': 'images', 'response_format': 'png', 'expires_at': 1744276943})
32
+ print(response['data'])
33
+ ```
34
+
35
+ ## Example
36
+
37
+ ### `Base64` response format
38
+
39
+ ```python
40
+ import orshot
41
+
42
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
43
+ modifications = {
44
+ 'title': 'From Orshot Python SDK',
45
+ 'description': 'Create Visuals and Automate Image Generation'
46
+ }
47
+ response = os.render_from_template({
48
+ 'template_id': 'open-graph-image-1',
49
+ 'modifications': modifications,
50
+ 'response_type': 'base64',
51
+ 'response_format': 'png'
52
+ })
53
+ print(response)
54
+ ```
55
+
56
+ Base64 output
57
+
58
+ ```
59
+ {
60
+ 'data': {
61
+ 'content': 'data:image/png;base64,iVBORw0KGgoAAA',
62
+ 'format': 'png',
63
+ 'type': 'base64',
64
+ 'responseTime': 3208.03
65
+ }
66
+ }
67
+ ```
68
+
69
+ ### `Binary` response format
70
+
71
+ ```python
72
+ from io import BytesIO
73
+
74
+ import orshot
75
+ from PIL import Image
76
+
77
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
78
+ modifications = {
79
+ 'title': 'From Orshot Python SDK',
80
+ 'description': 'Create Visuals and Automate Image Generation'
81
+ }
82
+ response = os.render_from_template({
83
+ 'template_id': 'open-graph-image-1',
84
+ 'modifications': modifications,
85
+ 'response_type': 'binary',
86
+ 'response_format': 'png'
87
+ })
88
+
89
+ with Image.open(BytesIO(response.content)) as im:
90
+ im.save('og.png')
91
+ ```
92
+
93
+ This example writes the binary image to the file `og.png`
94
+
95
+ ### `URL` response format
96
+
97
+ ```python
98
+ import orshot
99
+
100
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
101
+ modifications = {
102
+ 'title': 'From Orshot Python SDK',
103
+ 'description': 'Create Visuals and Automate Image Generation'
104
+ }
105
+ response = os.render_from_template({
106
+ 'template_id': 'open-graph-image-1',
107
+ 'modifications': modifications,
108
+ 'response_type': 'url',
109
+ 'response_format': 'png'
110
+ })
111
+ print(response)
112
+ ```
113
+
114
+ URL output
115
+
116
+ ```
117
+ {
118
+ 'data': {
119
+ 'content': 'https://storage.orshot.com/00632982-fd46-44ff-9a61-f52cdf1b8e62/images/AuBgAsKzLJl.png',
120
+ 'type': 'url',
121
+ 'format': 'png',
122
+ 'responseTime': 3387.08
123
+ }
124
+ }
125
+ ```
126
+
127
+ ### Signed URL
128
+
129
+ ```python
130
+ import orshot
131
+
132
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
133
+ modifications = {
134
+ 'title': 'From Orshot Python SDK',
135
+ 'description': 'Create Visuals and Automate Image Generation'
136
+ }
137
+
138
+ response = os.generate_signed_url({
139
+ 'template_id': 'open-graph-image-1',
140
+ 'modifications': modifications,
141
+ 'render_type': 'images',
142
+ 'response_format': 'png',
143
+ 'expires_at': 1744276943
144
+ })
145
+ print(response)
146
+ ```
147
+
148
+ Output
149
+
150
+ ```
151
+ {
152
+ "data": {
153
+ "url": "https://api.orshot.com/v1/generate/images?expiresAt=1744276943&id=28&templateId=open-graph-image-1&title=From%20python%20sdk%20new&signature=fa4ea0aa4cf05bd9b836be031dccfc26abf41dcc623561ac262c75b658f725f1"
154
+ }
155
+ }
156
+ ```
157
+
158
+ ## render_from_template
159
+
160
+ Use this function to generate an image.
161
+
162
+ | argument | required | description |
163
+ |----------|----------|-------------|
164
+ | `template_id` | Yes | ID of the template (`open-graph-image-1`, `tweet-image-1`, `beautify-screenshot-1`) |
165
+ | `modifications` | Yes | Modifications for the selected template. |
166
+ | `response_type` | No | `base64`, `binary`, `url` (Defaults to `base64`). |
167
+ | `response_format` | No | `png`, `webp`, `pdf`, `jpg`, `jpeg` (Defaults to `png`) |
168
+
169
+ For available templates and their modifications refer [Orshot Templates Page](https://orshot.com/templates)
170
+
171
+ ## generate_signed_url
172
+
173
+ Use this function to get a signed URL.
174
+
175
+ | argument | required | description |
176
+ |----------|----------|-------------|
177
+ | `template_id` | Yes | ID of the template (`open-graph-image-1`, `tweet-image-1`, `beautify-screenshot-1`) |
178
+ | `modifications` | Yes | Modifications for the selected template. |
179
+ | `expires_at` | Yes | Expires at time in UNIX timestamp (Integer) |
180
+ | `render_type` | No | `images`, `pdfs` (Defaults to `images`). |
181
+ | `response_format` | No | `png`, `webp`, `pdf`, `jpg`, `jpeg` (Defaults to `png`) |
182
+
183
+ ## Local development and testing
184
+
185
+ Install `uv` - https://docs.astral.sh/uv/getting-started/installation/#installation-methods
186
+
187
+ `uv venv` to create the virtual environment.
188
+
189
+ Uninstall before building and installing again
190
+
191
+ `uv pip uninstall orshot`
192
+
193
+ Build
194
+
195
+ `python -m build`
196
+
197
+ To install the package locally for testing
198
+
199
+ `uv pip install dist/orshot-0.2.1-py3-none-any.whl`
200
+
201
+ You can create a `test.py` file with a sample code to render an image.
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "orshot"
7
+ version = "0.1.0"
8
+ description = "Orshot API SDK for Python."
9
+ readme = "README.md"
10
+ authors = [
11
+ { name = "Rishi Mohan", email = "iamrishi.ms@gmail.com" }
12
+ ]
13
+ license = { file = "LICENSE" }
14
+ classifiers = [
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python",
17
+ "Programming Language :: Python :: 3",
18
+ ]
19
+ dependencies = [
20
+ "requests>=2.27.1",
21
+ ]
22
+ requires-python = ">=3.6"
23
+
24
+ [project.urls]
25
+ Homepage = "https://orshot.com"
orshot-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
orshot-0.1.0/setup.py ADDED
@@ -0,0 +1,3 @@
1
+ from setuptools import setup
2
+
3
+ setup()
@@ -0,0 +1 @@
1
+ from orshot.orshot import Orshot
@@ -0,0 +1,6 @@
1
+ ORSHOT_SOURCE = "orshot-python-sdk";
2
+ ORSHOT_API_BASE_URL = "https://api.orshot.com";
3
+ ORSHOT_API_VERSION = "v1";
4
+ DEFAULT_RESPONSE_TYPE = "base64";
5
+ DEFAULT_RESPONSE_FORMAT = "png";
6
+ DEFAULT_RENDER_TYPE = "images";
@@ -0,0 +1,5 @@
1
+ class APIException(Exception):
2
+ pass
3
+
4
+ class BadRequestException(Exception):
5
+ pass
@@ -0,0 +1,74 @@
1
+ import requests
2
+ from orshot.constants import (
3
+ ORSHOT_SOURCE,
4
+ ORSHOT_API_VERSION,
5
+ ORSHOT_API_BASE_URL,
6
+ DEFAULT_RENDER_TYPE,
7
+ DEFAULT_RESPONSE_TYPE,
8
+ DEFAULT_RESPONSE_FORMAT
9
+ )
10
+ from orshot.types import RenderOptions, SignedUrlOptions
11
+ from orshot.exceptions import APIException, BadRequestException
12
+
13
+ class Orshot:
14
+ def __init__(self, api_key: str):
15
+ self.api_key = api_key
16
+
17
+ def _get_base_url(self):
18
+ return f"{ORSHOT_API_BASE_URL}/{ORSHOT_API_VERSION}"
19
+
20
+ def _get_headers(self):
21
+ return {
22
+ 'Content-Type': 'application/json',
23
+ 'Authorization': f'Bearer {self.api_key}'
24
+ }
25
+
26
+ def render_from_template(self, render_options: RenderOptions):
27
+ template_id = render_options.get('template_id')
28
+ modifications = render_options.get('modifications')
29
+ response_type = render_options.get('response_type', DEFAULT_RESPONSE_TYPE)
30
+ response_format = render_options.get('response_format', DEFAULT_RESPONSE_FORMAT)
31
+
32
+ endpoint_url = f"{self._get_base_url()}/generate/images/{template_id}"
33
+
34
+ data = {
35
+ 'source': ORSHOT_SOURCE,
36
+ 'modifications': modifications,
37
+ 'response': {
38
+ 'type': response_type,
39
+ 'format': response_format
40
+ }
41
+ }
42
+
43
+ response = requests.post(endpoint_url, headers=self._get_headers(), json=data)
44
+
45
+ if response.status_code == 200:
46
+ if response_type == "base64" or response_type == "url":
47
+ return response.json()
48
+ else:
49
+ return response
50
+ elif response.status_code == 400:
51
+ error_response = response.json().get('error')
52
+
53
+ raise BadRequestException(error_response)
54
+ else:
55
+ raise APIException(f"An error occurred while generating an image. Status code: {response.status_code}. Error: {response.json().get('error')}")
56
+
57
+ def generate_signed_url(self, signed_url_options: SignedUrlOptions):
58
+ endpoint_url = f"{self._get_base_url()}/signed-url/create"
59
+
60
+ data = {
61
+ 'source': ORSHOT_SOURCE,
62
+ 'templateId': signed_url_options.get('template_id'),
63
+ 'modifications': signed_url_options.get('modifications'),
64
+ 'responseFormat': signed_url_options.get('response_format', DEFAULT_RESPONSE_FORMAT),
65
+ 'renderType': signed_url_options.get('render_type', DEFAULT_RENDER_TYPE),
66
+ 'expiresAt': signed_url_options.get('expires_at')
67
+ }
68
+
69
+ response = requests.post(endpoint_url, headers=self._get_headers(), json=data)
70
+
71
+ if response.status_code == 200:
72
+ return response.json()
73
+ else:
74
+ raise APIException(f"An error occurred while generating a signed URL. Status code: {response.status_code}. Error: {response.json()}")
@@ -0,0 +1,16 @@
1
+ from dataclasses import dataclass
2
+
3
+ @dataclass
4
+ class RenderOptions:
5
+ template_id: str
6
+ modifications: dict
7
+ response_type: str
8
+ response_format: str
9
+
10
+ @dataclass
11
+ class SignedUrlOptions:
12
+ template_id: str
13
+ response_format: str
14
+ render_type: str
15
+ modifications: dict
16
+ expires_at: int
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: orshot
3
+ Version: 0.1.0
4
+ Summary: Orshot API SDK for Python.
5
+ Author-email: Rishi Mohan <iamrishi.ms@gmail.com>
6
+ Project-URL: Homepage, https://orshot.com
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: requests>=2.27.1
13
+
14
+ # Orshot API Python SDK
15
+
16
+ View on pypi.org: [pypi.org/project/orshot](https://pypi.org/project/orshot/)
17
+
18
+ ## Installation
19
+
20
+ ```
21
+ pip install orshot
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ If you don't have your API key, get one from [orshot.com](https://orshot.com).
27
+
28
+ ### Initialise
29
+
30
+ ```python
31
+ os = orshot.Orshot('YOUR_ORSHOT_API_KEY')
32
+ ```
33
+
34
+ ### Render from template
35
+
36
+ ```python
37
+ response = os.render_from_template({'template_id': 'open-graph-image-1', 'modifications': {'title': 'From python sdk new'}, 'response_type': 'base64', 'response_format': 'png'})
38
+ print(response['data'])
39
+ ```
40
+
41
+ ### Generate signed URL
42
+
43
+ ```python
44
+ response = os.generate_signed_url({'template_id': 'open-graph-image-1', 'modifications': {'title': 'From python sdk new'}, 'render_type': 'images', 'response_format': 'png', 'expires_at': 1744276943})
45
+ print(response['data'])
46
+ ```
47
+
48
+ ## Example
49
+
50
+ ### `Base64` response format
51
+
52
+ ```python
53
+ import orshot
54
+
55
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
56
+ modifications = {
57
+ 'title': 'From Orshot Python SDK',
58
+ 'description': 'Create Visuals and Automate Image Generation'
59
+ }
60
+ response = os.render_from_template({
61
+ 'template_id': 'open-graph-image-1',
62
+ 'modifications': modifications,
63
+ 'response_type': 'base64',
64
+ 'response_format': 'png'
65
+ })
66
+ print(response)
67
+ ```
68
+
69
+ Base64 output
70
+
71
+ ```
72
+ {
73
+ 'data': {
74
+ 'content': 'data:image/png;base64,iVBORw0KGgoAAA',
75
+ 'format': 'png',
76
+ 'type': 'base64',
77
+ 'responseTime': 3208.03
78
+ }
79
+ }
80
+ ```
81
+
82
+ ### `Binary` response format
83
+
84
+ ```python
85
+ from io import BytesIO
86
+
87
+ import orshot
88
+ from PIL import Image
89
+
90
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
91
+ modifications = {
92
+ 'title': 'From Orshot Python SDK',
93
+ 'description': 'Create Visuals and Automate Image Generation'
94
+ }
95
+ response = os.render_from_template({
96
+ 'template_id': 'open-graph-image-1',
97
+ 'modifications': modifications,
98
+ 'response_type': 'binary',
99
+ 'response_format': 'png'
100
+ })
101
+
102
+ with Image.open(BytesIO(response.content)) as im:
103
+ im.save('og.png')
104
+ ```
105
+
106
+ This example writes the binary image to the file `og.png`
107
+
108
+ ### `URL` response format
109
+
110
+ ```python
111
+ import orshot
112
+
113
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
114
+ modifications = {
115
+ 'title': 'From Orshot Python SDK',
116
+ 'description': 'Create Visuals and Automate Image Generation'
117
+ }
118
+ response = os.render_from_template({
119
+ 'template_id': 'open-graph-image-1',
120
+ 'modifications': modifications,
121
+ 'response_type': 'url',
122
+ 'response_format': 'png'
123
+ })
124
+ print(response)
125
+ ```
126
+
127
+ URL output
128
+
129
+ ```
130
+ {
131
+ 'data': {
132
+ 'content': 'https://storage.orshot.com/00632982-fd46-44ff-9a61-f52cdf1b8e62/images/AuBgAsKzLJl.png',
133
+ 'type': 'url',
134
+ 'format': 'png',
135
+ 'responseTime': 3387.08
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### Signed URL
141
+
142
+ ```python
143
+ import orshot
144
+
145
+ os = orshot.Orshot('os-he2jdus1cbz1dpt4mktgjyvx')
146
+ modifications = {
147
+ 'title': 'From Orshot Python SDK',
148
+ 'description': 'Create Visuals and Automate Image Generation'
149
+ }
150
+
151
+ response = os.generate_signed_url({
152
+ 'template_id': 'open-graph-image-1',
153
+ 'modifications': modifications,
154
+ 'render_type': 'images',
155
+ 'response_format': 'png',
156
+ 'expires_at': 1744276943
157
+ })
158
+ print(response)
159
+ ```
160
+
161
+ Output
162
+
163
+ ```
164
+ {
165
+ "data": {
166
+ "url": "https://api.orshot.com/v1/generate/images?expiresAt=1744276943&id=28&templateId=open-graph-image-1&title=From%20python%20sdk%20new&signature=fa4ea0aa4cf05bd9b836be031dccfc26abf41dcc623561ac262c75b658f725f1"
167
+ }
168
+ }
169
+ ```
170
+
171
+ ## render_from_template
172
+
173
+ Use this function to generate an image.
174
+
175
+ | argument | required | description |
176
+ |----------|----------|-------------|
177
+ | `template_id` | Yes | ID of the template (`open-graph-image-1`, `tweet-image-1`, `beautify-screenshot-1`) |
178
+ | `modifications` | Yes | Modifications for the selected template. |
179
+ | `response_type` | No | `base64`, `binary`, `url` (Defaults to `base64`). |
180
+ | `response_format` | No | `png`, `webp`, `pdf`, `jpg`, `jpeg` (Defaults to `png`) |
181
+
182
+ For available templates and their modifications refer [Orshot Templates Page](https://orshot.com/templates)
183
+
184
+ ## generate_signed_url
185
+
186
+ Use this function to get a signed URL.
187
+
188
+ | argument | required | description |
189
+ |----------|----------|-------------|
190
+ | `template_id` | Yes | ID of the template (`open-graph-image-1`, `tweet-image-1`, `beautify-screenshot-1`) |
191
+ | `modifications` | Yes | Modifications for the selected template. |
192
+ | `expires_at` | Yes | Expires at time in UNIX timestamp (Integer) |
193
+ | `render_type` | No | `images`, `pdfs` (Defaults to `images`). |
194
+ | `response_format` | No | `png`, `webp`, `pdf`, `jpg`, `jpeg` (Defaults to `png`) |
195
+
196
+ ## Local development and testing
197
+
198
+ Install `uv` - https://docs.astral.sh/uv/getting-started/installation/#installation-methods
199
+
200
+ `uv venv` to create the virtual environment.
201
+
202
+ Uninstall before building and installing again
203
+
204
+ `uv pip uninstall orshot`
205
+
206
+ Build
207
+
208
+ `python -m build`
209
+
210
+ To install the package locally for testing
211
+
212
+ `uv pip install dist/orshot-0.2.1-py3-none-any.whl`
213
+
214
+ You can create a `test.py` file with a sample code to render an image.
@@ -0,0 +1,13 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ src/orshot/__init__.py
5
+ src/orshot/constants.py
6
+ src/orshot/exceptions.py
7
+ src/orshot/orshot.py
8
+ src/orshot/types.py
9
+ src/orshot.egg-info/PKG-INFO
10
+ src/orshot.egg-info/SOURCES.txt
11
+ src/orshot.egg-info/dependency_links.txt
12
+ src/orshot.egg-info/requires.txt
13
+ src/orshot.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.27.1
@@ -0,0 +1 @@
1
+ orshot