Python library for Autotask PSA REST API integration
Project description
py-autotask
A comprehensive Python SDK for the Autotask REST API providing 100% complete API coverage with 193 entity implementations.
Features
- 🎯 Complete Entity Coverage - Implementation of all major Autotask REST API entities
- 🚀 Easy to Use - Intuitive API that follows Python best practices
- 🔐 Automatic Authentication - Handles zone detection and authentication seamlessly
- 📊 Full CRUD Operations - Create, Read, Update, Delete for all Autotask entities
- 🔍 Flexible Filtering - Support for multiple filter formats and complex queries
- 📄 Pagination Support - Automatic handling of paginated API responses
- ⚡ Performance Optimized - Intelligent retry logic and connection pooling
- 🛡️ Type Safe - Full type hints for better IDE support and code reliability
- 🧪 Well Tested - Comprehensive test suite with live API integration tests
- 💼 Production Ready - Robust error handling and logging
Quick Start
Installation
pip install py-autotask
Basic Usage
from py_autotask import AutotaskClient
# Create client with credentials
client = AutotaskClient.create(
username="user@example.com",
integration_code="YOUR_INTEGRATION_CODE",
secret="YOUR_SECRET"
)
# Get a ticket
ticket = client.tickets.get(12345)
print(f"Ticket: {ticket['title']}")
# Query companies
companies = client.companies.query({
"filter": [{"op": "eq", "field": "isActive", "value": "true"}]
})
# Create a new contact
new_contact = client.contacts.create({
"firstName": "John",
"lastName": "Doe",
"emailAddress": "john.doe@example.com",
"companyID": 12345
})
Environment Variables
You can also configure authentication using environment variables:
export AUTOTASK_USERNAME="user@example.com"
export AUTOTASK_INTEGRATION_CODE="YOUR_INTEGRATION_CODE"
export AUTOTASK_SECRET="YOUR_SECRET"
from py_autotask import AutotaskClient
# Client will automatically use environment variables
client = AutotaskClient.from_env()
Supported Entities
py-autotask supports all major Autotask entities:
- Tickets - Service desk tickets and related operations
- Companies - Customer and vendor company records
- Contacts - Individual contact records
- Projects - Project management and tracking
- Resources - User and technician records
- Contracts - Service contracts and agreements
- Time Entries - Time tracking and billing
- Expenses - Expense tracking and management
- Products - Product catalog and inventory
- Services - Service catalog management
Error Handling
from py_autotask.exceptions import (
AutotaskAuthError,
AutotaskAPIError,
AutotaskRateLimitError
)
try:
ticket = client.tickets.get(12345)
except AutotaskAuthError:
print("Authentication failed - check credentials")
except AutotaskRateLimitError as e:
print(f"Rate limit exceeded, retry after {e.retry_after} seconds")
except AutotaskAPIError as e:
print(f"API error: {e.message}")
Batch Operations
# Bulk create
contacts_data = [
{"firstName": "John", "lastName": "Doe", "companyID": 123},
{"firstName": "Jane", "lastName": "Smith", "companyID": 123}
]
# Create multiple contacts
results = []
for contact_data in contacts_data:
result = client.contacts.create(contact_data)
results.append(result)
Configuration
Request Configuration
from py_autotask.types import RequestConfig
config = RequestConfig(
timeout=60, # Request timeout in seconds
max_retries=5, # Maximum retry attempts
retry_delay=2.0, # Base retry delay
retry_backoff=2.0 # Exponential backoff multiplier
)
client = AutotaskClient(auth, config)
Logging
import logging
# Enable debug logging
logging.getLogger('py_autotask').setLevel(logging.DEBUG)
# Configure custom logging
logger = logging.getLogger('py_autotask.client')
logger.addHandler(logging.FileHandler('autotask.log'))
Development
Setup Development Environment
# Clone the repository
git clone https://github.com/asachs01/py-autotask.git
cd py-autotask
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=py_autotask --cov-report=html
# Run specific test file
pytest tests/test_client.py
# Run integration tests (requires API credentials)
pytest tests/integration/ --integration
Code Quality
# Format code
black py_autotask tests
# Sort imports
isort py_autotask tests
# Lint code
flake8 py_autotask tests
# Type checking
mypy py_autotask
API Reference
For detailed API documentation, see the inline docstrings and type hints in the source code.
Core Classes
- AutotaskClient - Main client class for API operations
- AutotaskAuth - Authentication and zone detection
- BaseEntity - Base class for all entity operations
- EntityManager - Factory for entity handlers
Exception Classes
- AutotaskError - Base exception class
- AutotaskAPIError - HTTP/API related errors
- AutotaskAuthError - Authentication failures
- AutotaskValidationError - Data validation errors
- AutotaskRateLimitError - Rate limiting errors
Migration Guide
From autotask-node (Node.js)
py-autotask provides similar functionality to the popular Node.js autotask library:
// Node.js (autotask-node)
const autotask = require('autotask-node');
const at = new autotask(username, integration, secret);
at.tickets.get(12345).then(ticket => {
console.log(ticket.title);
});
# Python (py-autotask)
from py_autotask import AutotaskClient
client = AutotaskClient.create(username, integration, secret)
ticket = client.tickets.get(12345)
print(ticket['title'])
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Reporting Issues
- Use the GitHub Issues page
- Include Python version, library version, and error details
- Provide minimal reproduction code when possible
Feature Requests
- Open an issue with the "enhancement" label
- Describe the use case and expected behavior
- Include relevant Autotask API documentation references
Changelog
See CHANGELOG.md for version history and changes.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
Acknowledgments
- Autotask API team for excellent documentation
- Contributors to the autotask-node library for inspiration
- Python community for amazing libraries and tools
Disclaimer: This library is not officially affiliated with Datto/Autotask. It is an independent implementation of the Autotask REST API. # CI Trigger
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_autotask-2.3.0.tar.gz.
File metadata
- Download URL: py_autotask-2.3.0.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0259ade7bc3fb9b2f7ad1b10446030a696d76ac63602384c0918aa3b467d945d
|
|
| MD5 |
3e394cda8fcd725db81a5e007af0a00b
|
|
| BLAKE2b-256 |
02445e042d1fe3ae9319d57f4cfb9b73c06b441937e7744704f97e3a1b0fcb0d
|
Provenance
The following attestation bundles were made for py_autotask-2.3.0.tar.gz:
Publisher:
release.yml on asachs01/py-autotask
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_autotask-2.3.0.tar.gz -
Subject digest:
0259ade7bc3fb9b2f7ad1b10446030a696d76ac63602384c0918aa3b467d945d - Sigstore transparency entry: 919719723
- Sigstore integration time:
-
Permalink:
asachs01/py-autotask@e8e2a13f74b4dde269a2edd45fe48bde7dfc8149 -
Branch / Tag:
refs/tags/v2.3.0 - Owner: https://github.com/asachs01
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e8e2a13f74b4dde269a2edd45fe48bde7dfc8149 -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_autotask-2.3.0-py3-none-any.whl.
File metadata
- Download URL: py_autotask-2.3.0-py3-none-any.whl
- Upload date:
- Size: 889.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54be562d4b465eb5f21a0e8a555e4439584f135e764bfb50195db08949b587bb
|
|
| MD5 |
a0014c49013e7e7660a8a1be3593baed
|
|
| BLAKE2b-256 |
0c714934e70dc9475ecbffde03e662ebb7ca6c70bf115aec6db6ede0efccd089
|
Provenance
The following attestation bundles were made for py_autotask-2.3.0-py3-none-any.whl:
Publisher:
release.yml on asachs01/py-autotask
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_autotask-2.3.0-py3-none-any.whl -
Subject digest:
54be562d4b465eb5f21a0e8a555e4439584f135e764bfb50195db08949b587bb - Sigstore transparency entry: 919719726
- Sigstore integration time:
-
Permalink:
asachs01/py-autotask@e8e2a13f74b4dde269a2edd45fe48bde7dfc8149 -
Branch / Tag:
refs/tags/v2.3.0 - Owner: https://github.com/asachs01
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e8e2a13f74b4dde269a2edd45fe48bde7dfc8149 -
Trigger Event:
push
-
Statement type: