Unofficial library for the Salling Group holidays API
Project description
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.
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.
Source Distribution
Built Distribution
Hashes for salling-group-holidays-0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a4146900ac352584a56eab8973d59d31638e1d03c2b3ab54c6a5259420c878b |
|
MD5 | ee176ac01e4a051ddbea3d730bb2a0bc |
|
BLAKE2b-256 | c6b825818ced4587a5cfede4d32f2261b82b1809a1b72485d5247fad73327db0 |
Hashes for salling_group_holidays-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1fd357fbca10e09be064e8005205112faf8c6acad1a55dab69c1994bcb218ad |
|
MD5 | fc3770af04e06e4a8e56c813d9b9388a |
|
BLAKE2b-256 | 9df7364b4175d3adeb6951edcf5533e32b7561a849a24e802ec155bda5b1f601 |