Skip to content

Instantly share code, notes, and snippets.

@ramilamparo
Last active September 12, 2019 03:30
Show Gist options
  • Save ramilamparo/a4c4cf071abb7d7b719a49459501d1dc to your computer and use it in GitHub Desktop.
Save ramilamparo/a4c4cf071abb7d7b719a49459501d1dc to your computer and use it in GitHub Desktop.

Driver API

Summary

This is an API wrapper for Wialon to easily determine who is driving a vehicle given a specific time. All requests to the API are achieved with GET requests. All returned data are in the form of JSON.

Driver binding

A driver must be created in Wialon and the driver code must contain the same code that is in the RFID.

Salik Geofences

Geofences in Wialon containing the word "salik" (case insensitive) are automatically included in the API when getting driver data.

Get all vehicles

http://driver-api.atsuae.net/units?token=

Returns

[
	/* Return an array of all units in the account. */
	{
		"id": "[NUMBER]",
		"name": "[STRING]",
		"plate": "[STRING]", // (Nullable)
		"vin": "[STRING]", // (Nullable)
		"imei": "[STRING]"
	}
];

Params

  1. token
  • Access token used to login to an account.

Example

http://driver-api.atsuae.net/units?token=[TOKEN_HERE]

Get driving data.

http://driver-api.atsuae.net/driving-data?from=&to=&identifier=&identifierType=&token=

Returns:

{
    "drivers": [                /* Array of drivers in case there are multiple drivers in your selected time interval (from & to parameters)*/
        "name": "[STRING]",     /* Driver name */
        "code": "[STRING]",     /* RFID value. Unique on all drivers */
        "phone": "[STRING]"     /* Driver phone. */
    ],
    "maxSpeed": "[NUMBER]",     /* In Kilometers per hour */
    "salikTolls": [             /* Array of all salik tolls passed in the duration interval (from & to parameters) */
        "name": "[STRING]",     /* Toll booth name */
        "lat": "[NUMBER]",
        "lng": "[NUMBER]",
        "time": "[NUMBER]"      /* Time the driver has passed the gate */
    ],
    "foundMatches": "[NUMBER]",  /* Found matches with from the identifier parameter provided. */
    "messages": [               /* Array of all the device messages sent by the device */
        "lat": "[NUMBER]",
        "lng": "[NUMBER]",
        "time": "[NUMBER]",
        "driverCode": "[STRING]", /* Driver RFID value */
        "address": "[STRING]" /* Address formatted in the order: house, street, city, region, country */
    ],
    "unit": { /* Details for the found unit */
        "name": "[STRING]", /* Unit name (Nullable) */
        "plate": "[STRING]", /* Vehicle plate number (Nullable) */
        "vin": "[STRING]",  /* Vehicle vin number (Nullable) */
        "imei": "[STRING]" /*Device IMEI  (Nullable) */
    }
}

Params

  1. token
  • Access token used to login to an account.
  1. from
  • Get all messages from the device between from & to.
  • Time is formatted in unix time stamp https://www.unixtimestamp.com/
  • Maximum interval between from & to is 30 minutes.
  • If interval is more than 30 minutes specified in the parameters, it will default to 30 minutes.
  1. to (Optional)
  • Get all messages from the device between from & to.
  • If NOT specified, interval will be 30 minutes from the "from" parameter.
  • Time is formatted in unix time stamp https://www.unixtimestamp.com/.
  • Maximum interval between from & to is 30 minutes.
  • If interval is more than 30 minutes specified in the parameters, it will default to 30 minutes.
  1. identifier
  • Search keyword on which unit to return.
  • If multiple units are found, only the first unit will be returned.
  1. identifierType (Optional)
  • Possible values are imei | name | vin | plate. Default is imei. Note that these values are taken from the unit profile in Wialon.
    • imei - IMEI number of the unit. Unique on all units.
    • name - Unit name in Wialon.
    • vin - Vehicle chassis number in Wialon unit profile.
    • plate - Plate number in Wialon unit profile.
  • Determines what property to search in with the identifier provided.
  • Using imei is recommended since it is unique on all units and the other types could possibly be duplicated.

Example

http://driver-api.atsuae.net/driving-data?from=1567812599&to=1567814399&identifier=LP-DRIVER%20TEST&identifierType=name&token=[TOKEN_HERE]

Errors

If an error has occured, the server will respond with a JSON containing the error.

To see possible wialon errors, see https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/errors/errors

Returns

{ /* Details for the error occurred */
    "type": "[STRING]", /* Determines if the error occured in Wialon or somewhere else */
    "message": "[STRING]", /* Some information about the error. */
    "code": "[NUMBER]",  /* Error code for Wialon */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment