github: https://github.com/gyfstephen/shanghai-bus
上海发布里查询准确度不错,但是查询体验不是很好,会经常卡住,所以就简单抓了下上海发布查公交的接口自己集成了实现一个 API,现在应该只支持查询车辆名为纯数字的线路
数据来源:上海发布
API 接口:
查询车辆站台信息
/api/v1/stations/<string:stop_type>/<int:number>/
查询车辆到站信息
/api/v1/stops/<string:stop_type>/<int:number>/
示例:
{
"data": {
"1": "吉浦路仁德路",
"2": "武川路武东路",
"3": "武川路政立路",
"4": "政立路国权北路",
"5": "政立路逸仙路",
"6": "逸仙路场中路",
"7": "江湾(逸仙路)",
"8": "逸仙路纪念路",
"9": "大柏树(曲阳路)",
"10": "曲阳路中山北二路",
"11": "大连西路曲阳路",
"12": "欧阳路大连西路",
"13": "欧阳路祥德路",
"14": "欧阳路四达路",
"15": "欧阳路吉祥路",
"16": "四平路溧阳路",
"17": "吴淞路海宁路",
"18": "吴淞路天潼路"
},
"error": 0,
"msg": ""
}
{
"data": [
{
"distance": 0,
"error": 0,
"plate": "沪 A-00737D",
"station_name": "吉浦路仁德路",
"stop_dis": 1,
"stop_id": 1,
"time": 929
},
{
"distance": 1296,
"error": 0,
"plate": "沪 A-00737D",
"station_name": "武川路武东路",
"stop_dis": 1,
"stop_id": 2,
"time": 1048
},
{
"distance": 1548,
"error": 0,
"plate": "沪 A-00737D",
"station_name": "武川路政立路",
"stop_dis": 2,
"stop_id": 3,
"time": 1110
},
{
"distance": 2203,
"error": 0,
"plate": "沪 A-00737D",
"station_name": "政立路国权北路",
"stop_dis": 3,
"stop_id": 4,
"time": 1289
},
{
"distance": 576,
"error": 0,
"plate": "沪 A-01825D",
"station_name": "政立路逸仙路",
"stop_dis": 1,
"stop_id": 5,
"time": 88
},
{
"distance": 1175,
"error": 0,
"plate": "沪 A-01825D",
"station_name": "逸仙路场中路",
"stop_dis": 2,
"stop_id": 6,
"time": 208
},
{
"distance": 1590,
"error": 0,
"plate": "沪 A-01825D",
"station_name": "江湾(逸仙路)",
"stop_dis": 3,
"stop_id": 7,
"time": 269
},
{
"distance": 1882,
"error": 0,
"plate": "沪 A-01825D",
"station_name": "逸仙路纪念路",
"stop_dis": 4,
"stop_id": 8,
"time": 388
},
{
"distance": 3142,
"error": 0,
"plate": "沪 A-01825D",
"station_name": "大柏树(曲阳路)",
"stop_dis": 5,
"stop_id": 9,
"time": 628
},
{
"distance": 293,
"error": 0,
"plate": "沪 A-07566D",
"station_name": "曲阳路中山北二路",
"stop_dis": 1,
"stop_id": 10,
"time": 31
},
{
"distance": 1642,
"error": 0,
"plate": "沪 A-07566D",
"station_name": "大连西路曲阳路",
"stop_dis": 2,
"stop_id": 11,
"time": 331
},
{
"distance": 2170,
"error": 0,
"plate": "沪 A-07566D",
"station_name": "欧阳路大连西路",
"stop_dis": 3,
"stop_id": 12,
"time": 449
},
{
"distance": 2579,
"error": 0,
"plate": "沪 A-07566D",
"station_name": "欧阳路祥德路",
"stop_dis": 4,
"stop_id": 13,
"time": 569
},
{
"distance": 2867,
"error": 0,
"plate": "沪 A-07566D",
"station_name": "欧阳路四达路",
"stop_dis": 5,
"stop_id": 14,
"time": 630
},
{
"distance": 3196,
"error": 0,
"plate": "沪 A-07566D",
"station_name": "欧阳路吉祥路",
"stop_dis": 6,
"stop_id": 15,
"time": 689
},
{
"distance": 4019,
"error": 0,
"plate": "沪 A-07566D",
"station_name": "四平路溧阳路",
"stop_dis": 7,
"stop_id": 16,
"time": 870
},
{
"distance": 728,
"error": 0,
"plate": "沪 A-05870D",
"station_name": "吴淞路海宁路",
"stop_dis": 1,
"stop_id": 17,
"time": 90
},
{
"distance": 1329,
"error": 0,
"plate": "沪 A-05870D",
"station_name": "吴淞路天潼路",
"stop_dis": 2,
"stop_id": 18,
"time": 330
}
],
"error": 0,
"msg": ""
}
TODO:
1
zli 2019-01-31 13:00:01 +08:00
为什么不用巴士通的 API,
那个接口不是更直接更全面? |
2
exceloo 2019-01-31 13:16:13 +08:00
这个擅自搭建 api 获取公共信息有没有什么风险?就像自己画地图被抓起来那样...
|
3
Senventise 2019-01-31 13:47:38 +08:00 via Android
之前也写过一个,话说 sid 我记得好像就是线路名的 md5 啊,为什么查不了非数字线路?
btw,上海公交官方 app 也不错,用的是同一套 api |