产品服务
解决方案
文档与支持
定价
登录
公交路线规划
下载开发文档
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配合使用int64SN存在时必填SN存在时必填
callback回调函数,用于解决浏览器请求跨域问题string选填仅再output=json时,该参数有效
返回参数
字段名称字段类型备注
statusint0:成功
1:服务器内部错误
2:参数无效
1001:没有公交方案
1002:不支持跨域
messagestring
resultdict如果status为1001 或1002,此字段为null
origin
city_idstring
city_namestring
location
lngdouble坐标系由ret_coordtype设置
latdouble坐标系由ret_coordtype设置
destination
city_idstring
city_namestring
location
lngdouble坐标系由ret_coordtype设置
latdouble坐标系由ret_coordtype设置
taxi
detailarray
descstring仅在同城请求时才返回
km_pricedouble仅在同城请求时才返回
start_pricedouble仅在同城请求时才返回
total_pricedouble仅在同城请求时才返回
distanceint仅在同城请求时才返回
durationint仅在同城请求时才返回
remarkstring仅在同城请求时才返回
totalint符合条件的所有routes 的总数
routesarray请求中指定的page_index 和page_size 的部分。数组元素个数为page_size,每个元素代表从起点到终点的一条路线。
distanceint
durationint
arrive_timestring格式为2016-04-05 17:06:10
pricedouble境外地区此字段值为null
price_detailarray起终点为境内同城时此字段为一个数组,数组中的每一项都有ticket_type 和ticket_price 两个字段;
起终点为境内跨城时,该字段为一个空的数组。
ticket_typeint(0-1)0 公交票价;1 地铁票价
ticket_pricedouble本类型的票的总价
stepsarray数组,数组中的每一项是一步(step)。每条路线都由多个step组成。
起终点为同城时,比如从奎科大厦到西直门分3个step,第一步是奎科大厦步行到上地五街,第二步是上地五街到上地地铁站,第三步是上地地铁站到西直门;
起终点为跨城时,比如从奎科大厦到天津大学分3个step,第一步是奎科大厦到北京南站,第二步是北京南站到天津站,第三步是天津站到天津大学。
schemesarray当起终点为同城时,一个step 中可能会有多个scheme(方案),上述同城的第二步上地五街到上地地铁站可以坐205或447,每一种是一个scheme;
当起终点为跨城时,一个step 中可能会有多个sub_step(子步骤),上述跨城的第一步从奎科大厦到北京南站分为多个sub_step(子步骤),这里的每个子步骤类似同城时的一个scheme(方案)。
distanceint
durationint
instructionsstring
pathstring坐标系由ret_coordtype设置,示例:“116.321858,40.039183;116.3216343,40.039141”
traffic_conditionarray目前无输出
start_location
lngdouble坐标系由ret_coordtype设置
latdouble坐标系由ret_coordtype设置
end_location
lngdouble坐标系由ret_coordtype设置
latdouble坐标系由ret_coordtype设置
vehicle_info
typeint1:火车
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 的 uidstring
start_name起点公交站名称string
end_info
end_time末班车时间string
end_ uid终点POI 的 uidstring
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
如您需要获取未来驾车路线规划,驾车路线历史耗时,建议出发时间,途经点智能路线规划,请点击未来驾车路线规划驾车路线历史耗时建议出发时间途经点智能路线规划

上一篇

步行路线规划

下一篇

摩托车路线规划

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