AI
产品服务
解决方案
文档与支持
定价
更新时间: 2026/03/19 11:26
公交路线规划
API服务地址

https://api.map.baidu.com/direction/v2/transit?origin=40.056878,116.30815&destination=31.222965,121.505821&ak=您的AK
//GET请求

请求参数
字段名称含义字段类型必填备注

origin

起点

"double,double",格式为:纬度,经度,小数点后不超过6位,如:“40.056878,116.30815”

必填

destination

终点

"double,double",格式为:纬度,经度,小数点后不超过6位,如:“40.056878,116.30815”

必填

origin_uid

POI 的 uid(在已知起点POI 的 uid 情况下,请尽量填写uid,将提升路线规划的准确性,

使用地点检索服务获取uid

使用地点输入提示服务获取uid)

string

选填

destination_uid

POI 的 uid(在已知终点POI 的 uid 情况下,请尽量填写uid,将提升路线规划的准确性,

使用地点检索服务获取uid

使用地点输入提示服务获取uid)

string

选填

coord_type

起终点的坐标类型

string

选填

坐标类型,可选参数,默认为bd09ll。允许的 值为

bd09ll(百度经纬度坐标)、

bd09mc (百度墨卡托坐标)、

gcj02(国测局加密坐 标)、

wgs84(gps设备获取的坐标)

departure_date

出发日期

string

选填

可指定出发日期,若不填默认规则如下:

1. 若为起终点为同城:则默认为当天

2. 若为起终点为跨城:则默认第二天

departure_time

出发时间区间

string

选填

出发时间区间,格式为:

1. hh:mm-hh:mm,如”08:00-14:00”:表示只查询发车时间在8点至14点之间的方案

2. hh:mm,如”08:00” :表示只查询发车时间在8点至24点的方案

tactics_incity

市内公交换乘策略

int(0-5)

选填

默认为0

可选值:

0 推荐

1 少换乘

2 少步行

3 不坐地铁

4 时间短

5 地铁优先

tactics_intercity

跨城公交换乘策略

int(0-2)

选填

默认为0

可选值:

0 时间短

1 出发早

2 价格低

trans_type_intercity

跨城交通方式策略

int(0-2)

选填

默认为0

可选值:

0 火车优先

1 飞机优先

2 大巴优先

ret_coordtype

返回值的坐标类型

string

选填

默认为百度经纬度坐标:bd09ll

可选值:

bd09ll:百度经纬度坐标

gcj02:国测局坐标

output

输出类型

string

选填

默认为json

可选值:

json

xml

page_size

返回每页几条路线

int(1-10)

选填

默认为10

page_index

返回第几页

int

选填

默认为1

ak

开发者密钥AK申请

string

必填

sn

用户的权限签名,当AK设置为SN校验时,该参数必填SN计算方法

string

选填

timestamp

时间戳,与SN配合使用

int64

SN存在时必填

SN存在时必填

callback

回调函数,用于解决浏览器请求跨域问题

string

选填

仅再output=json时,该参数有效

返回参数
字段名称字段类型备注

status

int

0:成功

1:服务器内部错误

2:参数无效

1001:没有公交方案

1002:不支持跨域

message

string

result

dict

如果status为1001 或1002,此字段为null

origin

city_id

string

city_name

string

location

lng

double

坐标系由ret_coordtype设置

lat

double

坐标系由ret_coordtype设置

destination

city_id

string

city_name

string

location

lng

double

坐标系由ret_coordtype设置

lat

double

坐标系由ret_coordtype设置

taxi

detail

array

desc

string

仅在同城请求时才返回

km_price

double

仅在同城请求时才返回

start_price

double

仅在同城请求时才返回

total_price

double

仅在同城请求时才返回

distance

int

仅在同城请求时才返回

duration

int

仅在同城请求时才返回

remark

string

仅在同城请求时才返回

total

int

符合条件的所有routes 的总数

routes

array

请求中指定的page_index 和page_size 的部分。数组元素个数为page_size,每个元素代表从起点到终点的一条路线。

distance

int

duration

int

arrive_time

string

格式为2016-04-05 17:06:10

price

double

境外地区此字段值为null

price_detail

array

起终点为境内同城时此字段为一个数组,数组中的每一项都有ticket_type 和ticket_price 两个字段;

起终点为境内跨城时,该字段为一个空的数组。

ticket_type

int(0-1)

0 公交票价;1 地铁票价

ticket_price

double

本类型的票的总价

steps

array

数组,数组中的每一项是一步(step)。每条路线都由多个step组成。

起终点为同城时,比如从奎科大厦到西直门分3个step,第一步是奎科大厦步行到上地五街,第二步是上地五街到上地地铁站,第三步是上地地铁站到西直门;

起终点为跨城时,比如从奎科大厦到天津大学分3个step,第一步是奎科大厦到北京南站,第二步是北京南站到天津站,第三步是天津站到天津大学。

schemes

array

当起终点为同城时,一个step 中可能会有多个scheme(方案),上述同城的第二步上地五街到上地地铁站可以坐205或447,每一种是一个scheme;

当起终点为跨城时,一个step 中可能会有多个sub_step(子步骤),上述跨城的第一步从奎科大厦到北京南站分为多个sub_step(子步骤),这里的每个子步骤类似同城时的一个scheme(方案)。

distance

int

duration

int

instructions

string

path

string

坐标系由ret_coordtype设置,示例:“116.321858,40.039183;116.3216343,40.039141”

traffic_condition

array

目前无输出

start_location

lng

double

坐标系由ret_coordtype设置

lat

double

坐标系由ret_coordtype设置

end_location

lng

double

坐标系由ret_coordtype设置

lat

double

坐标系由ret_coordtype设置

vehicle_info

type

int

1:火车

2:飞机

3:公交

4:驾车

5:步行

6:大巴

detail

火车、飞机、大巴、公交4 种交通方式的这个字段有各自的格式,参见下面的文档,步行和驾车为null。

火车:vehicle_info 中type=1(火车)时detail 字段格式
字段名称含义字段类型备注

name

火车车次名称

string

price

总票价

double

booking

订票电话

string

departure_station

上车火车站名称

string

arrive_station

下车火车站名称

string

departure_time

发车时间

string

所乘的火车在上车火车站的发车时间

arrive_time

到站时间

string

所乘的火车在下车火车站的到站时

start_info

start_name

起点站名

string

start_city

起点所在城市名称

string

start_time

出发时间

string

end_info

end_name

终点站名

string

end_city

终点所在城市名称

string

end_time

抵达时间

string

飞机:vehicle_info 中type=2(飞机)时detail 字段格式
字段名称含义字段类型备注

name

航班名称

string

price

总票价

double

discount

折扣

double

airlines

航空公司

string

booking

订票网址

string

departure_station

登机机场名称

string

arrive_station

下飞机机场名称

string

departure_time

飞机起飞时间

string

arrive_time

飞机降落时间

string

start_info

start_name

起点站名

string

start_city

起点所在城市名称

string

start_time

出发时间

string

end_info

end_name

终点站名

string

end_city

终点所在城市名称

string

end_time

抵达时间

string

公交:vehicle_info 中type=3(公交)时detail 字段格式
字段名称含义字段类型备注

name

公交线路名称

string

line_color

线路颜色

string

type

市内公交的具体类型

int

只有同城公交才会有此字段

0:普通日行公交车

1:地铁、轻轨

2:机场巴士(前往机场)

3:有轨电车

4:机场巴士(从机场返回)

5:旅游线路车

6:夜班车

7:机场巴士(机场之间)

8:轮渡

9:其他

10:快车

11:慢车

12:机场快轨(前往机场)

13:机场快轨(从机场返回)

14:机场轨道交通环路

stop_num

途经站点数

int

on_station

上车站点名称

string

off_station

下车站点名称

string

first_time

始发车发车时间

string

指的是从上车站点到下车站点这个方向上的始发车发车时间

last_time

末班车发车时间

string

指的是从上车站点到下车站点这个方向上的末班车发车时间

start_info

start_time

首班车时间

string

start_ uid

起点poi 的 uid

string

start_name

起点公交站名称

string

end_info

end_time

末班车时间

string

end_ uid

终点POI 的 uid

string

end_name

终点公交站名称

string

大巴:大巴:vehicle_info 中type=6(大巴)时detail 字段格式
字段名称含义字段类型备注

name

大巴班次名称

string

price

总票价

double

booking

订票网址

string

provider_name

合作方名称

string

provider_url

合作方官网地址

string

departure_station

上车汽车站名称

string

arrive_station

下车汽车站名称

string

departure_time

发车时间

string

arrive_time

到站时间

string

start_info

start_name

起点站名

string

start_city

起点所在城市名称

string

start_time

出发时间

string

end_info

end_name

终点站名

string

end_city

终点所在城市名称

string

end_time

抵达时间

string

如您需要获取未来驾车路线规划,驾车路线历史耗时,建议出发时间,途经点智能路线规划,请点击未来驾车路线规划驾车路线历史耗时建议出发时间途经点智能路线规划

上一篇

步行路线规划

下一篇

摩托车路线规划

本篇文章对您是否有帮助?