与Sunlight Labs Transparency Data API交互的库
项目描述
用于与TransparencyData.com API交互的Python库。
TransparencyData.com API提供竞选捐款和游说数据。
http://transparencydata.com/api/
python-transparencydata是Sunlight Labs的项目(c)2010 由Jeremy Carbaugh编写 <jcarbaugh@sunlightfoundation.com>
所有代码都在BSD风格的许可证下,有关详情请参阅LICENSE。
源码: http://github.com/sunlightlabs/python-transparencydata/
需求
python >= 2.4
simplejson >= 1.8 (Python 2.6及以上版本不需要,将使用内置json模块)
用法
要初始化API,只需导入它并定义一个API密钥即可。
(如果您没有API密钥,请访问http://services.sunlightlabs.com/api/进行注册。)
导入TransparencyData类并设置您的API密钥
>>> from transparencydata import TransparencyData >>> td = TransparencyData('sunlight-api-key')
参数运算符
某些参数允许多个值或大于、小于或介于操作。我们允许添加运算符,类似于Django ORM中使用的方法。运算符附加到参数名称的末尾,使用双下划线。
>>> td.contributions(amount=100) # contributions equal to 100 dollars >>> td.contributions(amount__lt=100) # contributions less than 100 dollars>>> td.contributions(cycle=1990) # contributions from the 1990 election cycle >>> td.contributions(cycle__in=(1990,2008)) # contributions from the 1990 and 2008 election cycles
- gt
大于指定值。
- lt
小于指定值。
- between
介于较小值和较大值之间。参数必须传递为两个值的元组或列表。
>>> td.contributions(date__between=(start_date, end_date))
- in
与任何值匹配。参数必须是元组或列表。
请参阅参数文档(http://transparencydata.com/api/)以了解每个参数的有效操作符。
竞选捐款
查找2008年竞选周期中来自加州对Chris Van Hollen的所有捐款
>>> td.contributions(cycle=2008, contributor_state='CA', recipient_ft='van hollen')
可以通过程序访问有效的捐款参数列表
>>> print td.contributions.parameters
游说
查找John Wonderlich进行的所有游说活动
>>> td.lobbying(lobbyist_ft='john wonderlich')
可以通过程序访问有效的游说参数列表
>>> print td.lobbying.parameters
项目详情
python-transparencydata-0.1.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ab80ca3b36e1eea65c8d7fb00aaf32e36312afb8984e1d39f9c1b4051e78f1d9 |
|
MD5 | b48eeb522b13b174f15c6fd92f1ac19d |
|
BLAKE2b-256 | df572247f7360d77e75469c8dc46aac0d360a3a0d65f5b51855053e5120afffa |