API 文档 / 路径规划 / 骑行路径规划
骑行路径规划
接口说明
骑行路径规划
输入示例:起点:116.481028,39.989643;终点:116.434446,39.90816
返回示例:返回骑行路线方案,包括骑行距离、预计耗时和路线分段。
请求地址
GEThttps://cloud.dtbgis.com/api/v1/route/bicycling
鉴权方式
在 HTTP Header 中携带你的 API Key:
X-API-Key: 你的API-Key
每个 API Key 绑定已购接口与流量豆,调用成功扣减对应流量豆;调用失败(参数错误等)不扣流量豆。未开通该接口返回 403,流量豆不足返回 429。
请求参数
| 参数 | 必填 | 说明 | 示例 / 默认值 |
|---|---|---|---|
origin |
必填 | 起点坐标,格式 lon,lat | 116.481028,39.989643 |
destination |
必填 | 终点坐标,格式 lon,lat | 116.434446,39.90816 |
请求示例
curl -H "X-API-Key: 你的API-Key" \ "https://cloud.dtbgis.com/api/v1/route/bicycling?origin=116.481028%2C39.989643&destination=116.434446%2C39.90816"
import requests
resp = requests.get(
"https://cloud.dtbgis.com/api/v1/route/bicycling?origin=116.481028%2C39.989643&destination=116.434446%2C39.90816",
headers={"X-API-Key": "你的API-Key"},
)
print(resp.status_code, resp.json())
fetch("https://cloud.dtbgis.com/api/v1/route/bicycling?origin=116.481028%2C39.989643&destination=116.434446%2C39.90816", {
headers: { "X-API-Key": "你的API-Key" }
})
.then(r => r.json())
.then(console.log);
返回结果说明
本接口返回统一 JSON 信封结构:
{
"code": 200,
"msg": "success",
"data": { ... },
"quota_remaining": 9999
}| 字段 | 说明 |
|---|---|
code | 业务状态码,200 表示成功 |
msg | 状态描述,成功为 success |
data | 查询结果对象,字段见下方「data 字段说明」 |
quota_remaining | 本次调用后剩余可用流量豆数量 |
骑行走高德 v4 接口,data 为原始 JSON 透传:外层为 errcode / errmsg,规划结果在再下一层 data 对象内(与 v3 的 status / route 结构不同)。坐标系 GCJ-02;示例中 polyline 坐标串做了截断示意。
响应示例
{
"code": 200,
"msg": "success",
"data": {
"errcode": 0,
"errmsg": "OK",
"data": {
"origin": "116.481028,39.989643",
"destination": "116.434446,39.90816",
"paths": [
{
"distance": 11000,
"duration": 2640,
"steps": [
{
"instruction": "沿阜通东大街向西骑行500米",
"road": "阜通东大街",
"distance": 500,
"duration": 120,
"polyline": "116.481028,39.989643;116.478028,39.989643",
"action": "右转",
"assistant_action": ""
}
]
}
]
}
},
"quota_remaining": 9988
}
data 字段说明
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
errcode | int | 上游状态码,0 表示成功 | 0 |
errmsg | string | 上游状态说明 | OK |
data | object | 路径规划结果对象 | — |
origin | string | 起点坐标(lng,lat) | 116.481028,39.989643 |
destination | string | 终点坐标(lng,lat) | 116.434446,39.908160 |
paths | array | 规划方案列表 | — |
distance | int | 方案总距离(米) | 9347 |
duration | int | 方案预计耗时(秒) | 2400 |
steps | array | 方案分段指引列表 | — |
instruction | string | 分段骑行指引文本 | 沿阜通东大街骑行300米右转 |
road | string | 道路名称 | 阜通东大街 |
distance | int | 该段距离(米) | 300 |
duration | int | 该段预计耗时(秒) | 75 |
polyline | string | 该段坐标串(lng,lat;lng,lat) | 116.480,39.989;116.479,39.988 |
action | string | 导航主动作 | 右转 |
assistant_action | string | 导航辅助动作 | — |
错误码
错误以统一结构返回:{"detail": {"code": 429, "msg": "..."}}
| HTTP | 含义 | 常见原因 / 处理 |
|---|---|---|
400 | 参数错误 | 缺少必填参数或格式不合法 |
401 | 鉴权失败 | API Key 缺失、不存在、已停用或已过期 |
403 | 权限不足 | 该 API Key 未开通此接口,请购买流量豆 |
429 | 流量豆不足 / 限流 | 流量豆用完需续费;或超过速率(60 秒 200 次) |
404 | 资源不存在 | 路径错误,或查询对象无数据 |
503 | 服务暂时不可用 | 服务暂时异常,请稍后重试 |
完整错误码见 文档首页 · 错误码总览。