可在data.gov.sg上获得用于与api交互的python包
datagovsg的Python项目详细描述
这是一个非正式的python包,用于与Data.gov.sg上提供的api交互。
安装软件包
使用pip:
安装包pip install datagovsg
使用软件包
主要步骤是:
- 导入类。
- 从类中实例化对象。
- 对该对象调用函数。
有关详细信息,请refer to the documentation。
使用概述
与Data.gov.sg的api交互是通过四个客户端之一完成的,其中每个客户端对应一组端点。(Data.gov.sg不按集合对其终结点进行分类,但可以从终结点的路径目录中进行假设。)
这四个客户端是:Ckan、Environment、Technology和Transport。
每个客户端包含几个公共函数,每个端点一个函数。函数名与其对应端点的结束路径相同。
大多数函数接受命名参数,其中一个参数与端点接受的参数相对应。
Why have separate clients instead of one single client?
Without knowing how Data.gov.sg’s API will evolve, and noticing that the endpoints were themselves already partitioned into “sets”, it seemed like a good idea to keep each set of endpoints in its own contextual client. This allows for each “set” of endpoints to be customised on their own, e.g. the ^{tt3}$ endpoints allow for either a date or date-time to be specified, whereas the ^{tt5}$ endpoints don’t.