UiPath Platform Python HTTP Client

0.1.28 · active · verified Thu Apr 16

The `uipath-platform` library provides a low-level HTTP client for programmatic access to the UiPath Platform. It is an OpenAPI-generated client exposing various platform APIs like Orchestrator (assets, queues, processes), Data Service, and Automation Cloud. The current version is `0.1.28`. While it has its own release cycle, it is closely related to the main `uipath-python` SDK, which extracted its platform module into this library.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `UipathPlatform` client and make a basic API call, such as listing assets from UiPath Orchestrator. It assumes authentication details (Organization ID, Tenant ID, and Auth Token) are provided via environment variables. Ensure your authentication token has the necessary permissions for the API calls you intend to make.

import os
from uipath_platform import UipathPlatform

# Retrieve credentials from environment variables
# Ensure these are set in your environment before running:
# UIPATH_ORGANIZATION_ID, UIPATH_TENANT_ID (optional for some calls), UIPATH_AUTH_TOKEN
# Example: export UIPATH_ORGANIZATION_ID="your_org_id"
#          export UIPATH_TENANT_ID="your_tenant_id"
#          export UIPATH_AUTH_TOKEN="Bearer your_token_string"
ORGANIZATION_ID = os.environ.get("UIPATH_ORGANIZATION_ID", "")
TENANT_ID = os.environ.get("UIPATH_TENANT_ID", "")
AUTH_TOKEN = os.environ.get("UIPATH_AUTH_TOKEN", "")
BASE_URL = os.environ.get("UIPATH_BASE_URL", "https://cloud.uipath.com")

if not (ORGANIZATION_ID and AUTH_TOKEN):
    print("Error: Missing UIPATH_ORGANIZATION_ID or UIPATH_AUTH_TOKEN environment variables.")
    print("Please set them before running this script.")
    exit(1)

try:
    # Initialize the client
    # The client object provides access to various operation groups (e.g., assets, queues).
    client = UipathPlatform(
        organization_id=ORGANIZATION_ID,
        tenant_id=TENANT_ID,
        auth_token=AUTH_TOKEN,
        base_url=BASE_URL
    )

    print(f"Successfully initialized UiPath Platform client for Organization ID: {ORGANIZATION_ID}")
    print("Attempting to list first 5 assets (requires Asset Read permission on your token)...")

    # Example: List assets from Orchestrator
    # This call requires 'x_uipath_tenantid' for Orchestrator operations.
    # Ensure your AUTH_TOKEN has the necessary scopes, e.g., 'Orchestrator.Assets.Read'.
    assets_response = client.assets.get_assets(
        organization_id=ORGANIZATION_ID,
        x_uipath_tenantid=TENANT_ID,
        top=5
    )
    
    if assets_response.status_code == 200:
        print(f"Successfully retrieved assets: {assets_response.parsed}")
    else:
        print(f"Failed to retrieve assets. Status: {assets_response.status_code}, Error: {assets_response.content}")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →