mirror of
https://github.com/holidayapi/holidayapi-python.git
synced 2025-06-21 12:26:32 +00:00
Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
c3f02c4ecb | |||
0b00bcf471 | |||
|
2b49d85ad4 | ||
a2c5190805 | |||
6e92b65a9a | |||
|
15e629786a | ||
|
5fabca70a2 | ||
|
1ab665230a |
4 changed files with 23 additions and 21 deletions
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2016 Josh Sherman
|
||||
Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Gravity Boulevard, LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
22
README.md
22
README.md
|
@ -4,7 +4,7 @@ Official Python library for Holiday API
|
|||
## Installation
|
||||
|
||||
```shell
|
||||
pip install holidayapi
|
||||
pip install python-holidayapi
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
@ -16,16 +16,16 @@ hapi = holidayapi.v1('_YOUR_API_KEY_')
|
|||
|
||||
parameters = {
|
||||
# Required
|
||||
country: 'US',
|
||||
year: 2016,
|
||||
# Optional
|
||||
# month: 7,
|
||||
# day: 4,
|
||||
# previous: true,
|
||||
# upcoming: true,
|
||||
# public: true,
|
||||
# pretty: true,
|
||||
'country': 'US',
|
||||
'year': 2016,
|
||||
# Optional
|
||||
# 'month': 7,
|
||||
# 'day': 4,
|
||||
# 'previous': True,
|
||||
# 'upcoming': True,
|
||||
# 'public': True,
|
||||
# 'pretty': True,
|
||||
}
|
||||
|
||||
holidays = hapi.holidays(parameters);
|
||||
holidays = hapi.holidays(parameters)
|
||||
```
|
||||
|
|
|
@ -2,23 +2,22 @@ import json
|
|||
import requests
|
||||
|
||||
class v1:
|
||||
key = None
|
||||
|
||||
def __init__(self, key):
|
||||
self.key = key
|
||||
|
||||
def holidays(self, parameters):
|
||||
url = 'https://holidayapi.com/v1/holidays?'
|
||||
|
||||
if parameters.has_key('key') is False:
|
||||
if not parameters.get('key'):
|
||||
parameters['key'] = self.key
|
||||
else:
|
||||
assert self.key == parameters['key'], 'keys supplied as an argument & in `parameters` differ. \n Provide at only one place'
|
||||
|
||||
response = requests.get(url, params=parameters);
|
||||
data = json.loads(response.text)
|
||||
data = response.json()
|
||||
|
||||
if response.status_code != 200:
|
||||
if data.has_key('error') is False:
|
||||
if not response.ok:
|
||||
if not data.get('error'):
|
||||
data['error'] = 'Unknown error.'
|
||||
|
||||
return data
|
||||
|
||||
|
|
7
setup.py
7
setup.py
|
@ -2,13 +2,16 @@ from setuptools import setup
|
|||
|
||||
setup(
|
||||
name='python-holidayapi',
|
||||
version='1.0.0',
|
||||
version='1.2.0',
|
||||
description='Official Python library for Holiday API',
|
||||
url='https://holidayapi.com',
|
||||
author='Josh Sherman',
|
||||
author_email='hello@holidayapi.com',
|
||||
keywords=['python','holidayapi','holiday','api'],
|
||||
license='MIT',
|
||||
packages=['holidayapi']
|
||||
packages=['holidayapi'],
|
||||
install_requires=[
|
||||
'requests',
|
||||
],
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue