### Installation and Setup Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Instructions on how to install the Publitio Python SDK and initialize the API client with your credentials. ```APIDOC ## Installation and Setup Install the SDK via pip and initialize with your API credentials from the Publitio dashboard. ```python # Install the package # pip3 install publitio from publitio import PublitioAPI # Initialize the API client with your credentials publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') ``` ``` -------------------------------- ### Installation and Initialization Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Instructions on how to install the SDK and initialize the PublitioAPI client with your API credentials. ```APIDOC ## Installation ```bash pip3 install publitio ``` This SDK works for Python 3.6 and up. ## Initialization ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='', secret='') ``` For the remaining code samples, these two lines of code will be implied. ``` -------------------------------- ### Install Publitio Python SDK Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Install the SDK using pip. This command is for Python 3.6 and up. ```bash pip3 install publitio ``` -------------------------------- ### Install and Initialize Publitio API Client Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Install the SDK using pip and initialize the API client with your Publitio API key and secret. ```python # Install the package # pip3 install publitio from publitio import PublitioAPI # Initialize the API client with your credentials publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') ``` -------------------------------- ### List Players Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get all configured media players. ```APIDOC ## List Players ### Description Get all configured media players. ### Method GET (Conceptual - SDK method abstracts this) ### Endpoint `/players` (Conceptual - SDK method abstracts this) ### Response #### Success Response (200) - **players** (array) - A list of player objects. - **id** (string) - The player ID. - **name** (string) - The name of the player. ``` -------------------------------- ### Show Folder Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get details about a specific folder. ```APIDOC ## Show Folder ### Description Get details about a specific folder. ### Method GET (Conceptual - SDK method abstracts this) ### Endpoint `/folders/{folder_id}` (Conceptual - SDK method abstracts this) ### Parameters #### Path Parameters - **folder_id** (string) - Required - The unique identifier of the folder. ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') folder_info = publitio_api.show_folder('folder_id') ``` ### Response #### Success Response (200) - **name** (string) - The name of the folder. - **files_count** (integer) - The number of files in the folder. ``` -------------------------------- ### Get Folders Tree Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get the complete hierarchical folder structure of your account. This allows for easy visualization of your organization. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Get entire folder hierarchy tree = publitio_api.folders_tree() def print_tree(folders, indent=0): for folder in folders: print(" " * indent + f"- {folder['name']}") if 'children' in folder: print_tree(folder['children'], indent + 1) print_tree(tree['folders']) ``` -------------------------------- ### Show File Version Details Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get detailed information about a specific file version, including its extension, status, and preview URL. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') version_info = publitio_api.show_version('version_id') print(f"Extension: {version_info['extension']}") print(f"Status: {version_info['status']}") print(f"URL: {version_info['url_preview']}") ``` -------------------------------- ### List Versions Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get all available versions/transcodes of a specific file. ```APIDOC ## List Versions ### Description Get all available versions/transcodes of a specific file. ### Method GET (Conceptual - SDK method abstracts this) ### Endpoint `/files/{file_id}/versions` (Conceptual - SDK method abstracts this) ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier of the file. #### Query Parameters - **limit** (integer) - Optional - The maximum number of versions to return. - **offset** (integer) - Optional - The number of versions to skip. ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.list_versions('file_id', limit=10) ``` ### Response #### Success Response (200) - **versions** (array) - A list of version objects. - **id** (string) - The version ID. - **extension** (string) - The file extension of the version. - **status** (string) - The status of the version. ``` -------------------------------- ### Show Version Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get detailed information about a specific file version. ```APIDOC ## Show Version ### Description Get detailed information about a specific file version. ### Method GET (Conceptual - SDK method abstracts this) ### Endpoint `/versions/{version_id}` (Conceptual - SDK method abstracts this) ### Parameters #### Path Parameters - **version_id** (string) - Required - The unique identifier of the version. ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') version_info = publitio_api.show_version('version_id') ``` ### Response #### Success Response (200) - **extension** (string) - The file extension of the version. - **status** (string) - The status of the version. - **url_preview** (string) - The preview URL for the version. ``` -------------------------------- ### Getting a File Player Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieves the player configuration for a specific file, optionally specifying a player ID. ```APIDOC ## Getting a file player ```python publitio_api.get_file_player('file_id', player='myplayerid') ``` ``` -------------------------------- ### Show Folder Details Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get details about a specific folder, including its name and the count of files it contains. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') folder_info = publitio_api.show_folder('folder_id') print(f"Name: {folder_info['name']}") print(f"Files count: {folder_info['files_count']}") ``` -------------------------------- ### Show File Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get detailed information about a specific file by its ID. ```APIDOC ## Show File Get detailed information about a specific file by its ID. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Get file details file_info = publitio_api.show_file('abc123') print(f"Title: {file_info['title']}") print(f"Type: {file_info['type']}") print(f"Size: {file_info['size']} bytes") print(f"Dimensions: {file_info['width']}x{file_info['height']}") print(f"URL: {file_info['url_preview']}") ``` ``` -------------------------------- ### List File Versions Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get all available versions or transcodes of a specific file. Supports limiting the number of results. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # List versions with limit response = publitio_api.list_versions('file_id', limit=10) for version in response['versions']: print(f" Version {version['id']}: {version['extension']} - {version['status']}") ``` -------------------------------- ### List Media Players Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get a list of all configured media players in your account. Displays player names and their corresponding IDs. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.list_players() for player in response['players']: print(f" {player['name']} ({player['id']})") ``` -------------------------------- ### Folders Tree Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get the complete hierarchical folder structure. ```APIDOC ## Folders Tree ### Description Get the complete hierarchical folder structure. ### Method GET (Conceptual - SDK method abstracts this) ### Endpoint `/folders/tree` (Conceptual - SDK method abstracts this) ### Response #### Success Response (200) - **folders** (array) - A nested array representing the folder hierarchy. - **id** (string) - The folder ID. - **name** (string) - The name of the folder. - **children** (array) - An array of child folders, if any. ``` -------------------------------- ### Show File Details Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get detailed information about a specific file using its ID. The response includes metadata such as title, type, size, dimensions, and URL. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Get file details file_info = publitio_api.show_file('abc123') print(f"Title: {file_info['title']}") print(f"Type: {file_info['type']}") print(f"Size: {file_info['size']} bytes") print(f"Dimensions: {file_info['width']}x{file_info['height']}") print(f"URL: {file_info['url_preview']}") ``` -------------------------------- ### Get Folders Tree Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve the hierarchical structure of all folders. ```python publitio_api.folders_tree() ``` -------------------------------- ### Show Watermark Details Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get detailed information for a specific watermark. Requires watermark ID. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') watermark_info = publitio_api.show_watermark('watermark_id') print(f"Title: {watermark_info['title']}") print(f"Position: {watermark_info['position']}") ``` -------------------------------- ### Show Adtag Details Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Get detailed information for a specific advertising tag. Requires adtag ID. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') adtag_info = publitio_api.show_adtag('adtag_id') print(f"Name: {adtag_info['name']}") print(f"Tag URL: {adtag_info['tag']}") ``` -------------------------------- ### Get File Player Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve an HTML5 media player embed code for a video or audio file. ```APIDOC ## Get File Player ### Description Retrieve an HTML5 media player embed code for a video or audio file. ### Method GET (Implicit) ### Endpoint `/files/{file_id}/player` (Conceptual - SDK method abstracts this) ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier of the file. #### Query Parameters - **player** (string) - Optional - The ID of a custom player to use. ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.get_file_player('video_file_id', player='my_player_id') ``` ### Response #### Success Response (200) - **html** (string) - The HTML embed code for the media player. ``` -------------------------------- ### Get File Player by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve the player for a specific file using its ID and an optional player ID. ```python publitio_api.get_file_player('file_id', player='myplayerid') ``` -------------------------------- ### Get File Player Embed Code Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve an HTML5 media player embed code for a video or audio file. Requires the file ID and an optional custom player ID. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Get player embed code response = publitio_api.get_file_player('video_file_id', player='my_player_id') print(f"Embed code: {response['html']}") ``` -------------------------------- ### Create Player Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Create a custom HTML5 media player configuration. ```APIDOC ## Create Player ### Description Create a custom HTML5 media player configuration. ### Method POST (Conceptual - SDK method abstracts this) ### Endpoint `/players` (Conceptual - SDK method abstracts this) ### Parameters #### Request Body - **name** (string) - Required - The name of the player. - **skin** (string) - Optional - The visual skin for the player (e.g., 'light', 'dark'). - **autoplay** (string) - Optional - Whether the player should autoplay media ('on' or 'off'). - **controls** (string) - Optional - Whether the player controls should be visible ('on' or 'off'). ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.create_player( name='custom_player', skin='light', autoplay='off', controls='on' ) ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the newly created player. ``` -------------------------------- ### Create Folder Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Create a new folder to organize your media files. ```APIDOC ## Create Folder ### Description Create a new folder to organize your media files. ### Method POST (Conceptual - SDK method abstracts this) ### Endpoint `/folders` (Conceptual - SDK method abstracts this) ### Parameters #### Request Body - **name** (string) - Required - The name of the new folder. - **parent_id** (string) - Optional - The ID of the parent folder. If not provided, the folder is created at the root level. ``` -------------------------------- ### Create Folder Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Create a new folder with a specified name. ```python publitio_api.create_folder(name='myfolder') ``` -------------------------------- ### Creating Files Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Shows how to upload files to Publitio, either from a local path or a remote URL. The file must be opened in binary read mode. ```APIDOC ## Creating files ```python publitio_api.create_file(file=open('path/to/file', 'rb'), title='My title', description='My description') ``` Please do note that the file must be opened for binary reading. **The `publitio_api.create_file` function will not close the file**. Therefore, what you will probably want to do most of the time is: ```python with open('path/to/file', 'rb') as f: publitio_api.create_file(file=f, title='My title', description='My description') ``` If you wish to upload the file from a remote URL, pass the `file_url` keyword parameter instead of the optional file parameter. For example: ```python publitio_api.create_file(file_url='https://example.com/image.png', title='My title', description='My description') ``` ``` -------------------------------- ### Listing Files Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Demonstrates how to list files in your Publitio account, with support for pagination using the `offset` parameter. String values are accepted for numeric parameters. ```APIDOC ## Listing files ```python publitio_api.list_files(offset=1) ``` It's also OK to provide strings as parameters when numbers seem logical. So, also valid: ```python publitio_api.list_files(offset='1') ``` ``` -------------------------------- ### Show Player Details Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve configuration details for a specific player. Requires player ID. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') player_info = publitio_api.show_player('player_id') print(f"Name: {player_info['name']}") print(f"Skin: {player_info['skin']}") ``` -------------------------------- ### Create Custom Media Player Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Create a custom HTML5 media player configuration. You can define settings like skin, autoplay, and controls. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.create_player( name='custom_player', skin='light', autoplay='off', controls='on' ) print(f"Player created with ID: {response['id']}") ``` -------------------------------- ### Create Player Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Create a new player with a specified name. ```python publitio_api.create_player(name='whatever') ``` -------------------------------- ### Create Folder Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Create a new folder to organize your media files. You can specify a parent folder ID to create nested structures. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Create a new folder response = publitio_api.create_folder(name='marketing_assets', parent_id='parent_folder_id') print(f"Folder created with ID: {response['id']}") ``` -------------------------------- ### Create File from Local Path Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Upload a file from a local path. The file must be opened in binary read mode. The SDK does not close the file handle. ```python publitio_api.create_file(file=open('path/to/file', 'rb'), title='My title', description='My description') ``` ```python with open('path/to/file', 'rb') as f: publitio_api.create_file(file=f, title='My title', description='My description') ``` -------------------------------- ### Create File Version Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Create a new version for an existing file, specifying the file ID and a new extension. ```python publitio_api.create_version('file_id', extension='webm') ``` -------------------------------- ### Initialize Publitio API Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Initialize the PublitioAPI object with your API key and secret. These lines are implied for subsequent code samples. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='', secret='') ``` -------------------------------- ### View Documentation with pydoc Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Access documentation from source code docstrings using the pydoc command. ```bash pydoc3 publitio ``` -------------------------------- ### List File Versions Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md List all versions of a file, optionally specifying a limit. The limit can be a number or a string. ```python publitio_api.list_versions('file_id', limit=3) # Or limit='3' ``` -------------------------------- ### List Files in Publitio Account Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve a paginated list of all files with optional filtering and sorting parameters. Supports filtering by folder, type, and ordering. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # List files with pagination response = publitio_api.list_files(offset=0, limit=20) print(f"Total files: {response['files_count']}") for file in response['files']: print(f" - {file['title']} ({file['id']}): {file['url_preview']}") # List files with filtering response = publitio_api.list_files( folder='my_folder', filter_type='image', order='created', limit=10 ) ``` -------------------------------- ### List Folders Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve a list of folders, with options to specify limit and order. ```python publitio_api.list_folders(limit=10, order='name') ``` -------------------------------- ### List Folders Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve a list of all folders in your account. ```APIDOC ## List Folders ### Description Retrieve a list of all folders in your account. ### Method GET (Conceptual - SDK method abstracts this) ### Endpoint `/folders` (Conceptual - SDK method abstracts this) ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of folders to return. - **offset** (integer) - Optional - The number of folders to skip. - **order** (string) - Optional - The field to order the folders by (e.g., 'name', 'created_at'). ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.list_folders(limit=10, order='name') ``` ### Response #### Success Response (200) - **folders** (array) - A list of folder objects. - **id** (string) - The folder ID. - **name** (string) - The name of the folder. - **files_count** (integer) - The number of files in the folder. ``` -------------------------------- ### Create File Version Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Create a new transcoded version of a file with different format or settings. Specify the file ID and the desired output extension. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Create WebM version of a video response = publitio_api.create_version('video_id', extension='webm') print(f"Version ID: {response['id']}") print(f"Status: {response['status']}") ``` -------------------------------- ### Transforming Files Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Demonstrates how to transform files using the `transformed` method, including changing extensions and dimensions. This method returns raw bytes. ```APIDOC ## Transforming files ```python publitio_api.transformed('filename.jpeg', extension='png', w=300, h=300) # If you don't wish to change the extension, you can omit it: publitio_api.transformed('filename.jpeg', w=300, h=300) ``` This would return the `bytes` of the file named `filename`, now transcoded into a PNG, with dimensions 300x300. The `extension` parameter is optional. The supported parameters are the same as [here](https://publit.io/docs/#url-based-transformations). For example, the above invocation makes a call to this URL: ```url https://media.publit.io/file/w_300,h_300/filename.png ``` ``` -------------------------------- ### List Files with Offset Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve a list of files, optionally specifying an offset. The offset can be provided as a number or a string. ```python publitio_api.list_files(offset=1) # It's also OK to provide strings as parameters when numbers seem logical. So, also valid: publitio_api.list_files(offset='1') ``` -------------------------------- ### Create Version Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Create a new transcoded version of a file with different format or settings. ```APIDOC ## Create Version ### Description Create a new transcoded version of a file with different format or settings. ### Method POST (Conceptual - SDK method abstracts this) ### Endpoint `/files/{file_id}/versions` (Conceptual - SDK method abstracts this) ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier of the file. #### Query Parameters - **extension** (string) - Required - The desired file extension for the new version (e.g., 'webm', 'mp4'). - **quality** (integer) - Optional - The desired quality setting for the transcoded version. ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.create_version('video_id', extension='webm') ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the newly created version. - **status** (string) - The current status of the version creation (e.g., 'processing', 'completed'). ``` -------------------------------- ### Create Ad Tag Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Create a new ad tag with a specified name and tag URL. ```python publitio_api.create_adtag(name='name', tag='tag') ``` -------------------------------- ### Upload File to Publitio Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Upload a new file to Publitio from a local file path or a remote URL. Files must be opened in binary read mode. The response includes file metadata and the public URL. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Upload from local file (recommended pattern using context manager) with open('images/photo.jpg', 'rb') as f: response = publitio_api.create_file( file=f, title='My Photo', description='A beautiful landscape photo', folder='landscapes' ) print(f"File uploaded with ID: {response['id']}") print(f"Public URL: {response['url_preview']}") # Upload from remote URL response = publitio_api.create_file( file_url='https://example.com/image.png', title='Remote Image', description='Downloaded from external source' ) print(f"File ID: {response['id']}") ``` -------------------------------- ### List All Adtags Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve a list of all configured advertising tags. No parameters are required. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.list_adtags() for adtag in response['adtags']: print(f" {adtag['name']} ({adtag['id']})") ``` -------------------------------- ### List Files Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve a paginated list of all files in your Publitio account with optional filtering and sorting parameters. ```APIDOC ## List Files Retrieve a paginated list of all files in your Publitio account with optional filtering and sorting parameters. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # List files with pagination response = publitio_api.list_files(offset=0, limit=20) print(f"Total files: {response['files_count']}") for file in response['files']: print(f" - {file['title']} ({file['id']}): {file['url_preview']}") # List files with filtering response = publitio_api.list_files( folder='my_folder', filter_type='image', order='created', limit=10 ) ``` ``` -------------------------------- ### Show File Version by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve details for a specific file version using its ID. ```python publitio_api.show_version('version_id') ``` -------------------------------- ### Create File from Remote URL Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Upload a file by providing its remote URL using the `file_url` parameter. ```python publitio_api.create_file(file_url='https://example.com/image.png', title='My title', description='My description') ``` -------------------------------- ### Showing a File Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieves details for a specific file using its ID. ```APIDOC ## Showing files ```python publitio_api.show_file('file_id') ``` ``` -------------------------------- ### Show File by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve details for a specific file using its ID. ```python publitio_api.show_file('file_id') ``` -------------------------------- ### Update Player Configuration Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Modify player configuration settings such as skin and autoplay. Requires player ID. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.update_player('player_id', skin='dark', autoplay='on') print(f"Player updated: {response['success']}") ``` -------------------------------- ### Player Management API Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt APIs for retrieving, updating, and deleting player configurations. ```APIDOC ## Show Player ### Description Get configuration details for a specific player. ### Method GET (assumed, based on SDK method name) ### Endpoint `/players/{player_id}` (assumed) ### Parameters #### Path Parameters - **player_id** (string) - Required - The unique identifier of the player. ### Response #### Success Response (200) - **name** (string) - The name of the player. - **skin** (string) - The skin configuration of the player. ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') player_info = publitio_api.show_player('player_id') ``` ### Response Example ```json { "name": "Example Player", "skin": "default" } ``` ``` ```APIDOC ## Update Player ### Description Modify player configuration settings. ### Method PUT (assumed, based on SDK method name) ### Endpoint `/players/{player_id}` (assumed) ### Parameters #### Path Parameters - **player_id** (string) - Required - The unique identifier of the player. #### Query Parameters - **skin** (string) - Optional - The new skin configuration for the player (e.g., 'dark'). - **autoplay** (string) - Optional - The autoplay setting for the player (e.g., 'on'). ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.update_player('player_id', skin='dark', autoplay='on') ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the player update was successful. ### Response Example ```json { "success": true } ``` ``` ```APIDOC ## Delete Player ### Description Remove a player configuration. ### Method DELETE (assumed, based on SDK method name) ### Endpoint `/players/{player_id}` (assumed) ### Parameters #### Path Parameters - **player_id** (string) - Required - The unique identifier of the player to delete. ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.delete_player('player_id') ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the player deletion was successful. ### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Create File Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Upload a new file to Publitio from a local file path or a remote URL. The method returns parsed JSON with file metadata. ```APIDOC ## Create File Upload a new file to Publitio either from a local file path or a remote URL. Files must be opened in binary read mode. The method returns parsed JSON with file metadata including the assigned file ID. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Upload from local file (recommended pattern using context manager) with open('images/photo.jpg', 'rb') as f: response = publitio_api.create_file( file=f, title='My Photo', description='A beautiful landscape photo', folder='landscapes' ) print(f"File uploaded with ID: {response['id']}") print(f"Public URL: {response['url_preview']}") # Upload from remote URL response = publitio_api.create_file( file_url='https://example.com/image.png', title='Remote Image', description='Downloaded from external source' ) print(f"File ID: {response['id']}") ``` ``` -------------------------------- ### List Players Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve a list of all available players. ```python publitio_api.list_players() ``` -------------------------------- ### Create Watermark - Publitio Python SDK Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Creates a watermark. The file must be opened in binary read mode ('rb'). This function does not close the file handle. ```python publitio_api.create_watermark(self, file=open('path/to/file', 'rb'), title='whatever') ``` -------------------------------- ### Create Adtag Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Create a new advertising tag for monetization purposes. Requires a name and tag URL. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.create_adtag( name='preroll_ad', tag='https://adserver.example.com/vast.xml' ) print(f"Adtag created with ID: {response['id']}") ``` -------------------------------- ### Handle Publitio SDK Exceptions in Python Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Use try-except blocks to catch and handle specific Publitio SDK exceptions such as UnknownStatusCode, BadJSON, and TransformationFailed. This ensures robust error management for file operations and transformations. ```python from publitio import PublitioAPI, UnknownStatusCode, TransformationFailed, BadJSON publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') try: # Attempt file operations response = publitio_api.show_file('nonexistent_id') except UnknownStatusCode as e: print(f"Unexpected API response: {e}") except BadJSON as e: print(f"Invalid response from server: {e}") try: # Attempt transformation data = publitio_api.transformed('file.jpg', w=500) except TransformationFailed as e: print(f"Could not transform file: {e}") ``` -------------------------------- ### Show Folder by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve details for a specific folder using its ID. ```python publitio_api.show_folder('folder_id') ``` -------------------------------- ### Exceptions Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Lists and describes the custom exceptions raised by the Publitio Python SDK. ```APIDOC ## Exceptions - `UnknownStatusCode` - raised when the server responds to a request with an unknown status code. - `TransformationFailed` - raised when the server fails to perform a transformation, i.e. when `publitio_api.transformed` fails. - `BadJSON` - raised when the server responds with invalid JSON. This may be due to an internal server error. ``` -------------------------------- ### List All Watermarks Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve a list of all configured watermarks. No parameters are required. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.list_watermarks() for watermark in response['watermarks']: print(f" {watermark['title']} ({watermark['id']})") ``` -------------------------------- ### Transform File with Publitio API Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve a transformed version of a media file with on-the-fly modifications like resizing or format conversion. Returns raw bytes of the transformed file. Handles potential transformation failures. ```python from publitio import PublitioAPI, TransformationFailed publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') try: # Resize image and convert to PNG transformed_bytes = publitio_api.transformed( 'photo.jpeg', extension='png', w=300, h=300 ) with open('thumbnail.png', 'wb') as f: f.write(transformed_bytes) print("Transformed image saved!") # Apply multiple transformations (crop, quality, watermark) transformed_bytes = publitio_api.transformed( 'video_thumbnail.jpg', w=640, h=480, c='fill', # crop mode q=80 # quality ) except TransformationFailed as e: print(f"Transformation failed: {e}") ``` -------------------------------- ### Create Watermark Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Upload a watermark image to be applied to media files. Requires the image file, title, position, and opacity. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Upload watermark image with open('watermark.png', 'rb') as f: response = publitio_api.create_watermark( file=f, title='company_logo', position='bottom-right', opacity=50 ) print(f"Watermark created with ID: {response['id']}") ``` -------------------------------- ### Folders API Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Endpoints for managing folders, including creating, listing, showing, updating, and deleting folders, as well as retrieving the folder tree. ```APIDOC ## Creating folders ```python publitio_api.create_folder(name='myfolder') ``` ## Listing folders ```python publitio_api.list_folders(limit=10, order='name') ``` ## Showing folders ```python publitio_api.show_folder('folder_id') ``` ## Updating folders ```python publitio_api.update_folder('folder_id', name='mynewname') ``` ## Deleting folders ```python publitio_api.delete_folder('folder_id') ``` ## Folders tree ```python publitio_api.folders_tree() ``` ``` -------------------------------- ### List Ad Tags Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve a list of all available ad tags. ```python publitio_api.list_adtags() ``` -------------------------------- ### Update File by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Update the title or description of an existing file using its ID. ```python publitio_api.update_file('file_id', title='A better title') ``` -------------------------------- ### Show Player by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve details for a specific player using its ID. ```python publitio_api.show_player('player_id') ``` -------------------------------- ### Updating a File Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Updates the metadata (e.g., title, description) of an existing file using its ID. ```APIDOC ## Updating files ```python publitio_api.update_file('file_id', title='A better title') ``` ``` -------------------------------- ### Reconvert Version Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retry converting a file version that previously failed. ```APIDOC ## Reconvert Version ### Description Retry converting a file version that previously failed. ### Method POST (Conceptual - SDK method abstracts this) ### Endpoint `/versions/{version_id}/reconvert` (Conceptual - SDK method abstracts this) ### Parameters #### Path Parameters - **version_id** (string) - Required - The unique identifier of the version to reconvert. ### Request Example ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.reconvert_version('version_id') ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the reconversion process was successfully initiated. ``` -------------------------------- ### Reconvert File Version Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retry converting a file version that previously failed. This is useful for reattempting a conversion process. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Reattempt failed conversion response = publitio_api.reconvert_version('version_id') print(f"Reconversion started: {response['success']}") ``` -------------------------------- ### Transform File Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Transform a file by specifying its name and desired extension and dimensions. The extension parameter is optional. ```python publitio_api.transformed('filename.jpeg', extension='png', w=300, h=300) # If you don't wish to change the extension, you can omit it: publitio_api.transformed('filename.jpeg', w=300, h=300) ``` -------------------------------- ### File Versions API Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Endpoints for managing file versions, including creating, listing, showing, updating, reconverting, and deleting versions. ```APIDOC ## Creating file versions ```python publitio_api.create_version('file_id', extension='webm') ``` ## Listing versions ```python publitio_api.list_versions('file_id', limit=3) # Or limit='3' ``` ## Showing versions ```python publitio_api.show_version('version_id') ``` ## Updating versions ```python publitio_api.update_version('version_id') ``` ## Reconverting versions ```python publitio_api.reconvert_version('version_id') ``` ## Deleting versions ```python publitio_api.delete_version('version_id') ``` ``` -------------------------------- ### Show Watermark - Publitio Python SDK Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Displays details for a specific watermark using its unique ID. ```python publitio_api.show_watermark('watermark_id') ``` -------------------------------- ### List Watermarks - Publitio Python SDK Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieves a list of all available watermarks. No specific parameters are required. ```python publitio_api.list_watermarks() ``` -------------------------------- ### Transform File Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Retrieve a transformed version of a media file with on-the-fly modifications like resizing, format conversion, and image adjustments. Returns raw bytes of the transformed file. ```APIDOC ## Transform File Retrieve a transformed version of a media file with on-the-fly modifications like resizing, format conversion, and image adjustments. Returns raw bytes of the transformed file. ```python from publitio import PublitioAPI, TransformationFailed publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') try: # Resize image and convert to PNG transformed_bytes = publitio_api.transformed( 'photo.jpeg', extension='png', w=300, h=300 ) with open('thumbnail.png', 'wb') as f: f.write(transformed_bytes) print("Transformed image saved!") # Apply multiple transformations (crop, quality, watermark) transformed_bytes = publitio_api.transformed( 'video_thumbnail.jpg', w=640, h=480, c='fill', # crop mode q=80 # quality ) except TransformationFailed as e: print(f"Transformation failed: {e}") ``` ``` -------------------------------- ### Update Player by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Update an existing player's properties, such as its skin, using its ID. ```python publitio_api.update_player('player_id', skin='green') ``` -------------------------------- ### Show Ad Tag by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Retrieve details for a specific ad tag using its ID. ```python publitio_api.show_adtag('adtag_id') ``` -------------------------------- ### Update File Metadata Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Modify the metadata and properties of an existing file, such as title, description, and tags, using the file's ID. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Update file properties response = publitio_api.update_file( 'abc123', title='Updated Title', description='New description for this file', tags='nature,landscape,mountain' ) print(f"File updated: {response['success']}") ``` -------------------------------- ### Players API Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Endpoints for managing video players, including creating, listing, showing, updating, and deleting players. ```APIDOC ## Creating players ```python publitio_api.create_player(name='whatever') ``` ## Listing players ```python publitio_api.list_players() ``` ## Showing players ```python publitio_api.show_player('player_id') ``` ## Updating players ```python publitio_api.update_player('player_id', skin='green') ``` ## Deleting players ```python publitio_api.delete_player('player_id') ``` ``` -------------------------------- ### Reconvert File Version by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Reconvert an existing file version using its ID. ```python publitio_api.reconvert_version('version_id') ``` -------------------------------- ### Update File Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Modify the metadata and properties of an existing file. ```APIDOC ## Update File Modify the metadata and properties of an existing file. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Update file properties response = publitio_api.update_file( 'abc123', title='Updated Title', description='New description for this file', tags='nature,landscape,mountain' ) print(f"File updated: {response['success']}") ``` ``` -------------------------------- ### Delete File Version Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Remove a specific version of a file from your Publitio account. This action is permanent. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') response = publitio_api.delete_version('version_id') print(f"Version deleted: {response['success']}") ``` -------------------------------- ### Delete Folder by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Delete a folder from Publit.io using its ID. ```python publitio_api.delete_folder('folder_id') ``` -------------------------------- ### Update File Version by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Update an existing file version using its ID. ```python publitio_api.update_version('version_id') ``` -------------------------------- ### Delete File Source: https://context7.com/sistemd/publitio-python-sdk/llms.txt Permanently remove a file from your Publitio account. ```APIDOC ## Delete File Permanently remove a file from your Publitio account. ```python from publitio import PublitioAPI publitio_api = PublitioAPI(key='your_api_key', secret='your_api_secret') # Delete a file response = publitio_api.delete_file('abc123') print(f"File deleted: {response['success']}") ``` ``` -------------------------------- ### Update Folder by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Update the name of an existing folder using its ID. ```python publitio_api.update_folder('folder_id', name='mynewname') ``` -------------------------------- ### Delete File by ID Source: https://github.com/sistemd/publitio-python-sdk/blob/master/README.md Delete a file from Publit.io using its ID. ```python publitio_api.delete_file('file_id') ```