API 文档 / 路径规划 / 驾车路径规划
驾车路径规划
接口说明
驾车路径规划
输入示例:起点:116.481028,39.989643;终点:116.434446,39.90816
返回示例:返回驾车路线方案,包括距离、预计耗时、分段道路和导航步骤。
请求地址
GEThttps://cloud.dtbgis.com/api/v1/route/driving
鉴权方式
在 HTTP Header 中携带你的 API Key:
X-API-Key: 你的API-Key
每个 Key 绑定已购接口与额度,调用成功扣减 1 次;调用失败(参数错误等)不扣额度。未开通该接口返回 403,额度耗尽返回 429。
请求参数
| 参数 | 必填 | 说明 | 示例 / 默认值 |
|---|---|---|---|
origin |
必填 | 起点坐标,格式 lon,lat | 116.481028,39.989643 |
destination |
必填 | 终点坐标,格式 lon,lat | 116.434446,39.90816 |
extensions |
可选 |
返回结果详略
可选值:
base base、all all |
base |
strategy |
可选 | 驾车算路策略 | 32 |
waypoints |
可选 | 途经点,格式 lon,lat;lon,lat | — |
avoidroad |
可选 | 避让道路名 | — |
请求示例
curl -H "X-API-Key: 你的API-Key" \ "https://cloud.dtbgis.com/api/v1/route/driving?origin=116.481028%2C39.989643&destination=116.434446%2C39.90816&extensions=base&strategy=32"
import requests
resp = requests.get(
"https://cloud.dtbgis.com/api/v1/route/driving?origin=116.481028%2C39.989643&destination=116.434446%2C39.90816&extensions=base&strategy=32",
headers={"X-API-Key": "你的API-Key"},
)
print(resp.status_code, resp.json())
fetch("https://cloud.dtbgis.com/api/v1/route/driving?origin=116.481028%2C39.989643&destination=116.434446%2C39.90816&extensions=base&strategy=32", {
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 为 高德地图 Web 服务 的原始响应,字段以 官方文档 为准 |
quota_remaining | 本接口剩余可用调用次数 |
上游异常时 HTTP 仍为
200,需检查 data.status 判断上游是否成功(此类情况通常由系统自动切换 Key 处理)。错误码
错误以统一结构返回:{"detail": {"code": 429, "msg": "..."}}
| HTTP | 含义 | 常见原因 / 处理 |
|---|---|---|
400 | 参数错误 | 缺少必填参数或格式不合法 |
401 | 鉴权失败 | API Key 缺失、不存在、已停用或已过期 |
403 | 权限不足 | 该 Key 未开通此接口,请购买对应额度 |
429 | 额度耗尽 / 限流 | 额度用完需续费;或超过速率(60 秒 200 次) |
404 | 资源不存在 | 路径错误,或查询对象无数据 |
503 | 上游不可用 | 服务商暂时异常,稍后重试 |
完整错误码见 文档首页 · 错误码总览。