上海公交API
1. 公交線路查詢接口
接口地址:
/bus/<router_name>
請求方式:GET
請求參數(shù):
名稱 | 位置 | 類型 | 必須 | 說明 |
---|---|---|---|---|
router_name | url | string | 是 | 公交線路名稱蜡镶,如:1路勺爱、2路 |
direction | query string | int | 否 | 公交行駛方向,上行:0(默認(rèn))端壳,下行:1 |
返回參數(shù):
名稱 | 類型 | 說明 |
---|---|---|
from | string | 公交起點(diǎn)站名稱 |
to | string | 公交終點(diǎn)站名稱 |
direction | int | 公交行駛方向痊剖,上行:0韩玩,下行:1 |
stops | array | 公交站點(diǎn)列表 |
stop_id | string | 公交站點(diǎn)的數(shù)字代號 |
stop_name | string | 公交站點(diǎn)名稱 |
2.公交到站信息查詢接口
接口地址:
/bus/<router_name>/stop/<stop_id>
請求方式:GET
請求參數(shù):
名稱 | 位置 | 類型 | 必須 | 說明 |
---|---|---|---|---|
router_name | url | string | 是 | 公交線路名稱,如:1路陆馁、2路 |
stop_id | url | int | 是 | 公交站點(diǎn)的數(shù)字代號 |
direction | query string | int | 否 | 公交行駛方向找颓,上行:0(默認(rèn)),下行:1 |
返回參數(shù):
名稱 | 類型 | 說明 |
---|---|---|
router_name | string | 公交線路名稱 |
direction | int | 公交行駛方向叮贩,上行:0击狮,下行:1 |
plate_number | string | 公交車車牌號 |
stop_interval | int | 公交車到達(dá)本站的站數(shù) |
distance | int | 當(dāng)前公交車到達(dá)本站的距離 |
time | int | 當(dāng)前公交車到達(dá)本站的時間(秒) |
status | string | 公交車狀態(tài),waiting:等待發(fā)車益老;running:運(yùn)行中 |
3.公交線路詳情查詢接口
接口地址:
/bus/<router_name>/details
請求方式:GET
請求參數(shù):
名稱 | 位置 | 類型 | 必須 | 說明 |
---|---|---|---|---|
router_name | url | string | 是 | 公交線路名稱彪蓬,如:1路、2路 |
direction | query string | int | 否 | 公交行駛方向捺萌,上行:0(默認(rèn))档冬,下行:1 |
返回參數(shù):
名稱 | 類型 | 說明 |
---|---|---|
from | string | 公交起點(diǎn)站名稱 |
to | string | 公交終點(diǎn)站名稱 |
direction | int | 公交行駛方向,上行:0桃纯,下行:1 |
stops | array | 公交站點(diǎn)列表 |
stop_id | string | 公交站點(diǎn)的數(shù)字代號 |
stop_name | string | 公交站點(diǎn)名稱 |
plate_number | string | 公交車車牌號 |
stop_interval | int | 公交車到達(dá)本站的站數(shù) |
distance | int | 當(dāng)前公交車到達(dá)本站的距離 |
time | int | 當(dāng)前公交車到達(dá)本站的時間(秒) |
status | string | 公交車狀態(tài)酷誓,waiting:等待發(fā)車;running:運(yùn)行中 |
錯誤響應(yīng)
返回參數(shù):
名稱 | 類型 | 說明 |
---|---|---|
error | string | 錯誤代碼 |
error_msg | string | 錯誤說明 |
400 Bad Request
{
"error": "router_not_exists",
"error_msg": "不存在該公交線路"
}
404 Not Found
{
"error": "page_not_found",
"error_msg": "頁面不存在"
}
500 Internal Server Error
{
"error": "internal_server_error",
"error_msg": "服務(wù)器內(nèi)部錯誤"
}