diff --git a/README.md b/README.md index e816824..db52d9f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ # python-holidayapi Official Python library for Holiday API + +## Installation + +```shell +pip install holidayapi +``` + +## Usage + +```python +import holidayapi + +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, +} + +holidays = hapi.holidays(parameters); +``` diff --git a/holidayapi/__init__.py b/holidayapi/__init__.py new file mode 100644 index 0000000..9367f5b --- /dev/null +++ b/holidayapi/__init__.py @@ -0,0 +1,24 @@ +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: + parameters['key'] = self.key + + response = requests.get(url, params=parameters); + data = json.loads(response.text) + + if response.status_code != 200: + if data.has_key('error') is False: + data['error'] = 'Unknown error.' + + return data + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..dee550e --- /dev/null +++ b/setup.py @@ -0,0 +1,14 @@ +from setuptools import setup + +setup( + name='python-holidayapi', + version='1.0.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'] +) +