prolin_smartsuite_restapi
release 26.7.1
The prolin_smartsuite_restapi python library simplifies using the Smart Suite RESTAPI in a python program.
Introduction
The prolin-smartsuite-restapi library is a Python package designed to simplify interactions with the PROLIN SmartSuite Power Server RESTAPI. It provides a high-level client for authentication, session management, abstracting the complexities of OData and token handling.
The library supports encrypted storage of credentials and tokens, and offers both manual and context-managed session handling.
Installation
You can install the package using pip or another package manager using the URL to the platform independent WHL file:
pip install \
https://support.prolin.com/_files/restapi/prolin_smartsuite_restapi-26.7.1-py3-none-any.whlDependencies
The library requires Python >= 3.12 and depends on:
httpx2: For HTTP requests.lxml: For XML processing.xmltodict: For converting XML metadata to JSON.cryptography: For encrypting sensitive information.
Core Component
SmartSuiteClient
The SmartSuiteClient is the primary entry point for the library. It handles authentication and provides authenticated httpx2.Client sessions.
Initialization
import prolin_smartsuite_restapi
client = prolin_smartsuite_restapi.SmartSuiteClient(
hostname="your_odata_service",
port=5181,
username="your_app_username",
password="your_app_password",
protocol="https", # Optional, default: "https"
verify=False # Optional, default: False (set to True for SSL verification)
)When a client session is created the base_url is set to the ODATA endpoint. Subsequent requests using the session can safely use relative URLs.
Working with Sessions
The client provides two ways to obtain an authenticated session:
1. Using the Context Manager (Recommended)
This ensures the session is properly closed and license seats are released.
with client.session() as session:
response = session.get("/ServiceRequests")
print(response.status_code)2. Manual Session Management
session = client.open_session()
try:
response = session.get("/Incidents")
# ... process response
except ...:
# ... handle exception
print("error occurred")
# close session when finished
client.logout(session)The authentication token, received when successfully logging in, will expire after an hour, even if the session is still active. Longer running processes need to re-authenticate timely, or use the context manager before making a request.
Utilities
The library includes helper functions for common tasks.
Connectivity Check
Use ping to verify if the SmartSuite RESTAPI is accessible.
from prolin_smartsuite_restapi.utils import ping
is_alive = ping(hostname="your-server", port=5181)
if is_alive:
print("Server is responding!")Pretty Print Responses
A helper to display HTTP responses in a readable format.
from prolin_smartsuite_restapi.utils import pretty_print_response
with client.session() as session:
response = session.get("/Persons")
pretty_print_response(response)Advanced Features
Token Encryption
The library automatically encrypts access and refresh tokens in memory using the cryptography library. This provides an additional layer of security for long-running processes that utilize the refresh token mechanism.
Custom User-Agent
By default, the client identifies itself with a versioned User-Agent string (e.g., <<prolin_smartsuite_restapi 26.7.1>>), which is visible in the PSMC (PROLIN SmartSuite Management Console) connections overview.
Error Handling
The library defines specific exceptions in prolin_smartsuite_restapi.exceptions:
AuthenticationError: Raised when login or token processing fails.ConnectionError: Raised when the server cannot be reached or returns a connection-related error.SessionClosedError: Raised when attempting to use a session that has been closed.
License
(C)2025+ PROLIN.