This project provides a comprehensive API integration with HouseCall Pro to fetch jobs data. It includes a reusable TypeScript module and an HTTP endpoint for easy access to jobs information.
In Val Town, set your environment variable:
HOUSECALL_PRO_API_KEYhousecall-pro-api.ts: Core API module with TypeScript types and functionsmain.ts: HTTP endpoint for accessing the APIREADME.md: This documentationGET / or GET /jobs: Get jobs with optional query parametersGET /jobs/today: Get jobs scheduled for todayGET /jobs/this-week: Get jobs scheduled for this weekGET /jobs/status/{status}: Get jobs by specific statusGET /docs or GET /help: API documentationneeds_schedulingscheduledin_progresscompletedcanceledpage: Page number (default: 1)page_size: Items per page (default: 50, max: 100)get_all: Set to 'true' to fetch all jobs across all pageswork_status: Filter by work statusemployee_ids: Comma-separated employee IDscustomer_ids: Comma-separated customer IDsaddress_city: Filter by cityaddress_state: Filter by stateaddress_zip: Filter by ZIP codetags: Comma-separated tagslead_source: Filter by lead sourcebusiness_unit_id: Filter by business unit IDscheduled_start_min: Minimum scheduled start datescheduled_start_max: Maximum scheduled start datescheduled_end_min: Minimum scheduled end datescheduled_end_max: Maximum scheduled end datecreated_min: Minimum created datecreated_max: Maximum created dateupdated_min: Minimum updated dateupdated_max: Maximum updated datesort: Sort field (created_at, updated_at, scheduled_start, scheduled_end)sort_direction: Sort direction (asc, desc)# Get first 10 jobs GET /?page_size=10 # Get completed jobs GET /?work_status=completed # Get jobs for specific employee GET /?employee_ids=emp_123 # Get jobs in New York GET /?address_city=New York # Get jobs scheduled for January 2024 GET /?scheduled_start_min=2024-01-01&scheduled_start_max=2024-01-31 # Get all jobs (across all pages) GET /?get_all=true # Get today's jobs GET /jobs/today # Get this week's jobs GET /jobs/this-week # Get scheduled jobs GET /jobs/status/scheduled
import { getHouseCallProJobs, getJobsByDateRange, getJobsByStatus, getAllJobs } from './housecall-pro-api.ts';
// Get jobs with custom parameters
const jobs = await getHouseCallProJobs({
page: 1,
page_size: 50,
work_status: 'scheduled',
address_city: 'New York'
});
// Get jobs for a date range
const jobsInRange = await getJobsByDateRange('2024-01-01', '2024-01-31');
// Get jobs by status
const completedJobs = await getJobsByStatus('completed');
// Get all jobs (handles pagination automatically)
const allJobs = await getAllJobs({
work_status: 'scheduled'
});
The API returns jobs data in the following format:
{ "jobs": [ { "id": "job_123", "number": "12345", "customer": { "id": "cust_456", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "mobile_number": "+1234567890", "company": "Acme Corp" }, "address": { "street": "123 Main St", "city": "New York", "state": "NY", "zip": "10001", "country": "US" }, "start_date": "2024-01-15T09:00:00Z", "end_date": "2024-01-15T17:00:00Z", "work_status": "scheduled", "total_amount": 250.00, "outstanding_balance": 0.00, "assigned_employees": [ { "id": "emp_789", "first_name": "Jane", "last_name": "Smith" } ], "tags": ["plumbing", "emergency"], "created_at": "2024-01-10T10:00:00Z", "updated_at": "2024-01-12T14:30:00Z" } ], "total_items": 150, "total_pages": 3, "page_number": 1, "page_size": 50 }
The API includes comprehensive error handling:
All errors return JSON with error details:
{ "error": "Error message", "type": "ErrorType", "timestamp": "2024-01-15T10:00:00Z" }
The code is structured for easy maintenance and extension:
HOUSECALL_PRO_API_KEY environment variableFor more information about the HouseCall Pro API, visit: https://docs.housecallpro.com/docs/housecall-public-api/