The openrouteservice library gives you painless access to the openrouteservice (ORS) routing API's. This Python package is automatically generated by the Swagger Codegen using our latest API specifications.
API Version | Package version | Build package |
---|---|---|
7.1.1 | 7.1.1.post2 | io.swagger.codegen.v3.generators.python.PythonClientCodegen |
For further details, please visit:
For support, please ask our forum. By using this library, you agree to the ORS terms and conditions.
Python 2.7 and 3.4+
If the python package is hosted on Github, you can install directly from Github
pip install ors-py
Then import the package:
import openrouteservice
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install
to install the package for all users)
Then import the package:
import openrouteservice
Please follow the installation procedure before running the examples:
These examples show common usages of this library.
- Avoid construction sites dynamically
- Dieselgate Routing
- Route optimization of pub crawl
- Routing optimization in humanitarian context
import openrouteservice as ors
from pprint import pprint
# create an instance of the API class
directionsApi = ors.DirectionsServiceApi(
ors.apiClient(apiKey="YOUR_API_KEY") # set your api key here
)
# create request body
body = ors.DirectionsService(
coordinates=[[8.34234,48.23424],[8.34423,48.26424]]
)
profile = 'driving-car'
try:
routes = directionsApi.get_geo_json_route(body, profile)
pprint(routes)
except ors.rest.ApiException as e:
print("Exception when calling DirectionsServiceApi->get_geo_json_route: %s\n" % e)
import openrouteservice as ors
from pprint import pprint
isochronesApi = ors.IsochronesServiceApi(
ors.apiClient(host="http://localhost:8080/ors") # set host to your local instance
)
body = ors.IsochronesProfileBody(
locations=[[8.681495,49.41461],[8.686507,49.41943]],
range=[300]
)
profile = 'driving-car' # Specifies the route profile.
try:
api_response = isochronesApi.get_default_isochrones(body, profile)
pprint(api_response)
except ors.rest.ApiException as e:
print("Exception when calling IsochronesServiceApi->get_default_isochrones: %s\n" % e)
All URIs are relative to https://api.openrouteservice.org
Class | Method | HTTP request | Description |
---|---|---|---|
DirectionsServiceApi | get_geo_json_route | POST /v2/directions/{profile}/geojson | Directions Service GeoJSON |
DirectionsServiceApi | get_json_route | POST /v2/directions/{profile}/json | Directions Service JSON |
ElevationApi | elevation_line_post | POST /elevation/line | Elevation Line Service |
ElevationApi | elevation_point_get | GET /elevation/point | Elevation Point Service |
ElevationApi | elevation_point_post | POST /elevation/point | Elevation Point Service |
GeocodeApi | geocode_autocomplete_get | GET /geocode/autocomplete | Geocode Autocomplete Service |
GeocodeApi | geocode_reverse_get | GET /geocode/reverse | Reverse Geocode Service |
GeocodeApi | geocode_search_get | GET /geocode/search | Forward Geocode Service |
GeocodeApi | geocode_search_structured_get | GET /geocode/search/structured | Structured Forward Geocode Service (beta) |
IsochronesServiceApi | get_default_isochrones | POST /v2/isochrones/{profile} | Isochrones Service |
MatrixServiceApi | get_default1 | POST /v2/matrix/{profile} | Matrix Service |
OptimizationApi | optimization_post | POST /optimization | Optimization Service |
PoisApi | pois_post | POST /pois | Pois Service |
SnappingServiceApi | get_default | POST /v2/snap/{profile} | Snapping Service |
SnappingServiceApi | get_geo_json_snapping | POST /v2/snap/{profile}/geojson | Snapping Service GeoJSON |
SnappingServiceApi | get_json_snapping | POST /v2/snap/{profile}/json | Snapping Service JSON |
- AlternativeRoutes
- DirectionsServiceBody
- ElevationLineBody
- ElevationPointBody
- IsochronesProfileBody
- JSONResponse
- MatrixProfileBody
- OpenpoiservicePoiRequest
- OptimizationBody
- OptimizationBreaks
- OptimizationCosts
- OptimizationJobs
- OptimizationMatrices
- OptimizationMatricesCyclingelectric
- OptimizationOptions
- OptimizationSteps
- OptimizationVehicles
- PoisFilters
- PoisGeometry
- ProfileGeojsonBody
- ProfileJsonBody
- ProfileParameters
- ProfileParametersRestrictions
- ProfileWeightings
- RoundTripRouteOptions
- RouteOptions
- RouteOptionsAvoidPolygons
- SnapProfileBody