### Python Example for QGPT Relevance Endpoint Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/56-QGPTApi.md Demonstrates how to call the /qgpt/relevance endpoint using the pieces_os_client library. This snippet shows the setup, API call, and response handling. Ensure the Pieces OS client is installed and the server is running. ```python import pieces_os_client from pieces_os_client.models.qgpt_relevance_input import QGPTRelevanceInput from pieces_os_client.models.qgpt_relevance_output import QGPTRelevanceOutput from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.QGPTApi(api_client) qgpt_relevance_input = pieces_os_client.QGPTRelevanceInput() # QGPTRelevanceInput | (optional) try: # /qgpt/relevance [POST] api_response = api_instance.relevance(qgpt_relevance_input=qgpt_relevance_input) print("The response of QGPTApi->relevance:\n") pprint(api_response) except Exception as e: print("Exception when calling QGPTApi->relevance: %s\n" % e) ``` -------------------------------- ### Launch Pieces OS Server on Linux Source: https://github.com/pieces-app/documentation/blob/main/static/assets/_azuredatastudio_out/readme.ads.md Starts the Pieces for Developers OS Server background service. This command should be run after installation and connection setup. ```shell $ pieces-os ``` -------------------------------- ### Backup Asset Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/17-BackupApi.md Demonstrates how to use the backup_asset function from the Pieces OS client library to back up an asset. Ensure the Pieces OS client is installed and configured. This example shows basic usage with default settings. ```python import pieces_os_client from pieces_os_client.models.asset import Asset from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.BackupApi(api_client) asset = pieces_os_client.Asset() # Asset | (optional) try: # /backup/asset [POST] api_instance.backup_asset(asset=asset) except Exception as e: print("Exception when calling BackupApi->backup_asset: %s\n" % e) ``` -------------------------------- ### Python Example for QGPT Reprompt Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/56-QGPTApi.md Demonstrates how to use the QGPTApi to call the reprompt endpoint with Python. Ensure the Pieces OS client is installed and configured. ```python import pieces_os_client from pieces_os_client.models.qgpt_reprompt_input import QGPTRepromptInput from pieces_os_client.models.qgpt_reprompt_output import QGPTRepromptOutput from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.QGPTApi(api_client) qgpt_reprompt_input = pieces_os_client.QGPTRepromptInput() # QGPTRepromptInput | (optional) try: # /qgpt/reprompt [POST] api_response = api_instance.reprompt(qgpt_reprompt_input=qgpt_reprompt_input) print("The response of QGPTApi->reprompt:\n") pprint(api_response) except Exception as e: print("Exception when calling QGPTApi->reprompt: %s\n" % e) ``` -------------------------------- ### Install Pieces OS Server on Linux Source: https://github.com/pieces-app/documentation/blob/main/static/assets/_azuredatastudio_out/readme.ads.md Installs the Pieces for Developers OS Server using Snapcraft. This is the initial step for Linux installations. ```shell $ sudo snap install pieces-os ``` -------------------------------- ### Python PKCE Respond with Code Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/49-PKCEApi.md Demonstrates how to use the respond_with_code function from the pieces_os_client library to handle a PKCE authorization callback. Ensure the pieces_os_client library is installed and the host configuration is correct. ```python import pieces_os_client from pieces_os_client.models.embedded_model_schema import EmbeddedModelSchema from pieces_os_client.models.pkce import PKCE from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.PKCEApi(api_client) code = 'code_example' # str | The PKCE Code to be used to access a Token. state = 'state_example' # str | Likely the state that will be returned which should match the requested state as well as the nonce var_schema = pieces_os_client.EmbeddedModelSchema() # EmbeddedModelSchema | (optional) try: # /pkce/response/code [POST] api_response = api_instance.respond_with_code(code, state, var_schema=var_schema) print("The response of PKCEApi->respond_with_code:\n") pprint(api_response) except Exception as e: print("Exception when calling PKCEApi->respond_with_code: %s\n" % e) ``` -------------------------------- ### Install Pieces OS Client Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/index.mdx Use pip to install the Pieces SDK package. Ensure you have Python and pip installed. ```shell pip install pieces-os-client ``` -------------------------------- ### Install Dependencies Source: https://github.com/pieces-app/documentation/blob/main/README.md Install all project dependencies using pnpm. This command should be run after installing pnpm and cloning the repository. ```shell pnpm install ``` -------------------------------- ### Install Pieces via Homebrew Source: https://github.com/pieces-app/documentation/blob/main/docs/installation-getting-started/macos.mdx Use this command to install the Pieces package and Pieces OS using Homebrew. Ensure Homebrew is installed first. ```shell brew install --cask pieces ``` -------------------------------- ### Python SDK HTML Share Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/52-PieceApi.md Demonstrates how to use the `html_share` method from the `PieceApi` class in the Python SDK to get a preview of a public Piece. Ensure the Pieces OS client is configured with the correct host. ```python import pieces_os_client from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.PieceApi(api_client) p = 'p_example' # str | this is the a query param, that a shortened version of the share. try: # / [GET] api_response = api_instance.html_share(p) print("The response of PieceApi->html_share:\n") pprint(api_response) except Exception as e: print("Exception when calling PieceApi->html_share: %s\n" % e) ``` -------------------------------- ### Verify Pieces CLI Installation Source: https://github.com/pieces-app/documentation/blob/main/docs/extensions-plugins/cli/quickstart.mdx Run this command in your terminal to verify that the Pieces CLI has been installed successfully. It will display the installed version. ```bash pieces version ``` -------------------------------- ### Python Example for Searching Assets Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/15-AssetsApi.md This Python snippet demonstrates how to use the AssetsApi to search for assets. It shows how to configure the API client, set search parameters like query, transferables, searchable_tags, and pseudo, and handle the API response or exceptions. Ensure the pieces_os_client library is installed. ```python import pieces_os_client from pieces_os_client.models.searched_assets import SearchedAssets from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.AssetsApi(api_client) query = 'query_example' # str | This is a string that you can use to search your assets. (optional) transferables = True # bool | This is a boolean that will decided if we are want to return the transferable data (default) or not(performance enhancement) (optional) searchable_tags = 'searchable_tags_example' # str | This is a comma separated value of tags used for search. (optional) pseudo = True # bool | This is helper boolean that will give you the ability to also include your pseudo assets, we will always default to false. (optional) try: # /assets/search?query=string [GET] api_response = api_instance.assets_search_assets(query=query, transferables=transferables, searchable_tags=searchable_tags, pseudo=pseudo) print("The response of AssetsApi->assets_search_assets:\n") pprint(api_response) except Exception as e: print("Exception when calling AssetsApi->assets_search_assets: %s\n" % e) ``` -------------------------------- ### Install vim-plug Package Manager Source: https://github.com/pieces-app/documentation/blob/main/docs/extensions-plugins/neovim/quickstart.mdx Install the vim-plug package manager for Neovim. This command downloads and installs the plug.vim script. ```bash sh -c 'curl -fLo "${XDG_DATA_HOME:-"$HOME/.local/share"}"/nvim/site/autoload/plug.vim \ --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' ``` -------------------------------- ### Run Documentation Locally Source: https://github.com/pieces-app/documentation/blob/main/README.md Start a local development server for the documentation. Changes will be reflected live without needing to restart the server. ```shell pnpm run start ``` -------------------------------- ### Get Specific Application Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/13-ApplicationsApi.md Retrieves a snapshot of a specific application using its UUID. Ensure the pieces_os_client library is installed and configured with the correct host. This example demonstrates basic API client instantiation and method invocation. ```python import pieces_os_client from pieces_os_client.models.application import Application from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.ApplicationsApi(api_client) application = 'application_example' # str | This is a uuid that represents an application try: # /applications/\{application\} [GET] api_response = api_instance.applications_specific_application_snapshot(application) print("The response of ApplicationsApi->applications_specific_application_snapshot:\n") pprint(api_response) except Exception as e: print("Exception when calling ApplicationsApi->applications_specific_application_snapshot: %s\n" % e) ``` -------------------------------- ### Create Neovim Configuration File Source: https://github.com/pieces-app/documentation/blob/main/docs/extensions-plugins/neovim/quickstart.mdx Create the Neovim configuration directory and the init.vim file if they do not exist. ```bash mkdir -p ~/.config/nvim touch ~/.config/nvim/init.vim ``` -------------------------------- ### Refresh User Profile Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/70-UserApi.md Use this Python snippet to refresh a user's profile via the User API. Ensure the pieces_os_client is installed and configured with the correct host. This example demonstrates making a GET request to the /user/refresh endpoint. ```python import pieces_os_client from pieces_os_client.models.user_profile import UserProfile from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.UserApi(api_client) try: # /user/refresh [GET] api_response = api_instance.refresh_user() print("The response of UserApi->refresh_user:\n") pprint(api_response) except Exception as e: print("Exception when calling UserApi->refresh_user: %s\n" % e) ``` -------------------------------- ### Full Asset Management Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/sdks/python/assets.mdx This snippet shows a complete workflow for managing assets, including initialization, retrieval, property access, content modification, classification changes, and deletion. It also demonstrates creating a new asset. ```python from pieces_os_client.wrapper import PiecesClient from pieces_os_client.basic_asset import BasicAsset from pieces_os_client import ClassificationSpecificEnum # Initialize the PiecesClient pieces_client = PiecesClient() asset = pieces_client.assets()[0] # Get the asset ID asset_id = asset.id print(f"Asset ID: {asset_id}") # Get the full asset object (only for properties not available in BasicAsset) full_asset = asset.asset print(f"Full Asset Object: {full_asset}") # Check if the asset is an image if asset.is_image: print("The asset is an image.") else: print("The asset is not an image.") # Get and set the asset name print(f"Current Asset Name: {asset.name}") asset.name = "Updated Asset Name" print(f"Updated Asset Name: {asset.name}") # Retrieve and modify the asset content content = asset.raw_content print(f"Original Content: {content}") asset.raw_content = content + "\n# This is a comment" print(f"Updated Content: {asset.raw_content}") # Get the asset classification classification = asset.classification.value if asset.classification else "None" print(f"Asset Classification: {classification}") asset.classification = ClassificationSpecificEnum.SH # Reclassify to shell print(f"New Classification: {classification}") # Get the asset description description = asset.description if asset.description else "No description available." print(f"Asset Description: {description}") # Get the asset annotations annotations = asset.annotations if asset.annotations else "No annotations available." print(f"Asset Annotations: {annotations}") # Delete the asset asset.delete() print("Asset deleted.") # Create a new asset new_asset_id = BasicAsset.create("New Asset content") print(f"New Asset ID: {new_asset_id}") pieces_client.close() ``` -------------------------------- ### Update Website Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/72-WebsiteApi.md Demonstrates how to update a website using the WebsiteApi. This example shows how to instantiate the client, set configuration, and call the website_update method. It includes error handling for API exceptions. ```python import pieces_os_client from pieces_os_client.models.website import Website from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.WebsiteApi(api_client) transferables = True # bool | This is a boolean that will decided if we are want to return the transferable data (default) or not(performance enhancement) (optional) website = pieces_os_client.Website() # Website | (optional) try: # /website/update [POST] api_response = api_instance.website_update(transferables=transferables, website=website) print("The response of WebsiteApi->website_update:\n") pprint(api_response) except Exception as e: print("Exception when calling WebsiteApi->website_update: %s\n" % e) ``` -------------------------------- ### Get a Snapshot of a Specific Range in TypeScript Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/apis/52-RangeApi.md This example demonstrates how to get a snapshot of a single range using its identifier. The range identifier is a required parameter. ```typescript import * as Pieces from '@pieces.app/pieces-os-client' const configuration = Pieces.Configuration() const apiInstance = new Pieces.RangeApi(configuration) const body: Pieces.RangesSpecificRangeSnapshotRequest = { // string | This is a identifier that is used to identify a specific range. range: range_example, }; apiInstance.rangesSpecificRangeSnapshot(body).then((data: Range) => { console.log('API called successfully. Returned data: ' + data) }).catch((error: unknown) => console.error(error)) ``` -------------------------------- ### Get Sensitives Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/63-SensitivesApi.md Retrieves a snapshot of all sensitive data. This example demonstrates setting up the API client and making the GET request to the /sensitives endpoint. ```python import pieces_os_client from pieces_os_client.models.sensitives import Sensitives from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.SensitivesApi(api_client) try: # /sensitives [GET] api_response = api_instance.sensitives_snapshot() print("The response of SensitivesApi->sensitives_snapshot:\n") pprint(api_response) except Exception as e: print("Exception when calling SensitivesApi->sensitives_snapshot: %s\n" % e) ``` -------------------------------- ### connect Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/21-ConnectorApi.md Abstracts a bootup/connection for a specific context. This method allows for initiating a connection with optional seeding information. ```APIDOC ## POST /connect ### Description Abstracts a bootup/connection for a specific context. This method allows for initiating a connection with optional seeding information. ### Method POST ### Endpoint /connect ### Parameters #### Request Body - **seeded_connector_connection** (SeededConnectorConnection) - Optional - Connection details for seeding the connector. ### Request Example ```python import pieces_os_client from pieces_os_client.models.context import Context from pieces_os_client.models.seeded_connector_connection import SeededConnectorConnection from pieces_os_client.rest import ApiException from pprint import pprint configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) with pieces_os_client.ApiClient(configuration) as api_client: api_instance = pieces_os_client.ConnectorApi(api_client) seeded_connector_connection = pieces_os_client.SeededConnectorConnection() try: api_response = api_instance.connect(seeded_connector_connection=seeded_connector_connection) print("The response of ConnectorApi->connect:\n") pprint(api_response) except Exception as e: print("Exception when calling ConnectorApi->connect: %s\n" % e) ``` ### Response #### Success Response (200) - **Context** (Context) - The connection context. #### Response Example ```json { "example": "response body" } ``` ### Error Handling - **400**: Bad Request. Application Failed to connect. Please ensure this is a valid integration. This happens in the case a developer provides an incorrect {application} (applicationId) within the route that does not match a pre-registered integration. ``` -------------------------------- ### Get Allocations Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/apis/04-AllocationsApi.md Use this snippet to retrieve a snapshot of all connected allocations. Ensure you have the '@pieces.app/pieces-os-client' library installed and configured. ```typescript import * as Pieces from '@pieces.app/pieces-os-client' const configuration = Pieces.Configuration() const apiInstance = new Pieces.AllocationsApi(configuration) apiInstance.allocationsSnapshot().then((data: Allocations) => { console.log('API called successfully. Returned data: ' + data) }).catch((error: unknown) => console.error(error)) ``` -------------------------------- ### connect Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/apis/21-ConnectorApi.md Abstracts a bootup/connection for a specific context. This method is used to establish a connection for a given context. ```APIDOC ## POST /connect ### Description Abstracts a bootup/connection for a specific context. ### Method POST ### Endpoint /connect ### Parameters #### Request Body - **seededConnectorConnection** (SeededConnectorConnection) - Description: - Notes: ### Request Example ```typescript import * as Pieces from '@pieces.app/pieces-os-client' const configuration = Pieces.Configuration() const apiInstance = new Pieces.ConnectorApi(configuration) const body: Pieces.ConnectRequest = { // SeededConnectorConnection | (optional) seededConnectorConnection: , }; apiInstance.connect(body).then((data: Context) => { console.log('API called successfully. Returned data: ' + data) }).catch((error: unknown) => console.error(error)) ``` ### Response #### Success Response (200) - **Context** (Context) - Description: #### Response Example ```json { "example": "response body" } ``` ### Error Handling - **400** - Bad Request, Application Failed to connect, Please ensure this is a valid integration. This happens in the case a developer provides and incorrect {application} (applicationId) within the route that doest match a preregisterd integration. ``` -------------------------------- ### Get All Assets Source: https://github.com/pieces-app/documentation/blob/main/docs/build/sdks/python/quickstart.mdx Retrieve all assets managed by Pieces OS using the `assets` method. This example demonstrates how to iterate through the assets and print their names. ```python from pieces_os_client.wrapper import PiecesClient # Initialize the PiecesClient pieces_client = PiecesClient() # Get all assets and print their names assets = pieces_client.assets() for asset in assets: print(f"Asset Name: {asset.name}") # Close the client pieces_client.close() ``` -------------------------------- ### Get Specific Relationship Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/59-RelationshipApi.md Use this method to retrieve a single relationship object by its UUID. Ensure the `pieces_os_client` is installed and configured with the correct host. ```python import pieces_os_client from pieces_os_client.models.relationship import Relationship from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.RelationshipApi(api_client) relationship = 'relationship_example' # str | this is a specific relationship uuid. try: # /relationship/\{relationship\} [GET] api_response = api_instance.relationships_specific_relationship_snapshot(relationship) print("The response of RelationshipApi->relationships_specific_relationship_snapshot:\n") pprint(api_response) except Exception as e: print("Exception when calling RelationshipApi->relationships_specific_relationship_snapshot: %s\n" % e) ``` -------------------------------- ### Backup Asset Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/apis/17-BackupApi.md Demonstrates how to use the backupAsset function to back up an asset. Ensure you have the Pieces OS client configured and imported. ```typescript import * as Pieces from '@pieces.app/pieces-os-client' const configuration = Pieces.Configuration() const apiInstance = new Pieces.BackupApi(configuration) const body: Pieces.BackupAssetRequest = { // Asset (optional) asset: , }; apiInstance.backupAsset(body).then((data: void (empty response body)) => { console.log('API called successfully. Returned data: ' + data) }).catch((error: unknown) => console.error(error)) ``` -------------------------------- ### Log Application Installation Event Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/13-ApplicationsApi.md Logs the installation events of the Pieces application. This snippet demonstrates how to instantiate the client, create a TrackedApplicationInstall object, and call the API. It includes error handling for API exceptions. ```python import pieces_os_client from pieces_os_client.models.tracked_application_install import TrackedApplicationInstall from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.ApplicationsApi(api_client) tracked_application_install = pieces_os_client.TrackedApplicationInstall() # TrackedApplicationInstall | (optional) try: # /applications/usage/installation [POST] api_instance.applications_usage_installation(tracked_application_install=tracked_application_install) except Exception as e: print("Exception when calling ApplicationsApi->applications_usage_installation: %s\n" % e) ``` -------------------------------- ### Get Backups Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/18-BackupsApi.md Retrieves a snapshot of backups from the cloud. This endpoint requires user authentication and connection to the cloud. Ensure the pieces_os_client is installed and configured. ```python import pieces_os_client from pieces_os_client.models.backups import Backups from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.BackupsApi(api_client) try: # /backups [GET] api_response = api_instance.backups_snapshot() print("The response of BackupsApi->backups_snapshot:\n") pprint(api_response) except Exception as e: print("Exception when calling BackupsApi->backups_snapshot: %s\n" % e) ``` -------------------------------- ### Install SDK with pnpm Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/index.mdx Install the Pieces SDK using pnpm. ```shell pnpm add @pieces.app/pieces-os-client ``` -------------------------------- ### TypeScript Asset Snapshot Post Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/apis/14-AssetApi.md Demonstrates how to retrieve a snapshot of an asset using the assetSnapshotPost function. Ensure you have the '@pieces.app/pieces-os-client' library installed and configured. ```typescript import * as Pieces from '@pieces.app/pieces-os-client' const configuration = Pieces.Configuration() const apiInstance = new Pieces.AssetApi(configuration) const body: Pieces.AssetSnapshotPostRequest = { // string | The id (uuid) of the asset that you are trying to access. asset: 2254f2c8-5797-40e8-ac56-41166dc0e159, // boolean | This is a boolean that will decided if we are want to return the transferable data (default) or not(performance enhancement) (optional) transferables: true, // SeededAccessor (optional) seededAccessor: , }; apiInstance.assetSnapshotPost(body).then((data: Asset) => { console.log('API called successfully. Returned data: ' + data) }).catch((error: unknown) => console.error(error)) ``` -------------------------------- ### Install SDK with yarn Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/index.mdx Install the Pieces SDK using yarn. ```shell yarn add @pieces.app/pieces-os-client ``` -------------------------------- ### Get User Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/70-UserApi.md Retrieves a snapshot of the current user's profile. This example demonstrates how to instantiate the User API client and call the user_snapshot method. ```python import pieces_os_client from pieces_os_client.models.returned_user_profile import ReturnedUserProfile from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.UserApi(api_client) try: # /user [GET] api_response = api_instance.user_snapshot() print("The response of UserApi->user_snapshot:\n") pprint(api_response) except Exception as e: print("Exception when calling UserApi->user_snapshot: %s\n" % e) ``` -------------------------------- ### Python Suggestion Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/21-ConnectorApi.md Demonstrates how to use the ConnectorApi's suggest method to get code snippet suggestions. This is useful when a user copies code from an integration. ```python import pieces_os_client from pieces_os_client.models.seeded_connector_creation import SeededConnectorCreation from pieces_os_client.models.suggestion import Suggestion from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.ConnectorApi(api_client) application = 'application_example' # str | seeded_connector_creation = pieces_os_client.SeededConnectorCreation() # SeededConnectorCreation | This is the Snippet that we will compare to all the saved assets to determine what we want to do with it! (optional) try: # /\{application\}/suggestion [POST] api_response = api_instance.suggest(application, seeded_connector_creation=seeded_connector_creation) print("The response of ConnectorApi->suggest:\n") pprint(api_response) except Exception as e: print("Exception when calling ConnectorApi->suggest: %s\n" % e) ``` -------------------------------- ### Get Allocations Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/04-AllocationsApi.md Retrieves a snapshot of all connected allocations. This example demonstrates how to initialize the client and call the allocations_snapshot endpoint, handling potential API exceptions. ```python import pieces_os_client from pieces_os_client.models.allocations import Allocations from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.AllocationsApi(api_client) try: # /allocations [GET] api_response = api_instance.allocations_snapshot() print("The response of AllocationsApi->allocations_snapshot:\n") pprint(api_response) except Exception as e: print("Exception when calling AllocationsApi->allocations_snapshot: %s\n" % e) ``` -------------------------------- ### Log Application Installation Events Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/apis/13-ApplicationsApi.md Use this snippet to log installation events for the Pieces application. It requires initializing the Pieces client and constructing a request body with installation details. ```typescript import * as Pieces from '@pieces.app/pieces-os-client' const configuration = Pieces.Configuration() const apiInstance = new Pieces.ApplicationsApi(configuration) const body: Pieces.ApplicationsUsageInstallationRequest = { // TrackedApplicationInstall | (optional) trackedApplicationInstall: , }; apiInstance.applicationsUsageInstallation(body).then((data: void (empty response body)) => { console.log('API called successfully. Returned data: ' + data) }).catch((error: unknown) => console.error(error)) ``` -------------------------------- ### Generate PKCE Token Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/49-PKCEApi.md This example demonstrates how to generate a PKCE token using the Pieces OS client library. It shows the necessary imports, client configuration, and how to call the generate_token endpoint. This is useful for initiating OAuth flows with PKCE. ```python import pieces_os_client from pieces_os_client.models.pkce import PKCE from pieces_os_client.models.tokenized_pkce import TokenizedPKCE from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.PKCEApi(api_client) tokenized_pkce = pieces_os_client.TokenizedPKCE() # TokenizedPKCE | The needed properties to exchange a PKCE Code for an OAuth Token (optional) try: # /pkce/token [POST] api_response = api_instance.generate_token(tokenized_pkce=tokenized_pkce) print("The response of PKCEApi->generate_token:\n") pprint(api_response) except Exception as e: print("Exception when calling PKCEApi->generate_token: %s\n" % e) ``` -------------------------------- ### Get Anchors Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/09-AnchorsApi.md Retrieves a snapshot of all anchors. This example demonstrates how to instantiate the AnchorsApi client and call the anchors_snapshot method with the option to include transferable data. ```python import pieces_os_client from pieces_os_client.models.anchors import Anchors from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.AnchorsApi(api_client) transferables = True # bool | This is a boolean that will decided if we are want to return the transferable data (default) or not(performance enhancement) (optional) try: # /anchors [GET] api_response = api_instance.anchors_snapshot(transferables=transferables) print("The response of AnchorsApi->anchors_snapshot:\n") pprint(api_response) except Exception as e: print("Exception when calling AnchorsApi->anchors_snapshot: %s\n" % e) ``` -------------------------------- ### Get Specific Annotation Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/apis/10-AnnotationApi.md Use this function to retrieve a snapshot of a specific annotation using its UUID. Ensure you have the Pieces OS client library installed and configured. ```typescript import * as Pieces from '@pieces.app/pieces-os-client' const configuration = Pieces.Configuration() const apiInstance = new Pieces.AnnotationApi(configuration) const body: Pieces.AnnotationSpecificAnnotationSnapshotRequest = { // string | This is a specific annotation uuid. annotation: annotation_example, }; apiInstance.annotationSpecificAnnotationSnapshot(body).then((data: Annotation) => { console.log('API called successfully. Returned data: ' + data) }).catch((error: unknown) => console.error(error)) ``` -------------------------------- ### Initiate Application Session Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/13-ApplicationsApi.md Use this snippet to start a new user session with the Pieces application. Ensure the Pieces OS client is installed and configured. This endpoint is deprecated. ```python import pieces_os_client from pieces_os_client.models.session import Session from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.ApplicationsApi(api_client) try: # /applications/session/open [POST] api_response = api_instance.applications_session_open() print("The response of ApplicationsApi->applications_session_open:\n") pprint(api_response) except Exception as e: print("Exception when calling ApplicationsApi->applications_session_open: %s\n" % e) ``` -------------------------------- ### Update Person Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/apis/48-PersonApi.md Demonstrates how to update a specific person using the PersonApi. Ensure you have the Pieces client library installed and configured. The 'transferables' flag can be used for performance optimization. ```typescript import * as Pieces from '@pieces.app/pieces-os-client' const configuration = Pieces.Configuration() const apiInstance = new Pieces.PersonApi(configuration) const body: Pieces.UpdatePersonRequest = { // boolean | This is a boolean that will decided if we are want to return the transferable data (default) or not(performance enhancement) (optional) transferables: true, // Person (optional) person: , }; apiInstance.updatePerson(body).then((data: Person) => { console.log('API called successfully. Returned data: ' + data) }).catch((error: unknown) => console.error(error)) ``` -------------------------------- ### applications_usage_installation Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/13-ApplicationsApi.md Logs the installation events of the Pieces application. This method is deprecated. ```APIDOC ## POST /applications/usage/installation ### Description Logs the installation events of the Pieces application. ### Method POST ### Endpoint /applications/usage/installation ### Parameters #### Request Body - **tracked_application_install** (TrackedApplicationInstall) - Optional - Used to log installation details. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) void (empty response body) #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Python ConnectorApi Intention Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/21-ConnectorApi.md Demonstrates how to use the ConnectorApi's intention endpoint to send a SeededAsset for future comparison. Ensure the Pieces OS client is installed and configured. ```python import pieces_os_client from pieces_os_client.models.seeded_connector_asset import SeededConnectorAsset from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.ConnectorApi(api_client) application = 'application_example' # str | seeded_connector_asset = pieces_os_client.SeededConnectorAsset() # SeededConnectorAsset | (optional) try: # /\{application\}/intention [POST] api_response = api_instance.intention(application, seeded_connector_asset=seeded_connector_asset) print("The response of ConnectorApi->intention:\n") pprint(api_response) except Exception as e: print("Exception when calling ConnectorApi->intention: %s\n" % e) ``` -------------------------------- ### Install Published Pieces OS Client Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/models/263-README.md Install the published version of the Pieces OS Client package into your consuming project. ```bash npm install @pieces.app/pieces-os-client@1.0 --save ``` -------------------------------- ### Python QGPT Stream Example Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/56-QGPTApi.md This Python snippet demonstrates how to establish a WebSocket connection to the QGPT model using the pieces_os_client library. It shows how to instantiate the QGPT API client, prepare the stream input, and handle the streaming output or potential exceptions. It is useful for real-time interaction with the QGPT model. ```python import pieces_os_client from pieces_os_client.models.qgpt_stream_input import QGPTStreamInput from pieces_os_client.models.qgpt_stream_output import QGPTStreamOutput from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.QGPTApi(api_client) qgpt_stream_input = pieces_os_client.QGPTStreamInput() # QGPTStreamInput | (optional) try: # /qgpt/stream [WS] api_response = api_instance.qgpt_stream(qgpt_stream_input=qgpt_stream_input) print("The response of QGPTApi->qgpt_stream:\n") pprint(api_response) except Exception as e: print("Exception when calling QGPTApi->qgpt_stream: %s\n" % e) ``` -------------------------------- ### Update a Tag Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/66-TagApi.md Demonstrates how to update an existing tag using the TagApi.tag_update method. Ensure the pieces_os_client is installed and configured. This example shows setting the 'transferables' option and passing a Tag object. ```python import pieces_os_client from pieces_os_client.models.tag import Tag from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.TagApi(api_client) transferables = True # bool | This is a boolean that will decided if we are want to return the transferable data (default) or not(performance enhancement) (optional) tag = pieces_os_client.Tag() # Tag | (optional) try: # /tag/update [POST] api_response = api_instance.tag_update(transferables=transferables, tag=tag) print("The response of TagApi->tag_update:\n") pprint(api_response) except Exception as e: print("Exception when calling TagApi->tag_update: %s\n" % e) ``` -------------------------------- ### Install SDK with npm Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/typescript/index.mdx Install the Pieces SDK using npm. ```shell npm install @pieces.app/pieces-os-client ``` -------------------------------- ### Get Websites Snapshot Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/73-WebsitesApi.md Retrieves a snapshot of all websites. Set 'transferables' to True to include transferable data, or False for performance enhancement. This example demonstrates basic usage with default settings. ```python import pieces_os_client from pieces_os_client.models.websites import Websites from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.WebsitesApi(api_client) transferables = True # bool | This is a boolean that will decided if we are want to return the transferable data (default) or not(performance enhancement) (optional) try: # /websites [GET] api_response = api_instance.websites_snapshot(transferables=transferables) print("The response of WebsitesApi->websites_snapshot:\n") pprint(api_response) except Exception as e: print("Exception when calling WebsitesApi->websites_snapshot: %s\n" % e) ``` -------------------------------- ### Increment Anchor Score Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/06-AnchorApi.md Demonstrates how to increment the score of a specific anchor using the AnchorApi. Ensure the pieces_os_client library is installed and configured. This example shows the basic usage with default parameters. ```python import pieces_os_client from pieces_os_client.models.seeded_score_increment import SeededScoreIncrement from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.AnchorApi(api_client) anchor = 'anchor_example' # str | This is the specific uuid of an anchor. seeded_score_increment = pieces_os_client.SeededScoreIncrement() # SeededScoreIncrement | (optional) try: # '/anchor/\{anchor\}/scores/increment' [POST] api_instance.anchor_scores_increment(anchor, seeded_score_increment=seeded_score_increment) except Exception as e: print("Exception when calling AnchorApi->anchor_scores_increment: %s\n" % e) ``` -------------------------------- ### Linkify Multiple Assets Source: https://github.com/pieces-app/documentation/blob/main/docs/build/reference/python/apis/39-LinkifyApi.md Demonstrates how to use the linkify_multiple endpoint to process multiple assets. Ensure assets are backed up before sending their IDs. This example shows the basic setup and API call. ```python import pieces_os_client from pieces_os_client.models.linkify_multiple import LinkifyMultiple from pieces_os_client.models.shares import Shares from pieces_os_client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost:1000 # See configuration.py for a list of all supported configuration parameters. configuration = pieces_os_client.Configuration( host="http://localhost:1000" ) # Enter a context with an instance of the API client with pieces_os_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pieces_os_client.LinkifyApi(api_client) linkify_multiple = pieces_os_client.LinkifyMultiple() # LinkifyMultiple | (optional) try: # /linkify/multiple [POST] api_response = api_instance.linkify_multiple(linkify_multiple=linkify_multiple) print("The response of LinkifyApi->linkify_multiple:\n") pprint(api_response) except Exception as e: print("Exception when calling LinkifyApi->linkify_multiple: %s\n" % e) ```