You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/client.md
+4-12Lines changed: 4 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,17 @@
1
-
# Pixy SDK Client API Reference
1
+
# PixyClient API Reference
2
2
3
-
The Pixy SDK Client is a Python library that provides a simple interface for interacting with the Pixy SDK. It allows you to generate images, videos, and subtitles using the Pixy API. Using the SDK, offers the following functionalities:
4
-
5
-
1. Generating images, videos, and subtitles
6
-
2. Getting previously generated resources
7
-
3. Updating previously generated resources
8
-
4. Deleting previously generated resources
9
-
10
-
## Installation
11
-
12
-
### <spanstyle="color:red">To be added</span>
3
+
The easiest approach to use the Pixy SDK is to initialize a new instance of the PixyClient class, using the API key obtained from the Pixy panel. In this page, we walk through the whole functionalities of the PixyClient class, step by step.
Initializes a new instance of the PixyClient class, given the API key. The API key is verified automatically.
20
11
21
12
#### Args:
22
13
* api_key (str): The API key obtained from the Pixy panel.
14
+
* settings (Settings): The settings to use; stick to the default value, unless you have a custom provider. Checkout the [settings documentation]() for a comprehensive instruction on how to declare custom settings.
We use a the `settings` class from [settings.py](https://github.com/pixiee-ai/pixy-sdk/blob/main/src/pixy/settings.py) to store the settings that pixy SDK relies on; currently, these settings include:
4
+
5
+
1.**url_mapping** (dict): The URL mapping to determine the endpoint, given the `generation_type`; stick to the default value, unless you have a custom provider.
6
+
2.**properties_mapping** (dict): The properties mapping to determine the type of the `properties`, given the `generation_type`; stick to the default value, unless you have a custom provider.
7
+
8
+
This class is initialized with the default values; therefore, unless you are using a custom provider, you don't need to worry about the values it contains. Moreover, as this class is a static class, its attributes are accessible without instantiating it.
9
+
10
+
In case you are using a custom provider, you are supposed to instanciate from this class with custom endpoints, as below:
Don't forget to pass the custom settings to the `PixyClient` class, as well. You are supposed to this, once instanciating from the `PixyClient` class:
25
+
26
+
```python
27
+
from pixy.client import PixyClient
28
+
29
+
# assuming that you have declared the custom settings above
30
+
31
+
client = PixyClient(api_key, settings)
32
+
33
+
```
34
+
35
+
You also need to pass the attributes from the custom `settings` class to the functions from the `pixy.utils` module, as well; checkout the [utils documentation](https://github.com/pixiee-ai/pixy-sdk/blob/main/docs/utils.md) for more details.
Generates a resource (image, video, subtitle) based on the given properties.
@@ -33,14 +34,16 @@ Generates a resource (image, video, subtitle) based on the given properties.
33
34
* generation_type (str): The type of resource to generate; current valid choices are "image", "video" and "subtitle".
34
35
* properties (ImageGenProperties | VideoGenProperties | SubtitleGenProperties): The properties of the resource to generate; current valid choices are ImageGenProperties, VideoGenProperties and SubtitleGenProperties that correspond to "image", "video" and "subtitle", respectively.
35
36
* api_key (str): The API key to use for the request.
37
+
* url_mapping (dict): The URL mapping to determine the endpoint, given the `generation_type`; stick to the default value, unless you have a custom provider.
38
+
* properties_mapping (dict): The properties mapping to determine the type of the `properties`, given the `generation_type`; stick to the default value, unless you have a custom provider.
36
39
37
40
### Returns:
38
41
* dict: A JSON response containing the generated resource.
Retrieves a resource by its unique identifier (UID).
@@ -103,14 +106,15 @@ Retrieves a resource by its unique identifier (UID).
103
106
* generation_type (str): The type of resource to retrieve; current valid choices are "image", "video" and "subtitle".
104
107
* uid (str): The desired UID.
105
108
* api_key (str): The API key to use for the request.
109
+
* url_mapping (dict): The URL mapping to determine the endpoint, given the `generation_type`; stick to the default value, unless you have a custom provider.
106
110
107
111
### Returns:
108
112
* dict: A JSON response inclding the desired resource.
Retrieves a list of resources filtered by the given parameters.
167
172
168
173
### Args:
169
174
* generation_type (str): The type of resource to retrieve.
170
-
* params (GetListParameters | None): The parameters to filter the results by.
171
175
* api_key (str): The API key to use for the request.
176
+
* params (GetListParameters | None): The parameters to filter the results by; the default value is `None`.
177
+
* url_mapping (dict): The URL mapping to determine the endpoint, given the `generation_type`; stick to the default value, unless you have a custom provider.
172
178
173
179
### Returns:
174
180
* dict: A JSON response containing the retrieved resources.
@@ -288,14 +294,15 @@ Deletes a resource by its unique identifier.
288
294
* generation_type (str): The type of resource to delete.
289
295
* uid (str): The unique identifier of the resource.
290
296
* api_key (str): The API key to use for the request.
297
+
* url_mapping (dict): The URL mapping to determine the endpoint, given the `generation_type`; stick to the default value, unless you have a custom provider.
291
298
292
299
### Returns:
293
300
* dict: A JSON response indicating the result of the deletion.
Updates a resource by its unique identifier with the given properties.
@@ -353,13 +360,14 @@ Updates a resource by its unique identifier with the given properties.
353
360
* uid (str): The unique identifier of the resource.
354
361
* properties (dict): The properties to update the resource with. This is supposed to only include the key-values to update.
355
362
* api_key (str): The API key to use for the request.
363
+
* url_mapping (dict): The URL mapping to determine the endpoint, given the `generation_type`; stick to the default value, unless you have a custom provider.
356
364
357
365
### Returns:
358
366
* dict: A JSON response containing the updated resource.
0 commit comments