×

Bus route management

This API is used for managing bus routes and assigning vehicles to routes. It allows you to create routes, assign vehicles to trips, and manage route bindings.

How to get data

Method

POST

Request address

To get the data, use the address: https://<server_address>/api/api.php?

Request parameters

Request parameters:
  • cmd — the command to execute
  • data — JSON object with parameters specific to the command
Available commands:
  • setLine — create a new bus route
  • bindControl — bind a vehicle to a route
  • bindLineToVeh — bind a route to a vehicle by route ID
  • unbindControl — remove a vehicle binding
  • listLines — get the list of routes
  • setControl — assign a bus to a trip
  • unsetControl — remove the assignment
 

Creating a bus route (setLine)

Request address
https://<server_address>/api/api.php?cmd=setLine
Request body example
{
  "account_id": "3008",
  "bidirectional": 1,
  "description": "Route #9",
  "label": "123",
  "name": "Route #9",
  "number": "12304",
  "type_id": 0,
  "uid": "dhqwdh",
  "points": [
    {
      "lat": "45.0207",
      "lon": "33.9993",
      "name": "Airport",
      "price": 15.35,
      "radius": "91",
      "silent": 0,
      "stop_type": 0,
      "ts": 600,
      "te": 700,
      "uid": "819897e2-843b-11e4-bf52-002354656fea"
    },
    {
      "lat": "44.9078",
      "lon": "34.0784",
      "name": "7th City Hospital",
      "price": 15.35,
      "radius": "90",
      "silent": 0,
      "stop_type": 0,
      "ts": 900,
      "te": 1000,
      "uid": "819897e8-843b-11e4-bf52-002354656fea"
    }
  ]
}
Route parameters:
  Parameter
  Type
  Description
  account_id
  string
  Account ID
  bidirectional
  number
  1 = round-trip, 0 = one-way
  description
  string
  Route description
  label
  string
  Optional route label
  name
  string
  Route name
  number
  string
  Route number
  type_id
   number
  Vehicle type (0=bus, 1=trolleybus, 2=tram, 3=minibus)
  uid
  string
  Unique route ID
  points
  array
  Stops on the route
Stop parameters:
  Parameter
  Type
  Description
  lat
  string
  Stop latitude
  lon
  string
  Stop longitude
  name
  string
  Stop name
  price
  number
  Fare from previous stop
  radius
  string
  Stop radius in meters
  silent
  number
  1 = no notifications, 0 = notifications allowed
  stop_type
  number
  0 = regular, 1 = technical, 2 = terminal
  ts
  number
  Arrival time relative to previous stop (seconds)
  te
  number
  Stop duration (seconds)
  uid
  string
  Unique stop ID
Response
{
  "status": "success",
  "message": "Route created successfully",
  "data": {
    "uid": "dhqwdh",
    "lineuid": "2567"
  }
}
 

Binding a vehicle to a route (bindControl)

Request address
https://<server_address>/api/api.php?cmd=bindControl
Request body example
{
  "uid": "121e1e1e12",
  "imei": "12304",
  "lineuid": "2e23e23e2e",
  "ts": "1392294840",
  "te": "1392321600",
  "message_url": "http://example.com/message.php",
  "prognoze_url": "http://example.com/prognoze.php"
}
Parameters:
  Parameter
  Type
  Description
  uid
  string
  Unique binding ID
  imei
  string
  Vehicle IMEI
  lineuid
  string
  Route UID
  ts
  string
  Start timestamp
  te
  string
  End timestamp
  message_url
  string
  Event notification URL
  prognoze_url
  string
  Stop arrival forecast URL
Response
{
  "status": "success",
  "message": "Binding created successfully",
  "data": {
    "uid": "121e1e1e12",
    "imei": "12304",
    "lineuid": "2e23e23e2e"
  }
}
 

Simplified binding by route ID (bindLineToVeh)

Request address
https://<server_address>/api/api.php?cmd=bindLineToVeh
Request body example
{
  "data": {
    "imei": "12304",
    "lineid": "12345",
    "ts": "1392294840"
  }
}
Response
{
  "code": 0,
  "msg": "OK",
  "data": {
    "imei": "12304",
    "lineid": "12345"
  }
}
 

Unbinding a vehicle (unbindControl)

Request address
https://<server_address>/api/api.php?cmd=unbindControl
Request body example
{
  "uid": "qiwduhqiwdqkdqkn"
}
  • uid — unique identifier of the binding
Response
{
  "status": "success",
  "message": "Binding removed",
  "data": {
    "uid": "qiwduhqiwdqkdqkn"
  }
}
 

Getting the list of routes (listLines)

Request address
https://<server_address>/api/api.php?cmd=listLines
Response
{
  "code": 0,
  "msg": "OK",
  "data": [
    {
      "id": 2955,
      "name": "125K",
      "number": "125K",
      "bidirectional": 1,
      "description": "125K",
      "account_id": 18306,
      "active": 1,
      "type_id": 0
    }
  ]
}
 
 

Combined route creation and vehicle assignment

Request body example
{
  "uid": "qiwduhqiwdqkdqkn",
  "ts": "1392294840",
  "te": "1392321600",
  "name": "test",
  "imei": "359772039289781",
  "number": "861A",
  "message_url": "http://example.com/message.php",
  "prognoze_url": "http://example.com/prognoze.php",
  "points": [
    {
      "uid": "1",
      "lat": "53.352142",
      "lon": "83.758749",
      "name": "Barnaul Bus Station",
      "radius": "50",
      "stop_type": 0,
      "price": 15.35
    },
    {
      "uid": "2",
      "lat": "52.534012",
      "lon": "85.178777",
      "name": "Biysk Bus Station",
      "radius": "100",
      "stop_type": 0,
      "price": 15.35
    }
  ]
}
Response
{
  "status": "success",
  "message": "Route and binding created successfully",
  "data": {
    "uid": "qiwduhqiwdqkdqkn",
    "imei": "359772039289781",
    "lineuid": "2e23e23e2e"
  }
}