Download the PHP package stitch-digital/simpro-php-sdk without Composer
On this page you can find all versions of the php package stitch-digital/simpro-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stitch-digital/simpro-php-sdk
More information about stitch-digital/simpro-php-sdk
Files in stitch-digital/simpro-php-sdk
Package simpro-php-sdk
Short Description An SDK to easily work with the Simpro API
License MIT
Homepage https://github.com/stitch-digital/simpro-php-sdk
Informations about the package simpro-php-sdk
Simpro PHP SDK
This package is an unofficial PHP SDK for the Simpro API, built with Saloon.
✅ Stable Release
This package is stable and ready for production use. It follows semantic versioning, so breaking changes will only ever land in a new major version.
New API resources and endpoints are still being added, but existing ones will not change in a backwards-incompatible way within the 1.x line.
About Simpro
Simpro is a cloud-based field service management platform designed for trade and service contractors, supporting industries such as fire protection, electrical, plumbing, HVAC, and security. It helps businesses manage jobs, quoting, scheduling, asset registers, compliance, and invoicing in one central system, replacing spreadsheets and disconnected tools with a mobile-friendly platform where technicians can capture job data, photos, and service results on site while office teams manage workflows, customer communication, and reporting, with integrations into accounting and other business software.
- Website: https://www.simprogroup.com/
- GitHub: https://github.com/simPRO-Software
Table of Contents
- Installation
- Quick Start
- Authentication Methods
- OAuth (Authorization Code Grant)
- API Key
- Usage
- Setting a Timeout
- Rate Limiting
- Caching
- Laravel Integration
- Handling Errors
- Resources
- Pagination and Querying
- Fluent Search API
- Search Methods
- Using Laravel Collections
- Security
- Credits
- License
Installation
Quick Start
Choose the authentication method that fits your use case. See the Authentication Methods section below for details.
Behind the scenes, the SDK uses Saloon v3 to make HTTP requests.
Authentication Methods
This SDL supports two authentication methods. Choose the one that best fits your use case:
OAuth (Authorization Code Grant)
Best for: Web applications where users can be redirected to Simpro's authorization page.
This flow requires users to approve access to your application. After approval, they're redirected back with a code you exchange for an access token.
Token Management:
The AccessTokenAuthenticator returned by getAccessToken() contains:
- Access token
- Refresh token
- Expiry timestamp
You should securely store this (encrypted) in your database and check for expiration before each request.
API Key
Best for: Server-to-server integrations, background jobs, and command-line tools.
This is the simplest authentication method - just provide your API key and start making requests.
That's it! No token management, no refresh logic - just simple, straightforward authentication.
Usage
Authentication
The SDK supports two authentication methods. See the Authentication Methods section above for detailed information:
- OAuth Authorization Code Grant: For web applications with user redirects
- API Key: For server-to-server integrations
Setting a timeout
By default, the SDK waits 10 seconds for a response. Override via the constructor:
Rate Limiting
The SDK automatically handles Simpro's API rate limit of 10 requests per second per base URL. By default, when the limit is reached, the SDK waits and retries automatically.
See Simpro's API documentation for more details on rate limits.
Default Behavior
Rate limiting is enabled by default with sensible settings:
With default settings:
- 10 requests per second limit
- Sleep and retry when limit is reached (no exceptions)
- Memory store for tracking request counts (per-process)
Custom Store
For applications running multiple processes or workers, use a persistent store to share rate limit state:
For Laravel applications, you can use a cache-based store:
See Saloon's Rate Limit Plugin documentation for all available stores.
Throwing Exceptions
For queue jobs or situations where you want to handle rate limits yourself, configure the SDK to throw exceptions instead of sleeping:
Disabling Rate Limiting
If you need to disable rate limiting entirely:
Caching
The SDK supports response caching using Saloon's cache plugin. Caching is opt-in and disabled by default - you must provide a CacheConfig to enable it.
Enabling Caching
You can enable caching using any PSR-16 compatible cache, Laravel's cache system, or Flysystem:
Cache Options
Configure cache expiry and key prefix:
Cache Behavior
| Aspect | Behavior |
|---|---|
| Default state | Disabled (opt-in) |
| Cached methods | GET and OPTIONS only |
| Cached responses | Successful responses only |
| Cache key prefix | simpro:{hostname}[:userPrefix]:{hash} |
| Default expiry | 300 seconds (5 minutes) |
Cache keys are automatically prefixed with the Simpro instance hostname to ensure multi-tenant isolation.
Enabling Caching After Construction
You can also enable or disable caching after creating the connector:
Checking Cache Status
After sending a request, you can check if the response came from cache:
Disabling Cache for Specific Requests
You can disable caching for individual requests:
Invalidating Cache
To invalidate the cache for a specific request:
See Saloon's Cache Plugin documentation for more details.
Laravel Integration
This section provides guidance for integrating the SDK into Laravel applications. The approach differs depending on whether you're building a single-tenant application (API Key) or a multi-tenant application (OAuth).
API Key Connector (Single-Tenant Applications)
For applications that connect to a single Simpro instance using an API key.
Configuration (config/services.php):
Service Provider Binding (app/Providers/AppServiceProvider.php):
Usage via Dependency Injection:
Optional Facade:
Create a facade for convenient static access:
Usage:
OAuth Connector (Multi-Tenant Applications)
For applications where multiple users connect their own Simpro accounts. This approach requires the Saloon Laravel plugin for the Eloquent cast:
Configuration (config/services.php):
Model (app/Models/SimproConnection.php):
Store the OAuth authenticator and tenant-specific Simpro URL:
Migration:
Factory (app/Services/SimproConnectorFactory.php):
Controller (app/Http/Controllers/SimproOAuthController.php):
Usage Example:
Further Reading
Handling Errors
The SDK uses Saloon's AlwaysThrowOnErrors trait on the connector, which means exceptions will automatically be thrown whenever a request fails (4xx or 5xx response status codes). You don't need to manually check if a request failed or call throw() on responses - exceptions are thrown automatically.
Saloon's built-in exceptions are used for most errors, with a custom exception for validation errors (422 status codes).
Exception Hierarchy
The SDK uses Saloon's exception hierarchy:
Validation Errors
For validation errors (422 status code), the SDK throws a custom ValidationException which extends Saloon's UnprocessableEntityException. This exception provides additional methods to access validation error details:
Connection Errors
If Saloon cannot connect to the API, it will throw a FatalRequestException:
Resources
The SDK provides resource-based APIs for working with different Simpro entities. Each resource has its own documentation page with detailed examples and usage instructions.
Available Resources
- Info - Get information about your Simpro instance, including version, country, and enabled features
- Companies - Access company information and manage multi-company environments
- Customer Assets - List customer assets with site associations and service levels (read-only)
- Jobs - Manage jobs with full CRUD operations (create, list, get, update, delete)
- Customers - Customer company management with full CRUD operations
- Quotes - Quote management with full CRUD operations
- Invoices - Invoice management with full CRUD operations
- Schedules - View job and activity schedules (read-only)
- Activity Schedules - Manage scheduled activities for staff members (full CRUD)
- Employees - Employee management with full CRUD operations and nested resources (timesheets, licences, custom fields, attachments)
- CurrentUser - Get authenticated user information
- Reports - Access job cost-to-complete reports (financial and operations)
- Notes - List customer notes across all customers with basic and detailed views (read-only)
- Job Cost Centers - List cost centers across all jobs (read-only)
- Recurring Invoices - Recurring invoice templates with full CRUD operations and nested sections, cost centers and line items (one-offs, service fees, catalogs, labor, prebuilds)
- Recurring Invoice Cost Centers - List cost centers across all recurring invoices (read-only)
- Job Work Orders - List work orders across all jobs with basic and detailed views (read-only)
- Setup - Configure system settings: webhooks, tax codes, payment methods, custom fields, labor rates, and more
- Tasks - List tasks across all jobs and customers with basic and detailed views (read-only)
Additional resources are added in minor releases as coverage of the Simpro API expands.
Pagination and Querying
Resource methods that return lists use a QueryBuilder instance that provides fluent search, filtering, and ordering capabilities. The query builder wraps Saloon's pagination plugin and handles pagination automatically.
Basic Usage
Fluent Search API
The SDK provides a fluent search API for building complex queries:
Search Methods
The Search class provides these methods:
| Method | Description | Example Value |
|---|---|---|
equals($value) |
Exact match | Test |
find($value) |
Wildcard search | %25Test%25 |
startsWith($value) |
Starts with | Test%25 |
endsWith($value) |
Ends with | %25Test |
lessThan($value) |
Less than | lt(10) |
lessThanOrEqual($value) |
Less than or equal | le(10) |
greaterThan($value) |
Greater than | gt(10) |
greaterThanOrEqual($value) |
Greater than or equal | ge(10) |
notEqual($value) |
Not equal | ne(Cancelled) |
between($min, $max) |
Range | between(1,100) |
in($array) |
In list | in(Active,Pending) |
notIn($array) |
Not in list | !in(Cancelled,Deleted) |
Using Laravel Collections
The collect() method returns a LazyCollection for powerful data transformations:
Array Filters (Backward Compatible)
You can also pass filters as an array to list methods:
Controlling Page Size
By default, 30 items are fetched per page:
Pagination Metadata
The Simpro API returns pagination information in response headers:
Result-Total: Total number of resultsResult-Pages: Total number of pages
The paginator automatically reads these headers and handles pagination for you.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of simpro-php-sdk with dependencies
illuminate/collections Version ^11.0 || ^12.0 || ^13.0
saloonphp/cache-plugin Version ^3.0
saloonphp/pagination-plugin Version ^2.2
saloonphp/rate-limit-plugin Version ^2.0
saloonphp/saloon Version ^4.0