GraphHopper Directions API (1.0.0)

Integrate A-to-B route planning, turn-by-turn navigation, route optimization, isochrone calculations, location clustering and other tools into your application.

Authentication
  1. Sign up for GraphHopper and get a standard package for 2 weeks for free
  2. Create an API key

Authenticate to the API by passing your key as a query parameter in every request.

API Explorer

You can also try all API parts without registration in our API explorer.

Client Libraries

To speed up development and make coding easier, we offer a JavaScript client and a Java client.

Optimize Response Speed
  1. Reuse SSL/TLS sessions

You should utilize the SSL session to speed up responses after the initial response or use a library that does this. E.g. for Java the OkHttp library automatically reuses SSL/TLS sessions and also the browser takes care of this automatically. For python you can use the requests library: first you create a session (session = requests.Session()) and then do requests only with this session instead of directly using "requests".

  1. Bandwidth reduction

If you create your own client, make sure it supports http/2 and gzipped responses for best speed. If you use the Matrix, the Route Optimization API or the and want to solve large problems, we recommend you to reduce bandwidth by compressing your POST request and specifying the header as follows: Content-Encoding: gzip. This will also avoid the HTTP 413 error "Request Entity Too Large".

Download OpenAPI description
Languages
Servers
https://graphhopper.com/api/1/

Map Data and Routing Profiles

The default data source is OpenStreetMap and as an alternative we have also integrated TomTom.

Route Optimization

The Route Optimization API can be used to solve traveling salesman or vehicle routing problems. You can use our API Explorer to explore Route Optimization. If you have successfully solved the first problem, we recommend this tutorial - Getting Started with the Optimization API. It shows and describes the essential elements to model your vehicle routing problem.

Further reading:

Operations

Routing

The Routing API calculates the best path connecting two or more points, where the meaning of ''best'' depends on the vehicle profile and use case. Besides path coordinates it can return turn-by-turn instructions, elevation, path details and other useful information about the route.

Use our API Explorer to explore the Routing API.

Operations

Matrices

Operations

Compute a matrix

Request

Calculate a matrix of travel times and/or distances between N origins and M destinations.

This includes the common cases of routes from one origin to many destinations, or from many origins to one destination.

Bodyapplication/json
One of:
profilestring(VehicleProfileId)

The routing profile. It determines the network, speed and other physical attributes used when computing the route. See the section about routing profiles for more details and valid profile values.

from_pointsArray of numbers

The origin points for the routes in an array of [longitude,latitude].

Example: [[-0.11379003524780275,51.53664617804063],[-0.10866165161132814,51.538621486960956],[-0.11059284210205078,51.53245503603458]]
to_pointsArray of numbers

The destination points for the routes in an array of [longitude,latitude].

Example: [[-0.09576559066772462,51.512882367963456],[-0.08797645568847656,51.51317615367198]]
from_point_hintsArray of strings

See point_hintsof symmetrical matrix

Example: ["Copenhagen Street","Richmond Avenue","White Lion Street"]
to_point_hintsArray of strings

See point_hintsof symmetrical matrix

Example: ["Cannon","Cornhill"]
snap_preventionsArray of strings

See snap_preventions of symmetrical matrix

from_curbsidesArray of strings

See curbsidesof symmetrical matrix

to_curbsidesArray of strings

See curbsidesof symmetrical matrix

out_arraysArray of strings

Specifies which matrices should be included in the response. Specify one or more of the following options weights, times, distances. The units of the entries of distances are meters, of times are seconds and of weights is arbitrary and it can differ for different vehicles or versions of this API.

Example: ["weights","times","distances"]
fail_fastboolean

Specifies whether or not the matrix calculation should return with an error as soon as possible in case some points cannot be found or some points are not connected. If set to false the time/weight/distance matrix will be calculated for all valid points and contain the null value for all entries that could not be calculated. The hint field of the response will also contain additional information about what went wrong (see its documentation).

Default true
curl -i -X POST \
  'https://graphhopper.com/api/1/matrix?key=YOUR_API_KEY_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
    "from_points": [
      [
        -0.11379003524780275,
        51.53664617804063
      ],
      [
        -0.10866165161132814,
        51.538621486960956
      ],
      [
        -0.11059284210205078,
        51.53245503603458
      ]
    ],
    "to_points": [
      [
        -0.09576559066772462,
        51.512882367963456
      ],
      [
        -0.08797645568847656,
        51.51317615367198
      ]
    ],
    "from_point_hints": [
      "Copenhagen Street",
      "Richmond Avenue",
      "White Lion Street"
    ],
    "to_point_hints": [
      "Cannon",
      "Cornhill"
    ],
    "out_arrays": [
      "weights",
      "times",
      "distances"
    ],
    "vehicle": "car"
  }'

Responses

Matrix API response

Headers
X-RateLimit-Limitinteger

Your current daily credit limit.

X-RateLimit-Remaininginteger

Your remaining credits until the reset.

X-RateLimit-Resetinteger

The number of seconds that you have to wait before a reset of the credit count is done.

X-RateLimit-Creditsinteger

The credit costs for this request. Note it could be a decimal and even negative number, e.g. when an async request failed.

Bodyapplication/json
distancesArray of numbers

The distance matrix for the specified points in the same order as the time matrix. The distances are in meters. If fail_fast=false the matrix will contain null for connections that could not be found.

Example: [[0,97653,48887],[97426,0,121035],[49006,121049,0]]
timesArray of numbers

The time matrix for the specified points in the order [[from1->to1, from1->to2, ...], [from2->to1, from2->to2, ...], ...]. The times are in seconds. If fail_fast=false the matrix will contain null for connections that could not be found.

Example: [[0,4197,2994],[4192,0,6074],[3006,6062,0]]
weightsArray of numbers

The weight matrix for the specified points in the same order as the time matrix. The weights for different vehicle profiles can have a different unit but the weights array is perfectly suited as input for Vehicle Routing Problems as it is currently faster to calculate. If fail_fast=false the matrix will contain null for connections that could not be found.

Example: [[0,5662.551,3727.147],[5653.807,0,7889.653],[3741.528,7878.365,0]]
infoobject(ResponseInfo)

Additional information for your request

Example: {"copyrights":["GraphHopper","OpenStreetMap contributors"]}
info.​copyrightsArray of strings

Attribution according to our documentation is necessary if no white-label option included.

Example: ["GraphHopper","OpenStreetMap contributors"]
info.​tooknumber(double)
hintsArray of objects

Optional. Additional response data.

hints[].​messagestring

Short description of this hint

hints[].​detailsstring

Details of this hint

hints[].​invalid_from_pointsArray of numbers(int32)

Optional. An array of from_point indices of points that could not be found. Will only be added if fail_fast=false and some from_points were not found.`

hints[].​invalid_to_pointsArray of numbers(int32)

Optional. An array of to_point indices of points that could not be found. Will only be added if fail_fast=false and some to_points were not found.`

hints[].​point_pairsArray of numbers

Optional. An array of two-element arrays representing the from/to_point indices of points for which no connection could be found. Will only be added if fail_fast=false and some connections were not found.

Response
application/json
{ "distances": [ [ 0, 97653, 48887 ], [ 97426, 0, 121035 ], [ 49006, 121049, 0 ] ], "times": [ [ 0, 4197, 2994 ], [ 4192, 0, 6074 ], [ 3006, 6062, 0 ] ], "weights": [ [ 0, 5662.551, 3727.147 ], [ 5653.807, 0, 7889.653 ], [ 3741.528, 7878.365, 0 ] ], "info": { "copyrights": [ "GraphHopper", "OpenStreetMap contributors" ] } }

Compute a matrix

Request

For N origins and M destinations, compute routes from all origins to all destinations and output the result as a matrix of travel times and/or distances.

This includes the common cases of routes from one origin to many destinations, or from many origins to one destination.

Query
profilestring(VehicleProfileId)

The routing profile. It determines the network, speed and other physical attributes used when computing the route. See the section about routing profiles for more details and valid profile values.

Default "car"
pointArray of strings

Specify multiple points in latitude,longitude for which the weight-, route-, time- or distance-matrix should be calculated. In this case the starts are identical to the destinations. If there are N points, then NxN entries will be calculated. The order of the point parameter is important. Specify at least three points. Cannot be used together with from_point or to_point.

from_pointArray of strings

The origin points for the routes in latitude,longitude. E.g. if you want to calculate the three routes A->1, A->2, A->3 then you have one from_point parameter and three to_point parameters.

to_pointArray of strings

The destination points for the routes in latitude,longitude.

point_hintArray of strings

Optional parameter. Specifies a hint for each point parameter to prefer a certain street for the closest location lookup. E.g. if there is an address or house with two or more neighboring streets you can control for which street the closest location is looked up.

from_point_hintArray of strings

For the from_point parameter. See point_hint

to_point_hintArray of strings

For the to_point parameter. See point_hint

snap_preventionArray of strings

Optional parameter. 'Snapping' is the process of finding the closest road location for GPS coordinates provided in the point parameter. The snap_prevention parameter allows you to prevent snapping to specific types of roads. For example, if snap_prevention is set to bridge, the routing engine will avoid snapping to a bridge, even if it is the closest road for the given point. Current supported values: motorway, trunk, ferry, tunnel, bridge and ford. Multiple values are specified like snap_prevention=ferry&snap_prevention=motorway. Note that once snapped the routing algorithm can still route over bridges (or the other values). To avoid this you need to use the custom_model.

curbsideArray of strings

Optional parameter. It specifies on which side a point should be relative to the driver when she leaves/arrives at a start/target/via point. You need to specify this parameter for either none or all points. Only supported for motor vehicles and OpenStreetMap.

Items Enum"any""right""left"
from_curbsideArray of strings

Curbside setting for the from_point parameter. See curbside.

Items Enum"any""right""left"
to_curbsideArray of strings

Curbside setting for the to_point parameter. See curbside.

Items Enum"any""right""left"
out_arrayArray of strings

Specifies which arrays should be included in the response. Specify one or more of the following options 'weights', 'times', 'distances'. To specify more than one array use e.g. out_array=times&out_array=distances. The units of the entries of distances are meters, of times are seconds and of weights is arbitrary and it can differ for different vehicles or versions of this API.

fail_fastboolean

Specifies whether or not the matrix calculation should return with an error as soon as possible in case some points cannot be found or some points are not connected. If set to false the time/weight/distance matrix will be calculated for all valid points and contain the null value for all entries that could not be calculated. The hint field of the response will also contain additional information about what went wrong (see its documentation).

Default true
curl "https://graphhopper.com/api/1/matrix?point=49.932707,11.588051&point=50.241935,10.747375&point=50.118817,11.983337&type=json&profile=car&out_array=weights&out_array=times&out_array=distances&key=api_key"

Responses

Matrix API response

Headers
X-RateLimit-Limitinteger

Your current daily credit limit.

X-RateLimit-Remaininginteger

Your remaining credits until the reset.

X-RateLimit-Resetinteger

The number of seconds that you have to wait before a reset of the credit count is done.

X-RateLimit-Creditsinteger

The credit costs for this request. Note it could be a decimal and even negative number, e.g. when an async request failed.

Bodyapplication/json
distancesArray of numbers

The distance matrix for the specified points in the same order as the time matrix. The distances are in meters. If fail_fast=false the matrix will contain null for connections that could not be found.

Example: [[0,97653,48887],[97426,0,121035],[49006,121049,0]]
timesArray of numbers

The time matrix for the specified points in the order [[from1->to1, from1->to2, ...], [from2->to1, from2->to2, ...], ...]. The times are in seconds. If fail_fast=false the matrix will contain null for connections that could not be found.

Example: [[0,4197,2994],[4192,0,6074],[3006,6062,0]]
weightsArray of numbers

The weight matrix for the specified points in the same order as the time matrix. The weights for different vehicle profiles can have a different unit but the weights array is perfectly suited as input for Vehicle Routing Problems as it is currently faster to calculate. If fail_fast=false the matrix will contain null for connections that could not be found.

Example: [[0,5662.551,3727.147],[5653.807,0,7889.653],[3741.528,7878.365,0]]
infoobject(ResponseInfo)

Additional information for your request

Example: {"copyrights":["GraphHopper","OpenStreetMap contributors"]}
info.​copyrightsArray of strings

Attribution according to our documentation is necessary if no white-label option included.

Example: ["GraphHopper","OpenStreetMap contributors"]
info.​tooknumber(double)
hintsArray of objects

Optional. Additional response data.

hints[].​messagestring

Short description of this hint

hints[].​detailsstring

Details of this hint

hints[].​invalid_from_pointsArray of numbers(int32)

Optional. An array of from_point indices of points that could not be found. Will only be added if fail_fast=false and some from_points were not found.`

hints[].​invalid_to_pointsArray of numbers(int32)

Optional. An array of to_point indices of points that could not be found. Will only be added if fail_fast=false and some to_points were not found.`

hints[].​point_pairsArray of numbers

Optional. An array of two-element arrays representing the from/to_point indices of points for which no connection could be found. Will only be added if fail_fast=false and some connections were not found.

Response
application/json
{ "distances": [ [ 0, 97653, 48887 ], [ 97426, 0, 121035 ], [ 49006, 121049, 0 ] ], "times": [ [ 0, 4197, 2994 ], [ 4192, 0, 6074 ], [ 3006, 6062, 0 ] ], "weights": [ [ 0, 5662.551, 3727.147 ], [ 5653.807, 0, 7889.653 ], [ 3741.528, 7878.365, 0 ] ], "info": { "copyrights": [ "GraphHopper", "OpenStreetMap contributors" ] } }

Submit a matrix computation job

Request

An alternate endpoint for computing a large matrix asynchronously, where a request against the regular endpoint would result in a timeout.

The request format is the same, but instead of the result, you are given a job identification number that you can use to retrieve the result once it is available.

In most cases, prefer the regular endpoints.

Here are some full examples via curl:

$ curl -X POST -H "Content-Type: application/json" "https://graphhopper.com/api/1/matrix/calculate?key=[YOUR_KEY]" -d '{"points":[[13.29895,52.48696],[13.370876,52.489575],[13.439026,52.511206]]}'
{"job_id":"7ac65787-fb99-4e02-a832-2c3010c70097"}

Pick the returned job_id and use it in the next GET requests:

$ curl -X GET "https://graphhopper.com/api/1/matrix/solution/7ac65787-fb99-4e02-a832-2c3010c70097?key=[YOUR_KEY]"
{"status":"waiting"}

When the calculation is finished (status:finished) the JSON response will contain the full matrix JSON under solution:

$ curl -X GET "https://graphhopper.com/api/1/matrix/solution/7ac65787-fb99-4e02-a832-2c3010c70097?key=[YOUR_KEY]"
{"solution":{"weights":[[0.0,470.453,945.414],[503.793,0.0,580.871],[970.49,569.511,0.0]],"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"]}},"status":"finished"}

Please note that if an error occured while calculation the JSON will not have a status but contain directly the error message e.g.:

{"message":"Cannot find from_points: 1"}

And the optional hints array.

Bodyapplication/json
One of:
profilestring(VehicleProfileId)

The routing profile. It determines the network, speed and other physical attributes used when computing the route. See the section about routing profiles for more details and valid profile values.

from_pointsArray of numbers

The origin points for the routes in an array of [longitude,latitude].

Example: [[-0.11379003524780275,51.53664617804063],[-0.10866165161132814,51.538621486960956],[-0.11059284210205078,51.53245503603458]]
to_pointsArray of numbers

The destination points for the routes in an array of [longitude,latitude].

Example: [[-0.09576559066772462,51.512882367963456],[-0.08797645568847656,51.51317615367198]]
from_point_hintsArray of strings

See point_hintsof symmetrical matrix

Example: ["Copenhagen Street","Richmond Avenue","White Lion Street"]
to_point_hintsArray of strings

See point_hintsof symmetrical matrix

Example: ["Cannon","Cornhill"]
snap_preventionsArray of strings

See snap_preventions of symmetrical matrix

from_curbsidesArray of strings

See curbsidesof symmetrical matrix

to_curbsidesArray of strings

See curbsidesof symmetrical matrix

out_arraysArray of strings

Specifies which matrices should be included in the response. Specify one or more of the following options weights, times, distances. The units of the entries of distances are meters, of times are seconds and of weights is arbitrary and it can differ for different vehicles or versions of this API.

Example: ["weights","times","distances"]
fail_fastboolean

Specifies whether or not the matrix calculation should return with an error as soon as possible in case some points cannot be found or some points are not connected. If set to false the time/weight/distance matrix will be calculated for all valid points and contain the null value for all entries that could not be calculated. The hint field of the response will also contain additional information about what went wrong (see its documentation).

Default true
curl -i -X POST \
  'https://graphhopper.com/api/1/matrix/calculate?key=YOUR_API_KEY_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
    "from_points": [
      [
        -0.11379003524780275,
        51.53664617804063
      ],
      [
        -0.10866165161132814,
        51.538621486960956
      ],
      [
        -0.11059284210205078,
        51.53245503603458
      ]
    ],
    "to_points": [
      [
        -0.09576559066772462,
        51.512882367963456
      ],
      [
        -0.08797645568847656,
        51.51317615367198
      ]
    ],
    "from_point_hints": [
      "Copenhagen Street",
      "Richmond Avenue",
      "White Lion Street"
    ],
    "to_point_hints": [
      "Cannon",
      "Cornhill"
    ],
    "out_arrays": [
      "weights",
      "times",
      "distances"
    ],
    "vehicle": "car"
  }'

Responses

A jobId you can use to retrieve your solution from the server.

Headers
X-RateLimit-Limitinteger

Your current daily credit limit.

X-RateLimit-Remaininginteger

Your remaining credits until the reset.

X-RateLimit-Resetinteger

The number of seconds that you have to wait before a reset of the credit count is done.

X-RateLimit-Creditsinteger

The credit costs for this request. Note it could be a decimal and even negative number, e.g. when an async request failed.

Bodyapplication/json
job_idstring(uuid)

UUID. Unique id for your job/request with which you can fetch your solution

Example: "44886560-b584-4da5-b245-768151dacd8f"
Response
application/json
{ "job_id": "44886560-b584-4da5-b245-768151dacd8f" }

Retrieve result of a matrix computation job

Request

Path
jobIdstringrequired

The jobId you received when you submitted the job.

curl -i -X GET \
  'https://graphhopper.com/api/1/matrix/solution/{jobId}?key=YOUR_API_KEY_HERE'

Responses

A response containing the matrix

Headers
X-RateLimit-Limitinteger

Your current daily credit limit.

X-RateLimit-Remaininginteger

Your remaining credits until the reset.

X-RateLimit-Resetinteger

The number of seconds that you have to wait before a reset of the credit count is done.

X-RateLimit-Creditsinteger

The credit costs for this request. Note it could be a decimal and even negative number, e.g. when an async request failed.

Bodyapplication/json
solutionobject(MatrixResponse)
solution.​distancesArray of numbers

The distance matrix for the specified points in the same order as the time matrix. The distances are in meters. If fail_fast=false the matrix will contain null for connections that could not be found.

solution.​timesArray of numbers

The time matrix for the specified points in the order [[from1->to1, from1->to2, ...], [from2->to1, from2->to2, ...], ...]. The times are in seconds. If fail_fast=false the matrix will contain null for connections that could not be found.

solution.​weightsArray of numbers

The weight matrix for the specified points in the same order as the time matrix. The weights for different vehicle profiles can have a different unit but the weights array is perfectly suited as input for Vehicle Routing Problems as it is currently faster to calculate. If fail_fast=false the matrix will contain null for connections that could not be found.

solution.​infoobject(ResponseInfo)

Additional information for your request

solution.​hintsArray of objects

Optional. Additional response data.

Response
application/json
{ "solution": { "distances": [ [ 0, 97653, 48887 ], [ 97426, 0, 121035 ], [ 49006, 121049, 0 ] ], "times": [ [ 0, 4197, 2994 ], [ 4192, 0, 6074 ], [ 3006, 6062, 0 ] ], "weights": [ [ 0, 5662.551, 3727.147 ], [ 5653.807, 0, 7889.653 ], [ 3741.528, 7878.365, 0 ] ], "info": { "copyrights": [ "GraphHopper", "OpenStreetMap contributors" ] } } }

Geocoding

Geocoding describes the process of transforming an textual address representation to a coordinate (latitude,longitude). For example the conversion from Berlin to 52.5170365,13.3888599.

Reverse geocoding converts a coordinate to a textual address representation or place name. Find out more about Geocoding itself on Wikipedia.

Operations

Isochrones

An isochrone of a location is ''a line connecting points at which a vehicle arrives at the same time'', see Wikipedia. With the same API you can also calculate isodistances, just use the parameter distance_limit instead of time_limit`.

Some possible areas in which this API may be useful to you:

  • real estate analysis
  • realtors
  • vehicle scheduling
  • geomarketing
  • reach of electric vehicles
  • transport planning
  • logistics (distribution and retail network planning)

See the clients section in the main documentation, and our API explorer.

Operations

Map Matching

You can snap measured GPS points typically as GPX files to a digital road network to e.g. clean data or attach certain data like elevation or turn instructions to it.

See the clients section in the main documentation, and our API explorer.

The cost for one request depends on the number of GPS location and is documented here.

One request should not exceed the Map Matching API location limit depending on the package, see the pricing in our dashboard.

Operations

Clustering

It solves the “capacity clustering problem” by assigning a set of customers to a given number of distinct groups (called clusters). The API “clusters” by minimizing the total distance from each individual customer to its designated group median. It can also consider minimum and maximum capacity restrictions for each group.

Clustering can be used in many practical applications. For example, it can help to plan territories, i.e. territory optimization for field teams with large territories for field workers, or to solve large vehicle routing problems (VRP).

Try Clustering in our API Explorer!

The idea is to divide a certain number of customers, a pre-specified number of clusters. As already written above, a distribution is sought that minimizes the total cost (e.g. distance or time or a function of distance and time). We currently support two approaches.

  1. You can simply define a certain number of clusters via configuration ("clustering" with empty set of "clusters") and additionally how many customers should be in such a cluster. This is defined by an upper and lower limit ("min_quantity" and "max_quantity). The algorithm then searches for suitable clusters and divides the customers into these clusters.

  2. You can explicitly define clusters via "clusters". In this way, each individual cluster can be defined. This approach not only allows each cluster to have its own capacity upper and lower bound, but each cluster can also be assigned a fixed cluster center. In contrast to 1. the algorithm then does not search for a suitable center, but assigns the customers given the fixed centers to each cluster. Note that if you define clusters explicitly, any configuration of "clustering" will be overwritten by these explicit clusters.

Operations

Custom Model

A custom model allows you to modify the default routing behavior of a vehicle profile by specifying a set of rules in JSON language. There are three JSON properties to change a profile: priority, speed and distance_influence that are described in great detail in the next sections and you can get a quick overview in this example-driven blog post.

But first we will give an introductory example for each of these JSON properties. Let's start with speed:

{
  "speed": [{
    "if": "road_class == MOTORWAY",
    "limit_to": "90"
  }]
}

As you might have already guessed this limits the speed on motorways to 90km/h. Changing the speed will of course change the travel time, but at the same time this makes other road classes more likely as well, so you can use this model to avoid motorways.

You can immediately try this out in the Browser on GraphHopper Maps. GraphHopper Maps offers an interactive text editor to comfortably enter custom models. You can open it by pressing the "custom" button. It will check the syntax of your custom model and mark errors in red. You can press Ctrl+Space or Alt+Enter to retrieve auto-complete suggestions. Pressing Ctrl+Enter will send a routing request for the custom model you entered. To disable the custom model you click the "custom" button again.

In the second example we show how to avoid certain road classes without changing the travel time:

{
  "priority": [{
    "if": "road_class == LIVING_STREET || road_class == RESIDENTIAL || road_class == UNCLASSIFIED",
    "multiply_by": "0.1"
  }]
}

This example avoids certain smaller streets. View it in GraphHopper Maps.

The third example shows how to prefer shortest paths:

{
  "distance_influence": 200
}

View this example in GraphHopper Maps.

There is a fourth JSON property areas that allows you to define areas that can then be used in the if or else_if conditions for speed and priority. Please read more about this and the other properties below and try some examples in GraphHopper Maps with the help of this blog post.

Custom Profiles

You can create routing profiles that are customized to your needs. You can take advantage of all the modelling options described in the Custom Model section and use the created custom profile (prefix cp_) with our Routing, Matrix and Route Optimization APIs.

Important notes

  • Each custom profile is limited to a geographic area boundary. Within this boundary there is maximum flexibility for adjusting the profile and you can expect fast response times.
  • Currently this feature is only available to selected customers and customers with a premium package. If you are interested please contact us.
  • This feature is currently in beta status. It is fully functional, but the API might change in the future. Changes will of course be announced well in advance.
  • You can use the following profiles as base profile: car, bike, foot and ecargobike. Contact us if you have different requirements. Motor vehicles can be emulated like done for truck in this post.

A curl example:

curl -X POST -H "Content-Type: application/json" "https://graphhopper.com/api/1/profiles?key=YOUR_KEY" -d '{"bounds":{"bbox":[11.45462,48.00954,11.77322,48.2076]},"custom_model":{"priority":[{"if":"road_class == MOTORWAY","multiply_by":"0"}]},"profile":"car"}'

If you plan to tweak your custom_model frequently it is recommended to initially use the Routing API where a different custom model can be specified in every request. Or use GraphHopper Maps and click the gear button.

Creating custom profiles using the API Explorer

Besides using the /profiles endpoint directly you can also create custom profiles from our API explorer.

The API Explorer's Profiles Section

  1. Visit the API explorer.
  2. Set your API key with the "API key" button. If an error occurs we might have to activate custom profiles for your account before you can continue. Contact us.
  3. Now copy and paste the JSON to create a custom profile into the input window. To get started you can use the already pre-filled example, which will create a custom profile that excludes motorways and is limited to the Munich area.
  4. Click "Send". This creates a custom profile. Copy the returned id from the output window (it starts with cp_).
  5. To try this profile out you now change the drop down to "Optimization API", pick the first example and replace "car" in "profile": "car" (vehicle_types section) with the profile id and click "Send":

The API Explorer's Optimization Section

You should now see that the solution no longer uses motorways. Keep in mind that this is a simple example. The custom model language is a lot more powerful than this. Make sure you read the Custom Model section to learn about all the details.

Note that you can use the profile id just as well for the /matrix or /route endpoint. E.g. select "Routing API" and use the profile id in the request:

The API Explorer's Routing Section

Operations