mirror of
https://github.com/holidayapi/holidayapi-python.git
synced 2025-06-21 04:16:32 +00:00
Initial commit
This commit is contained in:
parent
9ebc846538
commit
9cba09675e
3 changed files with 67 additions and 0 deletions
29
README.md
29
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);
|
||||
```
|
||||
|
|
24
holidayapi/__init__.py
Normal file
24
holidayapi/__init__.py
Normal 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
14
setup.py
Normal 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']
|
||||
)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue