A Python SDK for the Lansweeper Helpdesk API. Create, retrieve, search, and manage helpdesk tickets programmatically.
Note: The Lansweeper Helpdesk API appears to be unmaintained and may be deprecated in the future. This SDK wraps the existing API as-is.
pip install lansweeper-helpdeskfrom lansweeper_helpdesk import HelpdeskAPI
api = HelpdeskAPI(
base_url="https://your-helpdesk-url:443/api.aspx",
api_key="your-api-key",
cert_path="/path/to/cert.pem", # optional
)
# Create a ticket
ticket = api.create_ticket(
subject="Network Issue",
description="Cannot reach internal network",
email="user@example.com",
)
# Get ticket details (HTML is auto-stripped)
ticket = api.get_ticket("12345")
print(ticket["Description"])Initialize the client.
| Parameter | Type | Description |
|---|---|---|
base_url |
str |
Base URL of the Lansweeper Helpdesk API |
api_key |
str |
API key for authentication |
cert_path |
str or None |
Path to SSL certificate file (optional) |
Create a new helpdesk ticket.
api.create_ticket(
subject="Printer not working",
description="Office printer on floor 3 is offline",
email="user@company.com",
)Retrieve ticket details. HTML in the Description field is automatically converted to plain text.
ticket = api.get_ticket("12345")Get all notes for a ticket. HTML content in note text fields is auto-stripped.
notes = api.get_ticket_history("12345")
for note in notes:
print(note["Text"])Update a ticket's state and type.
api.edit_ticket(
ticket_id="12345",
state="Closed",
ticket_type="Hardware Repair",
email="agent@company.com",
)Add a note to a ticket. Use note_type="Internal" for agent-only notes.
api.add_note(
ticket_id="12345",
text="Router restart resolved the issue",
email="agent@company.com",
note_type="Internal",
)search_tickets(*, state, from_user_id, agent_id, description, subject, ticket_type, max_results, min_date, max_date) -> dict
Search tickets with optional filters. All parameters are keyword-only and optional.
results = api.search_tickets(
state="Open",
ticket_type="Hardware Repair",
max_results=50,
min_date="2024-01-01",
max_date="2024-12-31",
)Look up a user by email address.
user = api.get_user("user@company.com")The SDK provides convenience enums for common values:
from lansweeper_helpdesk import TicketState, NoteType
api.search_tickets(state=TicketState.OPEN)
api.add_note("12345", "note text", "a@b.com", note_type=NoteType.INTERNAL)All API methods raise typed exceptions instead of returning None:
from lansweeper_helpdesk import HelpdeskAPI, APIError, ConfigurationError
try:
api = HelpdeskAPI(base_url="", api_key="key")
except ConfigurationError as e:
print(f"Bad config: {e}")
try:
ticket = api.get_ticket("99999")
except APIError as e:
print(f"API error (HTTP {e.status_code}): {e}")| Exception | When |
|---|---|
HelpdeskError |
Base class for all SDK exceptions |
ConfigurationError |
Invalid client configuration |
APIError |
HTTP or API-level error (has .status_code) |
TicketNotFoundError |
Requested ticket does not exist |
You can load credentials from a JSON config file:
import json
from lansweeper_helpdesk import HelpdeskAPI
with open("config/config.json") as f:
config = json.load(f)
api = HelpdeskAPI(**config)Example config/config.json:
{
"base_url": "https://your-helpdesk-url:443/api.aspx",
"api_key": "your-api-key-here",
"cert_path": "path/to/your/certificate.pem"
}# Clone and install in dev mode
git clone https://github.com/ds-brandao/Lansweeper.Helpdesk-Python.git
cd Lansweeper.Helpdesk-Python
pip install -e ".[dev]"
# Run tests
pytest --cov
# Lint & format
ruff check src/ tests/
ruff format src/ tests/
# Type check
mypy src/See CONTRIBUTING.md for full guidelines.
MIT License — see LICENSE for details.