一个简单的 BikeWise API 包装器
项目描述
一个简单的BikeWise API 包装器。
许可证:麻省理工学院。
安装
pip install python-bikewise
API 示例
创建 BikeWise类的实例。例如:
from bikewise import BikeWise
bike = BikeWise()
您可以访问事件或位置信息:
如果您想了解有关自行车事故的更多详细信息,请访问事故端点。
如果您想映射事件位置,请访问位置端点。此端点的行为与事件完全相同,但返回有效的 geojson。
访问locations.markers端点(行为类似于根位置端点)以返回简单样式标记(mapbox 样式标记)。
BikeWise()中方法的可接受参数表。请注意,某些参数仅限于某些方法 - 请查看下面的示例。
参数 |
数据类型 |
描述 |
笔记 |
|---|---|---|---|
页 |
整数 |
要获取的结果页面。 |
|
每页 |
整数 |
每页返回的结果数。默认为 25 |
|
发生_之前 |
整数 |
期末 |
接受 UTC unix 时间戳。 |
发生后 |
整数 |
期初 |
接受 UTC unix 时间戳。 |
事件类型 |
细绳 |
仅限特定类型的事件 |
|
接近 |
细绳 |
邻近搜索的位置中心 |
接受 IP 地址、地址、邮政编码、城市或纬度、经度 - 即70.210.133.87 , 210 NW 11th Ave, Portland, OR , 60647 , Chicago, IL和45.521728,-122.67326都是可以接受的。 |
接近正方形 |
整数 |
邻近搜索的大小 |
设置正方形边的长度以在其中查找匹配项。正方形以邻近度指定的位置为中心。 |
询问 |
细绳 |
事件的全文搜索 |
|
ID |
整数 |
事件 ID |
|
限制 |
整数 |
要返回的最大结果数。默认为 100 |
|
全部 |
布尔值 |
把它们都给我。将忽略限制 |
如果传递all参数,它将返回所有匹配项(可能很大,> 4mb),否则返回 100 个最近的匹配项。 |
事件:
# incidents method parameters
"""
bike.incidents(page=0, per_page=25)
bike.incidents.id(id)
bike.incidents.features(page=0, per_page=25, occurred_before=0, occurred_after=0,
incident_type="", proximity="", proximity_area=0, query="")
"""
# example
>>> bike.incidents.features(per_page=1, occurred_after=1440444800, incident_type='theft')
>>> {'incidents': [{'address': 'Portland, OR, 97227',
'description': 'Taken from basement',
'id': 115242,
'location_description': None,
'location_type': None,
'media': {'image_url': None, 'image_url_thumb': None},
'occurred_at': 1585854000,
'source': {'api_url': 'https://bikeindex.org/api/v1/bikes/705265',
'html_url': 'https://bikeindex.org/bikes/705265',
'name': 'BikeIndex.org'},
'title': 'Stolen 2018 On-One Dirty Disco(black)',
'type': 'Theft',
'type_properties': None,
'updated_at': 1585862797,
'url': 'https://bikewise.org/api/v1/incidents/115242'}]}
位置和标记:
# locations method parameters
"""
bike.locations(limit=100, all=False)
bike.locations.features(occurred_before=0, occurred_after=0, incident_type="", proximity="",
proximity_area=0, query="", limit=100, all=False)
bike.locations.markers(occurred_before=0, occurred_after=0, incident_type="", proximity="",
proximity_area=0, query="", limit=100, all=False)
"""
# example
>>> bike.locations.features(occurred_after=1440444800, incident_type='theft', limit=1)
>>> {'features': [{'geometry': {'coordinates': [-122.6766628, 45.5461375],
'type': 'Point'},
'properties': {'description': 'Taken from basement <a '
'href="https://bikeindex.org/bikes/705265" '
'target="_blank">View details</a>',
'id': 115242,
'marker-color': '#BD1622',
'marker-size': 'small',
'occurred_at': '2020-04-02 14:00:00 -0500',
'title': 'Stolen 2018 On-One Dirty Disco '
'(04-02-2020)'},
'type': 'Feature'}],
'type': 'FeatureCollection'}
支持
如果您发现任何错误或想要提出新功能,请使用问题跟踪器。我很乐意提供帮助!
项目详情
关
python_bikewise -0.1.0-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | d4d93fb25b5ac71dc877573ca25d1acab1386b601549e8a3b1cfb59597984997 |
|
| MD5 | c22719711370f4aa9ce3927c61cee5f2 |
|
| 布莱克2-256 | 68e7a9ac10e10d75c788463f6d48bf22cf944ce40e902cfe72b7998e932d9761 |