Skip to main content

温室 API 的 Python 包装器

项目描述

grnhse-api

皮皮 版本

温室API的 Python 包装器。

目前,仅支持Harvest API

安装

$ pip install grnhse-api

基本用法

from grnhse import Harvest

api_key = 'ABCDE12345'
hvst = Harvest(api_key)
# <Harvest API v1>

depts = hvst.departments
depts
# <Departments Endpoint>

depts.get()
# [{'id': 1234,
#   'name': 'Administration',
#   'parent_id': None,
#   'child_ids': [],
#   'external_id': None},
#  {'id': 2345,
#   'name': 'Operations',
#   'parent_id': None,
#   'child_ids': [],
#   'external_id': None},
#  {'id': 3456,
#   'name': 'Engineering',
#   'parent_id': None,
#   'child_ids': [],
#   'external_id': None},
#   ...]

depts.get(1234)
# {'id': 1234,
#  'name': 'Administration',
#  'parent_id': None,
#  'child_ids': [],
#  'external_id': None}

admin = depts(1234)
admin
# <Departments Endpoint (id=1234)>

admin.get()
# {'id': 1234,
#  'name': 'Administration',
#  'parent_id': None,
#  'child_ids': [],
#  'external_id': None}

hvst.departments(1234).get()
# {'id': 1234,
#  'name': 'Administration',
#  'parent_id': None,
#  'child_ids': [],
#  'external_id': None}

分页

from grnhse import Harvest

api_key = 'ABCDE12345'
hvst = Harvest(api_key)

apps = hvst.applications
apps
# <Applications Endpoint>

all_apps = apps.get()
len(all_apps)
# 100
apps.records_remaining
# True
while apps.records_remaining:
    all_apps.extend(apps.get_next())
len(all_apps)
# 437

# Using list comprehension
all_apps = [app for page in apps for app in page]
len(all_apps)
# 437

变更日志

0.1.1 (2020-12-10)

  • 更新:requests包固定到较新的版本
  • 更新:添加custom_fields端点
  • 修正:None用空字符串替换SessionAuthMixin

0.1.0 (2018-11-10)

  • 初始发行

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

grnhse-api-0.1.1.tar.gz (5.9 kB 查看哈希

已上传 source