npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

holidayapi

v6.0.1

Published

Official Node.js library for Holiday API

Downloads

37,154

Readme

Holiday API Node.js Library

License Node Version Test Status Code Coverage

Official Node.js library for Holiday API providing quick and easy access to holiday information from applications written in server-side JavaScript.

Documentation

Full documentation of the Holiday API endpoints is available here.

Installation

# NPM
npm install --save holidayapi

# Yarn
yarn add holidayapi

Usage

import { HolidayAPI } from 'holidayapi';

const key = 'Insert your API key here';
const holidayApi = new HolidayAPI({ key });

// Fetch supported countries and subdivisions
holidayApi.countries()
  .then((countries) => { console.log(countries); })
  .catch((err) => { console.error(err); });

// Fetch supported languages
holidayApi.languages()
  .then((languages) => { console.log(languages); })
  .catch((err) => { console.error(err); });

// Fetch holidays with minimum parameters
holidayApi.holidays({ country: 'US', year: 2019 })
  .then((holidays) => { console.log(holidays); })
  .catch((err) => { console.error(err); });

// Async? Await? No problem!
(async () => {
  // Fetch supported countries and subdivisions
  const countries = await holidayApi.countries();

  // Fetch supported languages
  const languages = await holidayApi.languages();

  // Fetch holidays with minimum parameters
  const holidays = await holidayApi.holidays({
    country: 'US',
    year: 2019,
  });
})();

Examples

Countries

Fetch all supported countries

holidayApi.countries();

Fetch only countries with public holidays

holidayApi.countries({
  public: true,
});

Fetch a supported country by code

holidayApi.countries({
  country: 'NO',
});

Search for countries by code or name

holidayApi.countries({
  search: 'united',
});

Languages

Fetch all supported languages

holidayApi.languages();

Fetch a supported language by code

holidayApi.language({
  language: 'es',
});

Search for languages by code or name

holidayApi.language({
  search: 'Chinese',
});

Holidays

Fetch holidays for a specific year

holidayApi.holidays({
  country: 'US',
  year: 2019,
});

Fetch holidays for a specific month

holidayApi.holidays({
  country: 'US',
  year: 2019,
  month: 7,
});

Fetch holidays for a specific day

holidayApi.holidays({
  country: 'US',
  year: 2019,
  month: 7,
  day: 4,
});

Fetch upcoming holidays based on a specific date

holidayApi.holidays({
  country: 'US',
  year: 2019,
  month: 7,
  day: 4,
  upcoming: true,
});

Fetch previous holidays based on a specific date

holidayApi.holidays({
  country: 'US',
  year: 2019,
  month: 7,
  day: 4,
  previous: true,
});

Fetch only public holidays

holidayApi.holidays({
  country: 'US',
  year: 2019,
  public: true,
});

Fetch holidays for a specific subdivision

holidayApi.holidays({
  country: 'GB-ENG',
  year: 2019,
});

Include subdivision holidays with countrywide holidays

holidayApi.holidays({
  country: 'US',
  year: 2019,
  subdivisions: true,
});

Search for a holiday by name

holidayApi.holidays({
  country: 'US',
  year: 2019,
  search: 'New Year',
});

Translate holidays to another language

holidayApi.holidays({
  country: 'US',
  year: 2019,
  language: 'zh', // Chinese (Simplified)
});

Fetch holidays for multiple countries

holidayApi.holidays({
  country: 'US,GB,NZ',
  year: 2019,
});

holidayApi.holidays({
  country: ['US', 'GB', 'NZ'],
  year: 2019,
});

Workday

Fetch workday 7 business days after a date

holidayApi.workday({
  country: 'US',
  start: '2019-07-01',
  days: 7,
});

Workdays

Fetch number of workdays between two dates

holidayApi.workday({
  country: 'US',
  start: '2019-07-01',
  end: '2019-07-10',
});