citybikes api的客户端接口
python-citybikes的Python项目详细描述
python城市图片
python citybikes是Citybikes API的python客户机。
关于城市生活
Citybikes是一个关于让自行车共享数据对两个用户都可用的项目 还有开发商。它有一个很好且易于使用的api,但是这个包可能是 对使用api的项目很有用。
python-citybikes不能与pybikes:
- pybikes是一组工具,用于直接从提供商处访问自行车共享数据。它是为项目和api提供动力的库。如果网络不受支持或无法正常工作,则必须在那里发送问题或贡献。
- python citybikes是围绕Citybikes API的python包装器。
安装
$ pip install python-citybikes
使用量
首先实例化客户机
>>>> import citybikes >>>> client = citybikes.Client()
获取网络的完整列表
>>>> networks = list(client.networks) >>>> len(networks) 458 >>>> networks[0] {'name': 'Opole Bike', 'href': '/v2/networks/opole-bike', 'location': {'lat itude': 50.6645, 'city': 'Opole', 'country': 'PL', 'longitude': 17.9276}, ' id': 'opole-bike', 'company': ['Nextbike GmbH']}
从网络获取电台
>>>> len(networks[0].stations) 16 >>>> list(networks[0].stations)[0] {'timestamp': '2016-11-22T16:05:44.318000Z', 'id': 'd8c9f66260759aeb27445b2 cddf2d6b9', 'name': 'Pętla Autobusowa - Dambonia', 'free_bikes': 7, 'empty_ slots': 3, 'latitude': 50.661775266224, 'extra': {'bike_uids': ['60128', '6 0108', '60063', '60062', '60052', '60037', '60190'], 'number': '6011', 'slo ts': 10, 'uid': '132115'}, 'longitude': 17.888891100884}
直接通过id实例化网络
>>>> bicing = citybikes.Network(client, uid='bicing') >>>> bicing['name'] 'Bicing' >>>> len(bicing.stations) 465
按到LAT、液化天然气的距离订购网络
>>>> # Lets get the nearest network to NY lat, lng >>>> net, dist = next(iter(client.networks.near(40.7128, -74.0059))) >>>> net {'href': '/v2/networks/citi-bike-nyc', 'id': 'citi-bike-nyc', 'gbfs_href': 'https://gbfs.citibikenyc.com/gbfs/gbfs.json', 'location': {'latitude': 40. 7143528, 'country': 'US', 'longitude': -74.00597309999999, 'city': 'New Yor k, NY'}, 'company': ['NYC Bike Share, LLC', 'Motivate International, Inc.', 'PBSC Urban Solutions'], 'name': 'Citi Bike'}
从按到LAT、液化天然气的距离排序的网络获取站点
>>>> # Now, get stations ordered by distance to Manhattan center >>>> sts = net.stations.near(40.7831, -73.9712) >>>> for s, dist in sts[:5]: ... print(s['name']) ... W 82 St & Central Park West Central Park West & W 85 St W 84 St & Columbus Ave Central Park West & W 76 St W 89 St & Columbus Ave
历史记录
0.1.4(2019-07-26)
- 修复python 2兼容性
0.1.3(2017-02-13)
- 为资源添加json编码器
0.1.1(2016-11-22)
- 改进文档
- 近辅助对象还返回相对距离
0.1.0(2016-11-17)
- 首次发布
- 可以导航citybikes api
- 资源请求只执行一次