Skip to main content

A Python wrapper for the Workiz RESTful API

Project description

Workiz Python Wrapper

A Python wrapper for the Workiz RESTful API that provides a simple and intuitive interface to interact with Workiz's job management, leads, team, and time off features.

Installation

Install from PyPI:

pip install workiz

Quick Start

from workiz import WorkizClient

# Initialize the client
client = WorkizClient(
    api_token="your_api_token",
    auth_secret="your_auth_secret"
)

# Get all jobs
jobs = client.jobs.all(start_date="2024-01-01", records=50)

# Get a specific job
job = client.jobs.get("job-uuid-here")

# Create a new job
job_data = {
    "JobDateTime": "2024-01-15T09:00:00Z",
    "ClientId": 1002,
    "Company": "Sample Company",
    "Phone": "6195555555",
    "Email": "client@example.com",
    "FirstName": "Joe",
    "LastName": "Acme",
    "Address": "123 W Main Street",
    "City": "San Diego",
    "State": "CA",
    "Country": "US",
    "PostalCode": "92109"
}
result = client.jobs.create(job_data)

# Update a job
update_data = {
    "Status": "In progress",
    "JobNotes": "Updated notes"
}
client.jobs.update("job-uuid-here", update_data)

# Assign a user to a job
client.jobs.assign("job-uuid-here", "Alex Wilson")

# Add a payment to a job
client.jobs.add_payment(
    "job-uuid-here",
    amount=100.00,
    payment_type="cash",
    reference="102235620"
)

Features

Jobs

  • get(uuid) - Get job details by UUID
  • all(start_date, offset, records, only_open, status) - Get a list of jobs
  • create(job_data) - Create a new job
  • update(uuid, job_data) - Update a job's information
  • assign(uuid, user) - Assign a user to a job
  • unassign(uuid, user) - Unassign a user from a job
  • add_payment(uuid, amount, payment_type, date, reference) - Add a payment to a job

Leads

  • get(uuid) - Get lead details by UUID
  • all(start_date, offset, records, only_open, status) - Get a list of leads
  • create(lead_data) - Create a new lead
  • update(uuid, lead_data) - Update a lead's information
  • assign(uuid, user) - Assign a user to a lead
  • unassign(uuid, user) - Unassign a user from a lead
  • mark_lost(uuid) - Mark a lead as lost
  • activate(uuid) - Change a lost lead back to active
  • convert(uuid) - Convert a lead to a job

Team

  • all() - Get a list of all active team members
  • get(user_id) - Get specific user details by user ID

Time Off

  • get_all(all) - Get time off details for all users or company-wide
  • get(user_name) - Get time off details for a specific user

Examples

Working with Jobs

from workiz import WorkizClient

client = WorkizClient(api_token="your_token", auth_secret="your_secret")

# Get open jobs from the last 30 days
jobs = client.jobs.all(
    start_date="2024-01-01",
    only_open=True,
    records=100
)

# Filter jobs by status
jobs = client.jobs.all(
    start_date="2024-01-01",
    status=["Scheduled", "In progress"]
)

# Create a job with all fields
job_data = {
    "JobDateTime": "2024-01-15T09:00:00Z",
    "JobEndDateTime": "2024-01-15T17:00:00Z",
    "ClientId": 1002,
    "Company": "Acme Corporation",
    "Phone": "6195555555",
    "PhoneExt": "123",
    "Email": "contact@acme.com",
    "FirstName": "John",
    "LastName": "Doe",
    "Address": "123 Main St",
    "City": "San Diego",
    "State": "CA",
    "Country": "US",
    "PostalCode": "92109",
    "Unit": "Suite 100",
    "JobType": "Repair",
    "Timezone": "US/Pacific",
    "JobSource": "Website",
    "JobNotes": "Customer requested morning appointment",
    "ServiceArea": "metro1"
}
result = client.jobs.create(job_data)

Working with Leads

# Get all leads
leads = client.leads.all(start_date="2024-01-01")

# Create a lead
lead_data = {
    "LeadDateTime": "2024-01-15T09:00:00Z",
    "ClientId": 1002,
    "Phone": "6195555555",
    "Email": "lead@example.com",
    "FirstName": "Jane",
    "LastName": "Smith",
    "Company": "Smith Inc",
    "Address": "456 Oak Ave",
    "City": "Los Angeles",
    "State": "CA",
    "PostalCode": "90001",
    "Country": "US",
    "JobType": "Installation"
}
result = client.leads.create(lead_data)

# Convert a lead to a job
client.leads.convert("lead-uuid-here")

# Mark a lead as lost
client.leads.mark_lost("lead-uuid-here")

# Reactivate a lost lead
client.leads.activate("lead-uuid-here")

Working with Team

# Get all team members
team_members = client.team.all()

# Get a specific team member
user = client.team.get("34637")
print(f"User: {user['name']}, Email: {user['email']}")

Working with Time Off

# Get all time off entries
time_offs = client.timeoff.get_all(all=True)

# Get time off for a specific user
user_time_offs = client.timeoff.get("Joe Acme")

Error Handling

The wrapper includes custom exceptions for better error handling:

from workiz import WorkizClient, WorkizAPIError, WorkizAuthenticationError

try:
    client = WorkizClient(api_token="invalid", auth_secret="invalid")
    jobs = client.jobs.all()
except WorkizAuthenticationError as e:
    print(f"Authentication failed: {e}")
except WorkizAPIError as e:
    print(f"API error {e.code}: {e.message}")

API Documentation

For detailed API documentation, please refer to the Workiz API Documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

workiz-0.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

workiz-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file workiz-0.1.0.tar.gz.

File metadata

  • Download URL: workiz-0.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for workiz-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8351edfd77015f5f522985f2e80be7a5bc8fd29e53b5b8b4d2045782a4fb9888
MD5 b72578c15af88e5cff514e2d951e6e94
BLAKE2b-256 e13c19154c492d64f67254d780a7489e3e758e8b02fb91ca3b823ceada6cb8df

See more details on using hashes here.

File details

Details for the file workiz-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: workiz-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for workiz-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4aba49907435f12e29758db8cc9512ca3516424729fdf4593f280b029331da8
MD5 9025049b79cad489741fd1635d4fa968
BLAKE2b-256 7b98253f06078281d34067977a4b8a1cc53301dffc7836547a3f973c0f3aad98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page