Official PHP library for Holiday API providing quick and easy access to holiday information from applications written in PHP.
Full documentation of the Holiday API endpoints is available here.
composer require holidayapi/holidayapi-php
<?php
$key = 'Insert your API key here';
$holiday_api = new \HolidayAPI\Client(['key' => $key]);
try {
// Fetch supported countries and subdivisions
$countries = $holiday_api->countries();
// Fetch supported languages
$languages = $holiday_api->languages();
// Fetch holidays with minimum parameters
$holidays = $holiday_api->holidays([
'country' => 'US',
'year' => 2019,
]);
var_dump($countries, $languages, $holidays);
} catch (Exception $e) {
var_dump($e);
}
<?php
$holiday_api->countries();
<?php
$holiday_api->countries([
'public' => true,
]);
<?php
$holiday_api->countries([
'country' => 'NO',
]);
<?php
$holiday_api->countries([
'search' => 'united',
]);
<?php
$holiday_api->languages();
<?php
$holiday_api->languages([
'language' => 'es',
]);
<?php
$holiday_api->languages([
'search' => 'Chinese',
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
'month' => 7,
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
'month' => 7,
'day' => 4,
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
'month' => 7,
'day' => 4,
'upcoming' => true,
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
'month' => 7,
'day' => 4,
'previous' => true,
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
'public' => true,
]);
<?php
$holiday_api->holidays([
'country' => 'GB-ENG',
'year' => 2019,
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
'subdivisions' => true,
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
'search' => 'New Year',
]);
<?php
$holiday_api->holidays([
'country' => 'US',
'year' => 2019,
'language' => 'zh', // Chinese (Simplified)
]);
<?php
$holiday_api->holidays([
'country' => 'US,GB,NZ',
'year' => 2019,
]);
$holiday_api->holidays([
'country' => ['US', 'GB', 'NZ'],
'year' => 2019,
]);
<?php
$holiday_api->workday([
'country' => 'US',
'start' => '2019-07-01',
'days' => 7,
]);
<?php
$holiday_api->workdays([
'country' => 'US',
'start' => '2019-07-01',
'end' => '2019-07-10',
]);