Initial commit

This commit is contained in:
Josh Sherman 2016-09-05 17:17:19 -05:00
parent 9ebc846538
commit 9cba09675e
3 changed files with 67 additions and 0 deletions

View file

@ -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);
```

24
holidayapi/__init__.py Normal file
View file

@ -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

14
setup.py Normal file
View file

@ -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']
)