用于与LTA DataMall上的API交互的Python包
landtransportsg的Python项目详细描述
这是一个非官方的Python包,用于与api交互 LTA DataMall。在
安装程序包
使用pip安装包:
pip install landtransportsg
使用软件包
先决条件:
- 来自LTA的API密钥。Request for API access。在
主要步骤是:
- 导入一个类。在
- 从类实例化一个对象。在
- 调用该对象上的函数。在
有关详细信息,refer to the documentation。在
使用概述
与LTA DataMall的API的交互是通过三个客户端之一完成的, 其中每个客户端对应一组端点。在
这四个客户机是:ActiveMobility,Geospatial,PublicTransport 和Traffic。在
每个客户端包含多个公共函数,每个端点一个函数。A 函数的名称与其相应端点的结束路径相同。在
有些函数接受命名参数,其中参数与 终结点接受的参数。在
Why have separate clients instead of one single client?
Without knowing how LTA DataMall’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 ^{tt4}$ passenger volume-related endpoints allow for a string to be returned, whereas the other endpoints return a list.
- 项目
标签: