1. Routing
GraphHopper Directions API
  • Routing
    • Calculate a route
      GET
    • Calculate a route
      POST
  • Isochrones
    • Compute an isochrone
      GET
  • Matrices
    • Compute a matrix
      POST
    • Compute a matrix
      GET
    • Submit a matrix computation job
      POST
    • Retrieve result of a matrix computation job
      GET
  • Map Matching
    • Map-match a GPX file
      POST
  • Geocoding
    • Geocoding Endpoint
      GET
  • Route Optimization
    • Solve a route optimization problem
      POST
    • Submit a route optimization job
      POST
    • Retrieve solution of a route optimization job
      GET
  • Clustering
    • Solve a clustering problem
      POST
    • Submit a clustering job
      POST
    • Retrieve solution of a clustering job
      GET
  • Custom Profiles
    • Create a custom routing profile
      POST
    • List your custom routing profiles
      GET
    • Submit a profile creation job
      POST
    • Retrieve result of a profile creation job
      GET
    • Delete a custom routing profile
      DELETE
  • 数据模型
    • Schemas
      • ClusterResponse
      • Cluster
      • ClusterRequest
      • ClusterConfiguration
      • Clusters
      • ClusterCustomer
      • ClusterCustomerAddress
      • ClusterConfigurationRouting
      • ClusterConfigurationClustering
      • GeocodingResponse
      • GeocodingLocation
      • GeocodingPoint
      • MatrixRequest
      • SymmetricalMatrixRequest
      • MatrixResponse
      • RouteRequest
      • CustomModel
      • CustomModelForProfile
      • ProfileRequest
      • ProfileResponse
      • ProfileGetResponse
      • RouteResponse
      • EncodedLineString
      • BBox
      • FeatureCollection
      • RouteResponsePath
      • ResponseInfo
      • IsochroneResponse
      • IsochroneResponsePolygon
      • LineString
      • Polygon
      • GHError
      • JobId
      • BadRequest
      • ErrorMessage
      • InternalErrorMessage
      • Request
      • Vehicle
      • VehicleProfileId
      • Shift
      • Algorithm
      • Address
      • ResponseAddress
      • SnappedWaypoint
      • DriveTimeBreak
      • TimeWindowBreak
      • VehicleType
      • Service
      • Shipment
      • Pickup
      • Stop
      • TimeWindow
      • PreferredVehicle
      • Configuration
      • Optimization
      • Routing
      • Objective
      • CostMatrix
      • GroupRelation
      • JobRelation
      • Response
      • Solution
      • Detail
      • Route
      • RoutePoint
      • Activity
  1. Routing

Calculate a route

POST
/route
To do a request you send JSON data.
See the GET endpoint for an alternative query method which is slightly simpler to get started but has some disadvantages.
Please note that in contrast to the GET endpoint, points are specified in the order of [longitude, latitude] and some parameter names use the plural.
For example the string point=10,11&point=20,22 will be converted to the points array (plural):
{ "points": [[11,10], [22,20]] }
So this points array uses a format similar to GeoJson.
Example:

请求参数

Authorization
API Key
在 query 添加参数
key
示例:
key: ********************
or
Body 参数application/json

示例
{
    "profile": "bike",
    "points": [
        [
            11.539421,
            48.118477
        ],
        [
            11.559023,
            48.12228
        ]
    ],
    "point_hints": [
        "Lindenschmitstraße",
        "Thalkirchener Str."
    ],
    "snap_preventions": [
        "motorway",
        "ferry",
        "tunnel"
    ],
    "details": [
        "road_class",
        "surface"
    ]
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location '/route?key=%3Capi-key%3E' \
--header 'Content-Type: application/json' \
--data '{
    "profile": "bike",
    "points": [
        [
            11.539421,
            48.118477
        ],
        [
            11.559023,
            48.12228
        ]
    ],
    "point_hints": [
        "Lindenschmitstraße",
        "Thalkirchener Str."
    ],
    "snap_preventions": [
        "motorway",
        "ferry",
        "tunnel"
    ],
    "details": [
        "road_class",
        "surface"
    ]
}'

返回响应

🟢200成功
application/json
Routing Result
Headers

Bodyapplication/json

示例
{
    "hints": {
        "visited_nodes.sum": 58,
        "visited_nodes.average": 58
    },
    "info": {
        "copyrights": [
            "GraphHopper",
            "OpenStreetMap contributors"
        ],
        "took": 2
    },
    "paths": [
        {
            "distance": 1791.011,
            "weight": 307.852443,
            "time": 370962,
            "transfers": 0,
            "points_encoded": false,
            "bbox": [
                11.539424,
                48.118343,
                11.558901,
                48.122364
            ],
            "points": {
                "type": "LineString",
                "coordinates": [
                    [
                        11.539424,
                        48.118352
                    ],
                    [
                        11.540387,
                        48.118368
                    ],
                    [
                        11.54061,
                        48.118356
                    ],
                    [
                        11.541941,
                        48.118409
                    ],
                    [
                        11.543696,
                        48.118344
                    ],
                    [
                        11.547167,
                        48.118343
                    ],
                    [
                        11.548478,
                        48.118366
                    ],
                    [
                        11.548487,
                        48.119329
                    ],
                    [
                        11.548807,
                        48.119328
                    ],
                    [
                        11.549408,
                        48.119366
                    ],
                    [
                        11.550349,
                        48.119508
                    ],
                    [
                        11.550441,
                        48.119473
                    ],
                    [
                        11.551109,
                        48.119467
                    ],
                    [
                        11.551553,
                        48.119445
                    ],
                    [
                        11.551748,
                        48.119398
                    ],
                    [
                        11.552087,
                        48.119475
                    ],
                    [
                        11.552236,
                        48.119542
                    ],
                    [
                        11.552353,
                        48.119635
                    ],
                    [
                        11.553853,
                        48.121136
                    ],
                    [
                        11.555448,
                        48.12039
                    ],
                    [
                        11.555797,
                        48.120206
                    ],
                    [
                        11.55632,
                        48.120592
                    ],
                    [
                        11.556716,
                        48.120919
                    ],
                    [
                        11.557326,
                        48.121345
                    ],
                    [
                        11.558901,
                        48.122364
                    ]
                ]
            },
            "instructions": [
                {
                    "distance": 672.954,
                    "heading": 89.04,
                    "sign": 0,
                    "interval": [
                        0,
                        6
                    ],
                    "text": "Continue onto Lindenschmitstraße",
                    "time": 144703,
                    "street_name": "Lindenschmitstraße"
                },
                {
                    "distance": 107.145,
                    "sign": -2,
                    "interval": [
                        6,
                        7
                    ],
                    "text": "Turn left",
                    "time": 22675,
                    "street_name": ""
                },
                {
                    "distance": 140.169,
                    "sign": 2,
                    "interval": [
                        7,
                        10
                    ],
                    "text": "Turn right onto Oberländerstraße",
                    "time": 28032,
                    "street_name": "Oberländerstraße"
                },
                {
                    "distance": 360.232,
                    "sign": 1,
                    "interval": [
                        10,
                        18
                    ],
                    "text": "Turn slight right",
                    "time": 72677,
                    "street_name": ""
                },
                {
                    "distance": 177.621,
                    "sign": 2,
                    "interval": [
                        18,
                        20
                    ],
                    "text": "Turn right onto Thalkirchner Straße",
                    "time": 35524,
                    "street_name": "Thalkirchner Straße"
                },
                {
                    "distance": 332.89,
                    "sign": -2,
                    "interval": [
                        20,
                        24
                    ],
                    "text": "Turn left onto Thalkirchner Straße",
                    "time": 67351,
                    "street_name": "Thalkirchner Straße"
                },
                {
                    "distance": 0,
                    "sign": 4,
                    "last_heading": 45.67046584987792,
                    "interval": [
                        24,
                        24
                    ],
                    "text": "Arrive at destination",
                    "time": 0,
                    "street_name": ""
                }
            ],
            "legs": [],
            "details": {},
            "ascend": 6.3294677734375,
            "descend": 25.0579833984375,
            "snapped_waypoints": {
                "type": "LineString",
                "coordinates": [
                    [
                        11.539424,
                        48.118352
                    ],
                    [
                        11.558901,
                        48.122364
                    ]
                ]
            }
        }
    ]
}
🟠400请求有误
🟠401没有权限
🟠429
🔴500服务器错误
修改于 2025-11-25 06:18:54
上一页
Calculate a route
下一页
Compute an isochrone
Built with