Skip to content

路径规划API

路径规划API提供了多种出行方式的路线规划服务,包括驾车、步行、骑行和公交换乘路线规划。通过这些API,您可以为用户提供最佳出行路线建议。

驾车路径规划 API

接口描述

提供综合路径规划服务,用于为接驾或送驾场景提供最佳路线。

请求方式

URL请求方式
https://lbs.xiaojukeji.com/api/v2/routeplanv3POST、GET

请求

查询参数(GET)

参数名必选类型描述示例值
keystring鉴权用的 API KeyYOUR_API_KEY

请求体参数(POST)

请求体应为 PackReq 模型的JSON格式。

请求示例

GET

shell
curl -X GET "https://lbs.xiaojukeji.com/api/v2/routeplanv3?key=YOUR_API_KEY&packs=%5B%7B%22origin%22%3A%22116.2807%2C40.04811%22%2C%22destination%22%3A%22116.29334%2C40.05203%22%2C%22departure_time%22%3A1741662325%2C%22routeplan_type%22%3A%221%22%2C%22need_polyline%22%3Afalse%2C%22eta_strategy%22%3A0%7D%2C%7B%22origin%22%3A%20%22116.2807%2C40.04811%22%2C%22destination%22%3A%20%22116.29334%2C40.05203%22%2C%22departure_time%22%3A%201741662325%2C%22routeplan_type%22%3A%20%221%22%2C%22need_polyline%22%3A%20true%7D%5D"

POST

shell
curl -X POST "https://lbs.xiaojukeji.com/api/v2/routeplanv3?key=YOUR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "packs": [
    {
      "origin": "116.2807,40.04811",
      "destination": "116.29334,40.05203",
      "departure_time": 1741662325,
      "routeplan_type": "1",
      "need_polyline": false,
      "eta_strategy": 0
    },
    {
      "origin": "116.2807,40.04811",
      "destination": "116.29334,40.05203",
      "departure_time": 1741662325,
      "routeplan_type": "1",
      "need_polyline": true
    }
  ]
}'

响应

成功响应为 RoutePlanResponse 模型的JSON格式。

响应示例

json
{
  "status": 10000,
  "msg": "OK",
  "trace_id": "0ac0611968c3d623e089047210a1abb0",
  "results": [
    {
      "errcode": 0,
      "errmsg": "ok",
      "routes": [
        {
          "dist": 12972,
          "duration": 1686,
          "tag": "平台推荐",
          "geo_list": [
            {
              "latitude": 39.960721,
              "longitude": 116.298906
            },
            {
              "latitude": 39.9607,
              "longitude": 116.29867
            },
            {
              "latitude": 39.96068,
              "longitude": 116.2986
            },
            {
              "latitude": 39.96068,
              "longitude": 116.2986
            }
          ]
        }
      ]
    },
    {
      "errcode": 0,
      "errmsg": "ok",
      "routes": [
        {
          "dist": 3308,
          "duration": 734,
          "tag": "时间快",
          "geo_list": [
            {
              "latitude": 40.047897,
              "longitude": 116.280717
            },
            {
              "latitude": 40.04811,
              "longitude": 116.28066
            }
          ]
        },
        {
          "dist": 3889,
          "duration": 828,
          "tag": "红绿灯少",
          "geo_list": [
            {
              "latitude": 40.047897,
              "longitude": 116.280717
            },
            {
              "latitude": 40.04811,
              "longitude": 116.28066
            }
          ]
        },
        {
          "dist": 4348,
          "duration": 951,
          "tag": "路线三",
          "geo_list": [
            {
              "latitude": 40.047897,
              "longitude": 116.280717
            },
            {
              "latitude": 40.04811,
              "longitude": 116.28066
            }
          ]
        }
      ]
    }
  ]
}

步行路线规划 API

接口描述

规划步行路线,提供从起点到终点的步行导航路线、距离和时间。

请求方式

URL请求方式
https://lbs.xiaojukeji.com/api/v2/walkroutePOST、GET

请求

查询参数(GET)

参数名必选类型描述示例值
keystring鉴权用的 API KeyYOUR_API_KEY
originstring出发点坐标,格式:lng,lat116.281801,40.043007
destinationstring目的地坐标,格式:lng,lat116.285056,40.049829

请求体参数(POST)

当使用POST方法时,请求体应为 WalkRouteRequest 模型的JSON格式。

请求示例

GET

shell
curl -X GET "https://lbs.xiaojukeji.com/api/v2/walkroute?key=YOUR_API_KEY&origin=116.281801,40.043007&destination=116.285056,40.049829"

POST

shell
curl -X POST "https://lbs.xiaojukeji.com/api/v2/walkroute?key=YOUR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "origin": "116.281801,40.043007",
  "destination": "116.285056,40.049829"
}'

响应

成功响应为 WalkRouteResponse 模型的JSON格式。

响应示例

json
{
  "status": 10000,
  "msg": "success",
  "trace_id": "0ac5186e67e3f692f0fb048158e0f9b0",
  "results": [
    {
      "dist": 1083,
      "duration": 1083,
      "errcode": 0,
      "errmsg": "ok",
      "geo_list": [
        {
          "latitude": 40.04811,
          "longitude": 116.28069
        },
        {
          "latitude": 40.04798,
          "longitude": 116.28135
        }
      ]
    }
  ]
}

骑行路线规划 API

接口描述

规划骑行路线,提供从起点到终点的自行车导航路线、距离和时间。

请求方式

URL请求方式
https://lbs.xiaojukeji.com/api/v2/bicyclingPOST、GET

请求

查询参数(GET)

参数名必选类型描述示例值
keystring鉴权用的 API KeyYOUR_API_KEY
originstring出发点坐标,格式:lng,lat116.281801,40.043007
destinationstring目的地坐标,格式:lng,lat116.285056,40.049829

请求体参数(POST)

当使用POST方法时,请求体应为 BicyclingRequest 模型的JSON格式。

请求示例

GET

shell
curl -X GET "https://lbs.xiaojukeji.com/api/v2/bicycling?key=YOUR_API_KEY&origin=116.281801,40.043007&destination=116.285056,40.049829"

POST

shell
curl -X POST "https://lbs.xiaojukeji.com/api/v2/bicycling?key=YOUR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "origin": "116.281801,40.043007",
  "destination": "116.285056,40.049829"
}'

响应

成功响应为 BicyclingResponse 模型的JSON格式。

响应示例

json
{
  "status": 10000,
  "msg": "success",
  "trace_id": "0ac5186e67e3f692f0fb048158e0f9b0",
  "results": [
    {
      "dist": 1083,
      "duration": 1083,
      "errcode": 0,
      "errmsg": "ok",
      "geo_list": [
        {
          "latitude": 40.04811,
          "longitude": 116.28069
        },
        {
          "latitude": 40.04798,
          "longitude": 116.28135
        }
      ]
    }
  ]
}

公交路径规划 API

接口描述

规划公交路线,提供从起点到终点的公共交通路线、距离和时间。

请求方式

URL请求方式
https://lbs.xiaojukeji.com/api/v2/transitPOST、GET

请求

查询参数(GET)

参数名必选类型描述示例值
keystring鉴权用的 API KeyYOUR_API_KEY
originstring起点经纬度,格式:lng,lat116.28184,40.04298
destinationstring终点经纬度,格式:lng,lat116.28516,40.04979
citystring城市名称北京市
strategyinteger偏好,0:推荐模式; 1:最快捷模式; 2:最少步行模式; 3:最少换乘模式; 4:不乘地铁模式; 5:地铁优先模式0
departure_timeinteger出发时间,unix秒级时间戳,默认0表示现在出发0
route_numinteger返回方案个数,取值1-10,默认55

请求示例

GET

shell
curl -X GET "https://lbs.xiaojukeji.com/api/v2/transit?key=YOUR_API_KEY&origin=116.28184,40.04298&destination=116.28516,40.04979&city=北京市"

POST

shell
curl -X POST "https://lbs.xiaojukeji.com/api/v2/transit?key=YOUR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "origin": "116.28184,40.04298",
  "destination": "116.28516,40.04979",
  "city": "北京市"
}'

响应

成功响应为 TransitRouteResponse 模型的JSON格式。

响应示例

json
{
  "status": 10000,
  "msg": "OK",
  "trace_id": "0ac5186e6809ecb33aac047eab35b4b0",
  "results": [
    {
      "origin": "116.28187,40.0429",
      "destination": "116.28512,40.04989",
      "cost": 200,
      "duration": 1440,
      "distance": 1862,
      "walking_distance": 423,
      "segments": [
        {
          "mode": "WALKING",
          "walking": {
            "origin": "116.28184,40.04298",
            "destination": "116.28142,40.04291",
            "distance": 36,
            "duration": 60,
            "steps": [
              {
                "instruction": "",
                "road": "",
                "distance": 36,
                "duration": 0,
                "polyline": "116.28184,40.04298;116.28167,40.04295;116.28142,40.04291",
                "action": [""],
                "action_code": [],
                "direction": [""]
              }
            ]
          }
        },
        {
          "mode": "TRANSIT",
          "metrobus": [
            {
              "name": "软件园通勤环线(一二期)",
              "id": "60000015617510001",
              "type": 1,
              "departure_stop": {
                "name": "软件园西一路南口",
                "id": "90002773733280001",
                "location": "116.281443,40.042869"
              },
              "arrival_stop": {
                "name": "软件园西一路北口",
                "id": "90002210406990001",
                "location": "116.280711,40.049098"
              },
              "start_station": "",
              "terminal_station": "地铁西二旗站南",
              "distance": 1439,
              "duration": 603,
              "cost": 200,
              "first_time": "07:30",
              "last_time": "19:30",
              "polyline": "116.281443,40.042871;116.28113,40.04282;116.28046,40.04273",
              "via_stops_count": 2,
              "via_stops": [
                {
                  "name": "百度科技园",
                  "id": "90002182465690001",
                  "location": "116.277405,40.043427"
                }
              ]
            }
          ]
        },
        {
          "mode": "WALKING",
          "walking": {
            "origin": "116.28072,40.04904",
            "destination": "116.28516,40.04979",
            "distance": 387,
            "duration": 300,
            "steps": [
              {
                "instruction": "",
                "road": "",
                "distance": 387,
                "duration": 0,
                "polyline": "116.28072,40.04904;116.28109,40.0491;116.28166,40.0492;116.28205,40.04925",
                "action": [""],
                "action_code": [],
                "direction": [""]
              }
            ]
          }
        }
      ]
    },
    {
      "origin": "116.28187,40.0429",
      "destination": "116.28512,40.04989",
      "cost": 200,
      "duration": 1200,
      "distance": 1268,
      "walking_distance": 592,
      "segments": [
        {
          "mode": "WALKING",
          "walking": {
            "origin": "116.28184,40.04298",
            "destination": "116.28641,40.04441",
            "distance": 502,
            "duration": 420,
            "steps": [
              {
                "instruction": "",
                "road": "",
                "distance": 502,
                "duration": 0,
                "polyline": "116.28184,40.04298;116.28251,40.04308;116.28286,40.04313",
                "action": [""],
                "action_code": [],
                "direction": [""]
              }
            ]
          }
        },
        {
          "mode": "TRANSIT",
          "metrobus": [
            {
              "name": "909路",
              "id": "24712786813990001",
              "type": 1,
              "departure_stop": {
                "name": "软件园西区",
                "id": "50000005180690001",
                "location": "116.286417,40.044414"
              },
              "arrival_stop": {
                "name": "东北旺西路北口",
                "id": "50000005379200001",
                "location": "116.285132,40.050416"
              },
              "start_station": "",
              "terminal_station": "土井村西口",
              "distance": 676,
              "duration": 176,
              "cost": 200,
              "first_time": "05:50",
              "last_time": "22:00",
              "polyline": "116.286428,40.044416;116.28568,40.04794;116.285143,40.050413",
              "via_stops_count": 1,
              "via_stops": []
            }
          ]
        }
      ]
    }
  ]
}