HousecallPro-API-Call
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
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.
- Log into your HouseCall Pro account
- Go to Settings > Integrations > API
- Generate or copy your API key
In Val Town, set your environment variable:
- Key:
HOUSECALL_PRO_API_KEY - Value: Your HouseCall Pro API key
housecall-pro-api.ts: Core API module with TypeScript types and functionsmain.ts: HTTP endpoint for accessing the APIREADME.md: This documentation
GET /orGET /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 /docsorGET /help: API documentation
needs_schedulingscheduledin_progresscompletedcanceled
page: Page number (default: 1)page_size: Items per page (default: 50, max: 100)get_all: Set to 'true' to fetch all jobs across all pages
work_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 ID
scheduled_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 date
sort: 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:
- 401 Unauthorized: Invalid or missing API key
- 400 Bad Request: Invalid parameters
- 404 Not Found: Invalid endpoint
- 500 Internal Server Error: API or network errors
All errors return JSON with error details:
{ "error": "Error message", "type": "ErrorType", "timestamp": "2024-01-15T10:00:00Z" }
- ✅ Full TypeScript support with proper interfaces
- ✅ Comprehensive query parameter support
- ✅ Pagination handling (manual and automatic)
- ✅ Date range filtering
- ✅ Multiple filtering options
- ✅ Helper functions for common use cases
- ✅ Error handling and validation
- ✅ Built-in API documentation
- ✅ Special endpoints for common queries
The code is structured for easy maintenance and extension:
- Type Safety: Full TypeScript interfaces for all API responses
- Modular Design: Separate API module for reuse in other projects
- Helper Functions: Convenient functions for common operations
- Error Handling: Comprehensive error catching and reporting
- Documentation: Built-in API documentation endpoint
- Set your
HOUSECALL_PRO_API_KEYenvironment variable - Test the API endpoints
- Customize the filtering and parameters as needed
- Integrate with your application or workflow
For more information about the HouseCall Pro API, visit: https://docs.housecallpro.com/docs/housecall-public-api/