UiPath Python SDK
The UiPath Python SDK provides programmatic interaction with UiPath Cloud Platform services, including processes, assets, buckets, context grounding, data services, and jobs. It also features a CLI for creation, packaging, and deployment of automations to the UiPath Cloud Platform. The library is actively developed, with minor releases (X.Y.0) potentially introducing breaking changes and patch releases (X.Y.Z) for bug fixes and new features, usually on a monthly or bi-monthly cadence.
Warnings
- breaking The schema 'type' field for coded functions changed from 'agent' to 'function'. This affects how `UiPathFunctionsRuntime.get_schema()` behaves if you were expecting 'type: agent'.
- breaking The `platform` module, including the main `UiPath` class, was extracted into a new `uipath-platform` library. Additionally, `context grounding` contract changes removed `PreProcessing` and `Fields`, and added `extraction_strategy`, `embeddings_enabled`, `is_encrypted`.
- breaking Version 2.2.0 introduced several breaking changes related to Studio Web Integration (`uipath push`/`uipath pull` commands) and the new Evaluation Framework (`uipath eval` command).
- gotcha While the `uipath` Python SDK itself requires Python >=3.11, users integrating Python scripts via UiPath Studio's 'Python Activities' (a separate UiPath package) might encounter compatibility issues with Python versions newer than 3.10 or 3.12, depending on the UiPath Studio version. Always check the UiPath Studio documentation for 'Python Activities' specific compatibility if using that integration method.
Install
-
pip install uipath
Imports
- UiPath
from uipath.platform import UiPath
Quickstart
import os
from uipath.platform import UiPath
# Configure environment variables (replace with your actual values or .env file)
UIPATH_URL = os.environ.get('UIPATH_URL', 'https://cloud.uipath.com/ACCOUNT_NAME/TENANT_NAME')
UIPATH_ACCESS_TOKEN = os.environ.get('UIPATH_ACCESS_TOKEN', 'YOUR_TOKEN_HERE')
# Ensure environment variables are set for authentication
if not UIPATH_URL or not UIPATH_ACCESS_TOKEN:
print("Please set UIPATH_URL and UIPATH_ACCESS_TOKEN environment variables.")
exit(1)
os.environ['UIPATH_URL'] = UIPATH_URL
os.environ['UIPATH_ACCESS_TOKEN'] = UIPATH_ACCESS_TOKEN
try:
# Initialize the SDK
sdk = UiPath()
print(f"Successfully initialized UiPath SDK for URL: {UIPATH_URL}")
# Example: List available processes (requires appropriate permissions)
# Note: Error handling for API calls should be implemented in production code
processes = sdk.processes.list()
print(f"Found {len(processes)} processes:")
for p in processes:
print(f" - {p.name} (Key: {p.key})")
# Example: Invoke a process (uncomment and modify for actual use)
# job = sdk.processes.invoke(
# name="MyProcess",
# input_arguments={"param1": "value1", "param2": 42}
# )
# print(f"Process invoked, Job ID: {job.id}")
except Exception as e:
print(f"An error occurred: {e}")