SDKs overview

The Public Holidays API offers Software Development Kits (SDKs) and client libraries designed to facilitate integration with its holiday data service. These SDKs handle the underlying HTTP communication, request authentication, and response deserialization, enabling developers to focus on application logic rather than API mechanics. The availability of official SDKs for popular programming languages aims to streamline development workflows for various platforms and applications requiring accurate global holiday information Public Holidays API documentation.

Using an SDK can reduce the boilerplate code required for API interactions. For instance, an SDK typically provides methods that map directly to API endpoints, allowing developers to call a function like getHolidays(countryCode, year) instead of manually constructing a URL, setting headers, and parsing JSON responses. This approach promotes cleaner code and can accelerate the development of applications that rely on external data sources.

Official SDKs by language

Public Holidays provides official client libraries for several widely used programming languages. These SDKs are maintained by Public Holidays and offer a supported method for integrating the API into applications. Each SDK is tailored to the conventions and best practices of its respective language ecosystem, ensuring a native development experience. The table below outlines the currently available official SDKs:

Language Package/Module Name Installation Command Example Maturity
JavaScript public-holidays-js npm install public-holidays-js or yarn add public-holidays-js Stable
PHP public-holidays-php composer require public-holidays/php-client Stable
Python public-holidays-py pip install public-holidays-py Stable
Ruby public-holidays-ruby gem install public-holidays-ruby Stable

These official SDKs are regularly updated to ensure compatibility with the latest API versions and to incorporate any new features or improvements. Developers can find detailed usage instructions and API method references within the Public Holidays API reference documentation for each specific language binding.

Installation

Installing the Public Holidays SDKs typically involves using the standard package managers for each programming language. The following sections provide specific installation instructions for the officially supported SDKs.

JavaScript (Node.js/Browser)

For JavaScript environments, including Node.js applications and front-end browser projects, the SDK is available via npm or Yarn. This allows developers to integrate the library into their existing build processes and dependency management systems Mozilla JavaScript documentation.

# Using npm
npm install public-holidays-js

# Using Yarn
yarn add public-holidays-js

PHP

PHP projects typically manage dependencies using Composer. The Public Holidays PHP client can be added to your project's composer.json file and installed via the command line.

composer require public-holidays/php-client

After running this command, Composer will download the library and its dependencies, making them available through your project's autoloader.

Python

Python developers can install the Public Holidays SDK using pip, the standard package installer for Python packages. This ensures that the library and its required components are correctly set up in your Python environment.

pip install public-holidays-py

It is often recommended to install Python packages within a virtual environment to manage project-specific dependencies effectively.

Ruby

For Ruby applications, the SDK is distributed as a Ruby gem. Gems are the standard way to package and distribute Ruby libraries, and they can be installed using the gem command or by including them in a Gemfile with Bundler.

gem install public-holidays-ruby

If you are using Bundler, add the following line to your Gemfile:

gem 'public-holidays-ruby'

Then run bundle install to install the gem.

Quickstart example

This section provides a basic quickstart example using the Python SDK to retrieve public holidays for a specific country and year. This illustrates the fundamental steps of initializing the client and making a request. Similar patterns apply to other language SDKs, with syntax adjusted to the respective language conventions.

Python Quickstart

The following Python code snippet demonstrates how to fetch all public holidays for Germany in the year 2026. This example assumes you have an API key, which is necessary for authenticated requests to the Public Holidays API Public Holidays pricing page.

from public_holidays import PublicHolidaysAPI

# Replace 'YOUR_API_KEY' with your actual Public Holidays API key
api_key = 'YOUR_API_KEY'
client = PublicHolidaysAPI(api_key)

try:
    # Fetch holidays for Germany (DE) in 2026
    holidays = client.get_holidays(country='DE', year=2026)

    print(f"Public Holidays for Germany in 2026:")
    for holiday in holidays:
        print(f"  - {holiday['date']}: {holiday['name']} ({holiday['localName']})")

except Exception as e:
    print(f"An error occurred: {e}")

This example first imports the necessary class, initializes the client with your API key, and then calls the get_holidays method. The response is a list of dictionaries, each representing a holiday with details like date, English name, and local name. Error handling is included to catch potential issues during the API call.

Community libraries

In addition to the official SDKs, the broader developer community may contribute unofficial libraries or wrappers for the Public Holidays API in various programming languages and frameworks. These community-driven projects can offer alternative approaches or support for languages not covered by official SDKs, such as Go, Java, or C#. While not officially supported by Public Holidays, they can sometimes provide valuable resources for developers working in specific ecosystems.

When considering a community library, it is advisable to evaluate its maintenance status, documentation, and the activity of its contributors. Developers should check the project's repository on platforms like GitHub for recent commits, open issues, and pull requests to gauge its reliability and ongoing support. Community contributions often demonstrate the API's flexibility and the demand for holiday data across diverse technical stacks, such as integrating with Google Cloud services or AWS infrastructure. Always refer to the official Public Holidays API reference for the definitive source of API specifications, regardless of the client library used.