1. Clustering
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. Clustering

Submit a clustering job

POST
/cluster/calculate
Prefer the synchronous endpoint and use this Batch Cluster endpoint for
long running problems only. The work flow is asynchronous:
send a POST request towards https://graphhopper.com/api/1/cluster/calculate?key=<your_key> and fetch the job_id.
poll the solution every 500ms until it gives status=finished. Do this with a GET request
towards https://graphhopper.com/api/1/cluster/solution/<job_id>?key=<your_key>.

请求参数

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

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location '/cluster/calculate?key=%3Capi-key%3E' \
--header 'Content-Type: application/json' \
--data '{
    "configuration": {
        "response_type": "json",
        "routing": {
            "profile": "car",
            "cost_per_second": 1,
            "cost_per_meter": 0
        },
        "clustering": {
            "num_clusters": 10,
            "max_quantity": 50,
            "min_quantity": 30
        }
    },
    "clusters": [
        {
            "name": "GraphHopper GmbH",
            "center": {
                "lon": 11.53941,
                "lat": 48.118434,
                "street_hint": "Lindenschmitstraße 52"
            },
            "min_quantity": 10,
            "max_quantity": 10
        }
    ],
    "customers": [
        {
            "id": "GraphHopper GmbH",
            "address": {
                "lon": 11.53941,
                "lat": 48.118434,
                "street_hint": "Lindenschmitstraße 52"
            },
            "quantity": 10
        }
    ]
}'

返回响应

🟢200成功
application/json
A jobId you can use to retrieve your solution from the server - see solution endpoint.
Headers

Bodyapplication/json

示例
{
    "job_id": "44886560-b584-4da5-b245-768151dacd8f"
}
🟠400请求有误
🔴500服务器错误
修改于 2025-11-25 06:18:54
上一页
Solve a clustering problem
下一页
Retrieve solution of a clustering job
Built with