PHPackages                             hapio/hapio-sdk-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. hapio/hapio-sdk-php

ActiveLibrary[API Development](/categories/api)

hapio/hapio-sdk-php
===================

Hapio SDK for PHP.

1.1.0(1y ago)3341MITPHPPHP ^8.2

Since Oct 19Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Hapio-Booking-and-Scheduling-API/hapio-sdk-php)[ Packagist](https://packagist.org/packages/hapio/hapio-sdk-php)[ RSS](/packages/hapio-hapio-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

Hapio SDK for PHP
=================

[](#hapio-sdk-for-php)

The Hapio SDK for PHP allows you to easily interact with the Hapio API for bookings and scheduling when using the PHP programming language.

Requirements
------------

[](#requirements)

- PHP 8.2 or later

Getting started
---------------

[](#getting-started)

The easiest way to install the Hapio SDK is by using [Composer](https://getcomposer.org/) to require the package in your project:

```
composer require hapio/hapio-sdk-php
```

To use the SDK in your project you simply instantiate an API client, and then get to work:

```
// Require the Composer autoloader
require __DIR__ . '/vendor/autoload.php';

use Hapio\Sdk\ApiClient;

// Instantiate a Hapio API client
$apiClient = new ApiClient('your-api-token');

// Get a list of all bookings this week
$response = $apiClient->bookings()->list([
    'from' => new DateTime('monday this week 00:00:00'),
    'to' => new DateTime('friday this week 23:59:59'),
]);

while ($response) {
    foreach ($response->getItems() as $booking) {
        var_dump($booking);
    }

    if ($response->hasMoreItems()) {
        $response = $response->getNextPage();
    } else {
        $response = null;
    }
}
```

Documentation
-------------

[](#documentation)

### API client

[](#api-client)

Provide your API token when you instantiate the API client:

```
use Hapio\Sdk\ApiClient;

$apiClient = new ApiClient('your-api-token');
```

### Models

[](#models)

The following models are available in the SDK:

- `Hapio\Sdk\Models\Project`
- `Hapio\Sdk\Models\Location`
- `Hapio\Sdk\Models\Resource`
- `Hapio\Sdk\Models\Service`
- `Hapio\Sdk\Models\ScheduleBlock`
- `Hapio\Sdk\Models\RecurringSchedule`
- `Hapio\Sdk\Models\RecurringScheduleBlock`
- `Hapio\Sdk\Models\Booking`
- `Hapio\Sdk\Models\BookingGroup`
- `Hapio\Sdk\Models\BookableSlot`
- `Hapio\Sdk\Models\TimeSpan`
- `Hapio\Sdk\Models\ResourceServiceAssociation`

These models are returned when fetching entities, as well as when you create or update entities. When instantiating a new model, you can provide an array of properties to set:

```
$location = new Location([
    'name' => 'My first location',
    'time_zone' => 'Europe/Stockholm',
    'resource_selection_strategy' => 'equalize',
]);
```

You can also set and get individual properties on the model object:

```
$location->name = 'My first location';

echo $location->name; // "My first location"
```

You can use either `snake_case` or `camelCase` for the property names. Property names in `camelCase` will be automatically converted to `snake_case` internally, since that is used when communicating with the API.

```
$location->timeZone = 'Europe/London';

echo $location->timeZone; // "Europe/London"
echo $location->time_zone; // "Europe/London"
```

You can only set values for valid property names:

```
$location->nonExistentAttribute = 'A random value';

echo $location->nonExistentAttribute; // null
```

### Repositories

[](#repositories)

The Hapio SDK provides a repository class for each type of entity available in Hapio:

- `Hapio\Sdk\Repositories\ProjectRepository`
- `Hapio\Sdk\Repositories\LocationRepository`
- `Hapio\Sdk\Repositories\ResourceRepository`
- `Hapio\Sdk\Repositories\ServiceRepository`
- `Hapio\Sdk\Repositories\ScheduleBlockRepository`
- `Hapio\Sdk\Repositories\RecurringScheduleRepository`
- `Hapio\Sdk\Repositories\RecurringScheduleBlockRepository`
- `Hapio\Sdk\Repositories\BookingRepository`
- `Hapio\Sdk\Repositories\BookingGroupRepository`

These repositories are the communication gateway to the API, and are used to send and retrieve data.

The repositories are accessible through methods on the `ApiClient` class:

```
public function projects(): ProjectRepository;
public function locations(): LocationRepository;
public function resources(): ResourceRepository;
public function services(): ServiceRepository;
public function scheduleBlocks(): ScheduleBlockRepository;
public function recurringSchedules(): RecurringScheduleRepository;
public function recurringScheduleBlocks(): RecurringScheduleBlockRepository;
public function bookings(): BookingRepository;
public function bookingGroups(): BookingGroupRepository;
```

Each repository has a set of methods, corresponding to the endpoints available for the entity. These are listed for each repository below.

#### Hapio\\Sdk\\Repositories\\ProjectRepository

[](#hapiosdkrepositoriesprojectrepository)

```
public function getCurrentProject(): Project;
```

#### Hapio\\Sdk\\Repositories\\LocationRepository

[](#hapiosdkrepositorieslocationrepository)

```
public function list(array $params = []): PaginatedResponse;
public function get(string $id): Location;
public function store(Location $location): Location;
public function replace(string $id, Location $location): Location;
public function patch(string $id, Location $location): Location;
public function delete(string $id): bool;
```

#### Hapio\\Sdk\\Repositories\\ResourceRepository

[](#hapiosdkrepositoriesresourcerepository)

```
public function list(array $params = []): PaginatedResponse;
public function get(string $id): Resource;
public function store(Resource $resource): Resource;
public function replace(string $id, Resource $resource): Resource;
public function patch(string $id, Resource $resource): Resource;
public function delete(string $id): bool;
public function listSchedule(string $id, array $params = []): PaginatedResponse;
public function listFullyBooked(string $id, array $params = []): PaginatedResponse;
public function listAssociatedServices(string $resourceId): array;
public function getAssociatedService(string $resourceId, string $serviceId): ResourceServiceAssociation;
public function associateService(string $resourceId, string $serviceId): ResourceServiceAssociation;
public function dissociateService(string $resourceId, string $serviceId): bool;
```

#### Hapio\\Sdk\\Repositories\\ServiceRepository

[](#hapiosdkrepositoriesservicerepository)

```
public function list(array $params = []): PaginatedResponse;
public function get(string $id): Service;
public function store(Service $service): Service;
public function replace(string $id, Service $service): Service;
public function patch(string $id, Service $service): Service;
public function delete(string $id): bool;
public function listBookableSlots(string $serviceId, array $params = []): PaginatedResponse;
public function listBookableSlots(string $serviceId, array $params = []): PaginatedResponse;
public function listAssociatedResources(string $serviceId): array;
public function getAssociatedResource(string $serviceId, string $resourceId): ResourceServiceAssociation;
public function associateResource(string $serviceId, string $resourceId): ResourceServiceAssociation;
public function dissociateResource(string $serviceId, string $resourceId): bool;
```

#### Hapio\\Sdk\\Repositories\\ScheduleBlockRepository

[](#hapiosdkrepositoriesscheduleblockrepository)

```
public function list(array $parentIds, array $params = []): PaginatedResponse;
public function get(array $parentIds, string $id): ScheduleBlock;
public function store(array $parentIds, Service $service): ScheduleBlock;
public function replace(array $parentIds, string $id, Service $service): ScheduleBlock;
public function patch(array $parentIds, string $id, Service $service): ScheduleBlock;
public function delete(array $parentIds, string $id): bool;
```

#### Hapio\\Sdk\\Repositories\\RecurringScheduleRepository

[](#hapiosdkrepositoriesrecurringschedulerepository)

```
public function list(array $parentIds, array $params = []): PaginatedResponse;
public function get(array $parentIds, string $id): RecurringSchedule;
public function store(array $parentIds, RecurringSchedule $service): RecurringSchedule;
public function replace(array $parentIds, string $id, RecurringSchedule $service): RecurringSchedule;
public function patch(array $parentIds, string $id, RecurringSchedule $service): RecurringSchedule;
public function delete(array $parentIds, string $id): bool;
```

#### Hapio\\Sdk\\Repositories\\RecurringScheduleBlockRepository

[](#hapiosdkrepositoriesrecurringscheduleblockrepository)

```
public function list(array $parentIds, array $params = []): PaginatedResponse;
public function get(array $parentIds, string $id): RecurringScheduleBlock;
public function store(array $parentIds, Service $service): RecurringScheduleBlock;
public function replace(array $parentIds, string $id, Service $service): RecurringScheduleBlock;
public function patch(array $parentIds, string $id, Service $service): RecurringScheduleBlock;
public function delete(array $parentIds, string $id): bool;
```

#### Hapio\\Sdk\\Repositories\\Booking

[](#hapiosdkrepositoriesbooking)

```
public function list(array $params = []): PaginatedResponse;
public function get(string $id): Booking;
public function store(Booking $booking): Booking;
public function replace(string $id, Booking $booking): Booking;
public function patch(string $id, Booking $booking): Booking;
public function delete(string $id): bool;
```

#### Hapio\\Sdk\\Repositories\\BookingGroupRepository

[](#hapiosdkrepositoriesbookinggrouprepository)

```
public function list(array $params = []): PaginatedResponse;
public function get(string $id): BookingGroup;
public function store(BookingGroup $bookingGroup): BookingGroup;
public function replace(string $id, BookingGroup $bookingGroup): BookingGroup;
public function patch(string $id, BookingGroup $bookingGroup): BookingGroup;
public function delete(string $id): bool;
```

### Paginated responses

[](#paginated-responses)

All the methods for API endpoints that respond with a paginated list, will return an instance of `Hapio\Sdk\PaginatedResponse`. This class has a set of methods that make it easier for you to work with these paginated responses.

```
public function getItems(): ArrayIterator;
public function hasMoreItems(): bool;
public function getNextPage(): PaginatedResponse|null;
public function getPreviousPage(): PaginatedResponse|null;
public function getFirstPage(): PaginatedResponse|null;
public function getLastPage(): PaginatedResponse|null;
public function getCurrentPageNumber(): int;
public function getLastPageNumber(): int;
public function getFromIndex(): int;
public function getToIndex(): int;
public function getTotalItems(): int;
public function getItemsPerPage(): int;
public function getNextPageLink(): string|null;
public function getPreviousPageLink(): string|null;
public function getFirstPageLink(): string|null;
public function getLastPageLink(): string|null;
```

### Exceptions

[](#exceptions)

Whenever the API responds with a `4XX` or `5XX` response, an exception will be thrown. Validation error responses with a status code of `422` will throw a `Hapio\Sdk\Exceptions\ValidationException`, and all other `4XX` and `5XX` status codes will throw a `Hapio\Sdk\Exceptions\ErrorException`. For both of these exceptions you can access the original Guzzle exception using the `getPrevious()` method, the `message` property of the response is available using the `getMessage()` method, and the status code can be fetched using the `getCode()` method. The `ValidationException` class also has a method for accessing validation errors, called `getValidationErrors()`. Other Guzzle exceptions are not caught by the SDK.

```
$resource = new Resource([
    'name' => '',
]);

try {
    $resourceRepository->store($resource);
} catch (ValidationException $e) {
    $e->getCode(); // 422
    $e->getMessage(); // "The given data was invalid."
    $e->getValidationErrors(); // ["name" => ["The name field is required."]]
}
```

Resources
---------

[](#resources)

- [API documentation](https://docs.hapio.io/)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Total

5

Last Release

545d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97cfabdd2afe15b374466159145fe71fd42767f50fb59377666c45ab5b93a91e?d=identicon)[jesperstrahle](/maintainers/jesperstrahle)

---

Top Contributors

[![jesperstrahle](https://avatars.githubusercontent.com/u/1790374?v=4)](https://github.com/jesperstrahle "jesperstrahle (8 commits)")[![MihkelAtWork](https://avatars.githubusercontent.com/u/151734220?v=4)](https://github.com/MihkelAtWork "MihkelAtWork (7 commits)")

---

Tags

apiclientsdkschedulingbookinghapio

### Embed Badge

![Health badge](/badges/hapio-hapio-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/hapio-hapio-sdk-php/health.svg)](https://phpackages.com/packages/hapio-hapio-sdk-php)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[crowdin/crowdin-api-client

PHP client library for Crowdin API v2

611.5M5](/packages/crowdin-crowdin-api-client)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[fabian-beiner/todoist-php-api-library

A PHP client library that provides a native interface to the official Todoist REST API.

4810.8k](/packages/fabian-beiner-todoist-php-api-library)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
