A simple BikeWise API wrapper
Project description
A simple BikeWise API wrapper.
License: MIT.
Installation
pip install python-bikewise
API Examples
Make an instance of the BikeWise class. For example:
from bikewise import BikeWise
bike = BikeWise()
You can access incident or location information:
Access the incidents endpoint if you’d like more detailed information about bike incidents.
Access the locations endpoint if you’d like to map incident locations. This endpoint behaves exactly like incidents, but returns a valid geojson.
Access the locations.markers endpoint (behaves like root locations endpoint) to return simplestyled markers (mapbox styled markers).
A table of acceptable parameters for methods in BikeWise(). Note, some parameters are restricted to certain methods - please look at the examples below.
Parameter |
Data Type |
Description |
Notes |
---|---|---|---|
page |
integer |
Page of results to fetch. |
|
per_page |
integer |
Number of results to return per page. Defaults to 25 |
|
occurred_before |
integer |
End of period |
Accepts UTC unix timestamps. |
occurred_after |
integer |
Start of period |
Accepts UTC unix timestamps. |
incident_type |
string |
Only incidents of specific type |
|
proximity |
string |
Center of location for proximity search |
Accepts an ip address, an address, zipcode, city, or latitude,longitude - i.e. 70.210.133.87, 210 NW 11th Ave, Portland, OR, 60647, Chicago, IL, and 45.521728,-122.67326 are all acceptable. |
proximity_square |
integer |
Size of the proximity search |
Sets the length of the sides of the square to find matches inside of. The square is centered on the location specified by proximity. |
query |
string |
Full text search of incidents |
|
id |
integer |
Incident ID |
|
limit |
integer |
Max number of results to return. Defaults to 100 |
|
all |
boolean |
Give ‘em all to me. Will ignore limit |
If you pass the all parameter it returns all matches (which can be big, > 4mb), otherwise it returns the 100 most recent. |
Incidents:
# 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 & Markers:
# 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'}
Support
If you find any bug or you want to propose a new feature, please use the issues tracker. I’ll be happy to help!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python-bikewise-0.1.0.tar.gz
.
File metadata
- Download URL: python-bikewise-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9599155e4c53995646bf50edfdcfbdb6ce2bbc8d5eef2e1c1528adb848df3da4 |
|
MD5 | 04f16946b8ecf765825f53e2dbb91271 |
|
BLAKE2b-256 | 711ecee8fa6373d2d65c8ce4e3c6514a8f963625316ff9bab47be3868f7f31e0 |
File details
Details for the file python_bikewise-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: python_bikewise-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4d93fb25b5ac71dc877573ca25d1acab1386b601549e8a3b1cfb59597984997 |
|
MD5 | c22719711370f4aa9ce3927c61cee5f2 |
|
BLAKE2b-256 | 68e7a9ac10e10d75c788463f6d48bf22cf944ce40e902cfe72b7998e932d9761 |