Skip to main content

Unofficial library for the Salling Group holidays API

Project description

Linux Build Status Windows Build Status

Unofficial library for the Salling Group Holidays API

Unofficial Python 3 library for the Salling Group Holidays API.

The API supports fetching Danish holidays for a given date or range of dates. This library simply provides an abstraction over that API.

Note

This library is in no way supported by Salling Group A/S nor is the author in any way affiliated with Salling Groups A/S.

Installation

To install this library, type the following into the command prompt:

$ pip install salling-group-holidays

Usage

First of all, an API key is needed to use the Salling Group Holidays API. Contact Salling Group to receive your API key.

Once you have received your key, you can start using this library. Usage is fairly simple. Start by getting an API instance:

import salling_group_holidays

API_KEY = 'your_api_key'
v1 = salling_group_holidays.v1(API_KEY)

To see if a given date is a holiday, use a Python datetime.date object. and call the is_holiday method. For example, to see if today is a Danish holiday:

from datetime import date
import salling_group_holidays

v1 = salling_group_holidays.v1(API_KEY)

if v1.is_holiday(date.today()):
  print('Great news. No work today!')
else:
  print('Get back to work. No holiday today.')

To get a list of holidays for a given period, call the holidays method with a start and end date as a Python datetime.date object. This method returns a Python dictionary with the holiday dates as the key and the name of the day as well as whether it is a holiday. For example to get the list of Danish holidays in December 2018:

from datetime import date
import salling_group_holidays

v1 = salling_group_holidays.v1(API_KEY)
holidays = v1.holidays(date(2018, 12, 1), date(2018, 12, 31))

print('There are {} holidays in December 2018.'.format(len(holidays)))
print('December 25th is {}'.format(holidays[date(2018, 12, 25)]['name']))

Will output:

There are 4 holidays in December 2018
December 25th is 1. juledag.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
salling_group_holidays-0.3-py3-none-any.whl (3.5 kB) Copy SHA256 hash SHA256 Wheel py3 Jul 13, 2018
salling-group-holidays-0.3.tar.gz (3.2 kB) Copy SHA256 hash SHA256 Source None Jul 13, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page