Export users with PySisense(Python SDK)
Sometimes an Admin needs a quick and easy-to-read report about every user of a Sisense instance. This addresses that need by pulling user data out of Sisense with an automated and simple usage of the Sisense REST API.
What the Solution Does
- Creates a single, enriched users table—id, name, email, role_name, role_id, groups[{id,name}], status, last_login—ready for audits, governance reviews, and downstream workflows
- Simplifies multi-step Sisense API flows into one readable SDK call that runs steps in the correct order
- Automatically resolves cross-endpoint details: get_users_all() fetches users, looks up role and group names, and applies safe retries/backoff with consistent logging
- Returns structured results that can be exported or analyzed immediately
Why It’s Useful
- Easily produces a complete, human-readable user inventory
- Reduces time and errors in access reviews, onboarding/offboarding, and compliance checks
- Improves governance with predictable runs, traceable logs, and consistent output across environments
Setup
While you can use the SDK in any environment, this guide uses VS Code for simplicity.
Prerequisites
- Python: >= 3.9
- VS Code with the Python extension
If you don’t have them, install Python and VS Code first.
1) Create a project folder
# choose a location and create the folder
mkdir PySisense && cd PySisense
(Optional) Create a virtual environment
Use a dedicated venv named pysisense.
macOS/Linux
python3 -m venv pysisense
source pysisense/bin/activate
Windows (PowerShell)
python -m venv pysisense
pysisense\Scripts\Activate.ps1
2) Installation
Install PySisense from PyPI.
pip install pysisense
Tip: If you just created a venv, ensure it’s activated before running pip.
3) Authentication
To interact with your Sisense instance using PySisense, authentication is required.
You'll need an Admin API token, which can be generated here. Copy the generated token value.
4) Configuration
In the project's root directory, create a file named config.yaml and populate it with the provided template.
# config.yaml
# Domain can be an IP (e.g., 192.168.1.1) or hostname (e.g., example.com)
domain: ""
# Whether to use SSL (https). Set true if your Sisense is on HTTPS.
is_ssl: false
# Sisense Admin API token (keep this secure)
token: ""
Fill in your details and save the file.
5) Create a starter script
To initialize the client and call a method, create main.py with the following code:
import os
from pysisense import AccessManagement, SisenseClient
# Path to config.yaml in the same directory as this script
config_path = os.path.join(os.path.dirname(__file__), "config.yaml")
# Initialize the API client (set debug=True for verbose logs)
api_client = SisenseClient(config_file=config_path, debug=True)
# Initialize the AccessManagement module
access_mgmt = AccessManagement(api_client=api_client)
# Example: Get all users
response = access_mgmt.get_users_all()
print(response)
# Optional: Convert to a DataFrame and print
try:
df = api_client.to_dataframe(response)
print(df)
except Exception as e:
print(f"DataFrame conversion skipped: {e}")
# Optional: Export to CSV
api_client.export_to_csv(response, file_name="all_users.csv")
To run the program, execute python main.py.
RECORDING LINK
Explore the full documentation and examples in the GitHub repository:
Windows and Linux