This is the official PHP client library for the Seats.io V2 REST API.
The recommended way to install seatsio-php is through Composer.
composer require seatsio/seatsio-php
The minimum required PHP version is 8.1.
seatsio-php follows semver since v62.3.0.
To use this library, you'll need to create a SeatsioClient
:
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
...
You can find your workspace secret key in the settings section of the workspace.
The region should correspond to the region of your account:
Region::EU()
: EuropeRegion::NA()
: North-AmericaRegion::SA()
: South-AmericaRegion::OC()
: Oceania
If you're unsure about your region, have a look at your company settings page.
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$chart = $seatsio->charts->create();
$event = $seatsio->events->create($chart->key);
echo 'Created event with key ' . $event->key;
Changes the object status to ‘booked’. Booked seats are not selectable on a rendered chart.
https://docs.seats.io/docs/api-book-objects
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$seatsio->events->book(<AN EVENT KEY>, ["A-1", "A-2"]);
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$seatsio->events->book(<AN EVENT KEY>, ["A-1", "A-2"], <A HOLD TOKEN>);
Either
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$seatsio->events->book(<AN EVENT KEY>, ["GA1", "GA1", "GA1"]);
Or
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$seatsio->events->book(<AN EVENT KEY>, [["objectId" => "GA1", "quantity" => 3]]);
Changes the object status to ‘free’. Free seats are selectable on a rendered chart.
https://docs.seats.io/docs/api-release-objects
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$seatsio->events->release(<AN EVENT KEY>, ["A-1", "A-2"]);
Changes the object status to a custom status of your choice. If you need more statuses than just booked and free, you can use this to change the status of a seat, table or booth to your own custom status.
https://docs.seats.io/docs/api-custom-object-status
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$seatsio->events->changeObjectStatus(<AN EVENT KEY>, ["A-1", "A-2"], "unavailable");
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$objectInfos = $seatsio->events->retrieveObjectInfos($event->key, ["A-1", "A-2"]);
print_r($objectInfos["A-1"]->categoryKey)
print_r($objectInfos["A-1"]->categoryLabel)
print_r($objectInfos["A-1"]->status)
print_r($objectInfos["A-2"]->categoryKey)
print_r($objectInfos["A-2"]->categoryLabel)
print_r($objectInfos["A-2"]->status)
Want to know which seats of an event are booked, and which ones are free? That’s where reporting comes in handy.
The report types you can choose from are:
- byStatus
- byCategoryLabel
- byCategoryKey
- byLabel
- byOrderId
https://docs.seats.io/docs/api-event-reports
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$seatsio->eventReports->byStatus(<AN EVENT KEY>, <OPTIONAL FILTER>);
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>);
$charts = $seatsio->charts->listAll();
foreach($charts as $chart) {
echo 'Chart ' . $chart->key;
}
Note: listAll()
returns an iterator, which under the hood calls the seats.io API to fetch charts page by page. So multiple API calls may be done underneath to fetch all charts.
E.g. to show charts in a paginated list on a dashboard.
Each page contains an items
array of charts, and nextPageStartsAfter
and previousPageEndsBefore
properties. Those properties are the chart IDs after which the next page starts or the previous page ends.
// ... user initially opens the screen ...
$firstPage = $seatsio->charts->listFirstPage();
foreach($firstPage->items as $chart) {
echo 'Chart ' . $chart->key;
}
// ... user clicks on 'next page' button ...
$nextPage = $seatsio->charts->listPageAfter($firstPage->nextPageStartsAfter);
foreach($nextPage->items as $chart) {
echo 'Chart ' . $chart->key;
}
// ... user clicks on 'previous page' button ...
$previousPage = $seatsio->charts->listPageBefore($nextPage->previousPageEndsBefore);
foreach($page->items as $chart) {
echo 'Chart ' . $chart->key;
}
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
// company admin key can be found on https://app.seats.io/company-settings
$seatsio = new SeatsioClient(Region::EU(), <COMPANY ADMIN KEY>);
$seatsio->workspaces->create("a workspace");
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
// company admin key can be found on https://app.seats.io/company-settings
// workspace public key can be found on https://app.seats.io/workspace-settings
$seatsio = new SeatsioClient(Region::EU(), <COMPANY ADMIN KEY>, <WORKSPACE PUBLIC KEY>);
$chart = $seatsio->charts->create();
$event = $seatsio->events->create($chart->key);
echo 'Created event with key ' . $event->key;
When an API call results in a 4xx or 5xx error (e.g. when a chart could not be found), a SeatsioException is thrown.
This exception contains a message string describing what went wrong, and also two other properties:
messages
: an array of error messages that the server returned. In most cases, this array will contain only one element.requestId
: the identifier of the request you made. Please mention this to us when you have questions, as it will make debugging easier.
This library supports exponential backoff.
When you send too many concurrent requests, the server returns an error 429 - Too Many Requests
. The client reacts to this by waiting for a while, and then retrying the request.
If the request still fails with an error 429
, it waits a little longer, and try again. By default this happens 5 times, before giving up (after approximately 15 seconds).
We throw a RateLimitExceededException
(which is a subclass of SeatsioException
) when exponential backoff eventually fails.
To change the maximum number of retries, create the SeatsioClient
as follows:
require 'vendor/autoload.php';
use Seatsio\Region;
use Seatsio\SeatsioClient;
$seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>, null, 3);
Passing in 0 disables exponential backoff completely. In that case, the client will never retry a failed request.
- An event's chart key can no longer be changed
- Removed StatusChangeRequest constructor. Use setters instead.
- No breaking changes.
- Only PHP 8.1 and newer are supported (older versions have reached end of life).
$client->usageReports->summaryForAllMonths()
now returns aUsageSummaryForAllMonths
object
- if you're using
$seatsioClient->subaccounts
, you should switch to$seatsioClient->workspaces
- social distancing got removed. There is no alternative for those API calls.
$seatsioClient->events->create()
now takes aCreateEventParams
object$seatsioClient->events->update()
now takes anUpdateEventParams
object
$seatsioClient->events->channels->replace()
now takes a normal array instead of an associative array. If you want to just replace the channel metadata but keep the objects (like replace() used to do), you have to explicitly pass in the objects.- Removed
$seatsioClient->events->channels->setObjects()
in favor of$seatsioClient->events->channels->replace()
- Usage report format changed
- Fields returned by usage reports have changed
- signature of
$seatsioClient->events->markAsForSale()
and$seatsioClient->events->markAsNotForSale()
changed. Added new parameter$areaPlaces
, between$objects
and$categories
. - added
$seatsioClient->charts->listCategories(string $chartKey)
to retrieve an array ofCategory
instances for a specified chart.
- removed fields from usage report by month:
$numFirstBookingsOrSelections
,$numGASelectionsWithoutBooking
,$numNonGASelectionsWithoutBooking
. Instead of$numFirstBookingsOrSelections
, use$numUsedObjects
.
- oldest supported PHP version is now PHP 7.4
$seatsioClient->seasons->createEvents()
returns an array of Event objects now, instead of the Season object
- Renamed
$seatsioClient->events->retrieveObjectStatus()
to$seatsioClient->events->retrieveObjectInfo()
- Renamed
\Seatsio\Reports\Events\EventReportItem
to\Seatsio\Events\EventObjectInfo
- Renamed
\Seatsio\Events\ObjectStatus
to\Seatsio\Events\EventObjectInfo
- Renamed
\Seatsio\Reports\Charts\ChartReportItem
to\Seatsio\Charts\ChartObjectInfo
- Renamed
ObjectStatus->quantity
toEventObjectInfo->numBooked
The SeatsioClient
now takes a region as first parameter. This is the region of your account.
Switched to builder pattern for creating social distancing rulesets. Removed constructor of SocialDistancingRuleset
class.
Rule-based rulesets:
$ruleset = SocialDistancingRuleset::ruleBased("My first ruleset")
->setIndex(0)
->setNumberOfDisabledSeatsToTheSides(1)
->setDisableSeatsInFrontAndBehind(true)
->setDisableDiagonalSeatsInFrontAndBehind(true)
->setNumberOfDisabledAisleSeats(2)
->setMaxGroupSize(1)
->setMaxOccupancyAbsolute(10)
->setOneGroupPerTable(true)
->setDisabledSeats(["A-1"])
->setEnabledSeats(["A-2"])
->build();
Fixed rulesets:
$ruleset = SocialDistancingRuleset::fixed("My second ruleset")
->setIndex(1)
->setDisabledSeats(["A-1"])
->build();
Replaced SeatsioException->$messages
by SeatsioException->$errors
. An error contains both a $code
and a $message
.
To implement logic based on the exception type, use the techincal $code
instead of the human-readable $message
.
The Event
class does not have $bookWholeTables
and $tableBookingModes
properties anymore. Those are replaced by a single
$tableBookingConfig
property:
$bookWholeTables
equal totrue
corresponds to a$tableBookingConfig
with$mode
equal toALL_BY_TABLE
$bookWholeTables
equal tofalse
corresponds to a$tableBookingConfig
with$mode
eitherALL_BY_SEAT
,INHERIT
orCUSTOM
- The list of tables in
$tableBookingModes
is now$tableBookingConfig->tables
(but only if$mode
equalsCUSTOM
)
When creating an event, you now pass in an (optional) $tableBookingConfig
instead of $bookWholeTablesOrTableBookingModes
:
$seatsioClient->events->create(
"4250fffc-e41f-c7cb-986a-2c5e728b8c28", null,
TableBookingConfig::custom(["T1" => "BY_TABLE", "T2" => "BY_SEAT"])
);
When creating multiple events, you now pass in an (optional) $tableBookingConfig
instead of $bookWholeTables
and $tableBookingModes
:
$params = [
CreateEventParams::create()
->setEventKey("event34")
->setTableBookingConfig(TableBookingConfig::allByTable(),
CreateEventParams::create()
->setEventKey("event35")
->setTableBookingConfig(TableBookingConfig::allBySeat()
];
$events = $seatsioClient->events->createMultiple("4250fffc-e41f-c7cb-986a-2c5e728b8c28", $params);
No migration needed
You now need to be on PHP 7.1 or newer to use this library.
Added boolean parameter $oneGroupPerTable
to the constructor of SocialDistancingRuleset
. Pass in false
to not force only one group
to sit at a table.
Also added this parameter to SocialDistancingRuleset::ruleBased()
Added $maxOccupancyAbsolute
, $maxOccupancyPercentage
and $fixedGroupLayout
to the constructor of SocialDistancingRuleset
.
To keep the default behaviour, pass in the following:
$maxOccupancyAbsolute = 0
$maxOccupancyPercentage = 0
$fixedGroupLayout = false
events->bookBestAvailable()
, events->holdBestAvailable()
and events->changeBestAvailableObjectStatus()
take optional $extraData
and
$ticketTypes
parameters. Pass in null
to keep the default behaviour.