API Integration

API Integration


Protrack offers an application program interface (API) to customise your software by in which means integration GPS data from your fleet management account

Instruction

Parameter encoding

Parameter encoding is UTF-8 as standard.

Please refer to: http://en.wikipedia.org/wiki/UTF-8

Time format

Time format is UNIX timestamp.

Please refer to: https://en.wikipedia.org/wiki/Unix_time

HTTP MIME

application/json; charset=UTF-8

The response JSON format

{"code":0,"message":""}

If code != 0, it means request is error ,please refer to Chapter 3.

Message is the code description, or it’s empty.

API List

Get access token

Purpose

Get access token for the others requests, every API must contain the access token.The access token is valid for 2 hours only, please refresh it frequently. When you get a new access token, the old one will be invalid automatically.

Request type

GET

Parameters

ParameterTypeRequiredDescription
timelongtrueThe time when the client sends request
accountstringtrueDistributor ' account
signaturestringtrueEncrypted signature,the algorithm is:md5(md5(password) + time),md5 use 32 lower-case characters.

URI

/api/authorization

Example

http://api.protrack.kiwi/api/authorization?time=1504084954&account=test&signature=ecca11e8e116455c48c8ad2ef5c1e0ee the password=123456,md5(md5(123456) + 1504084954) wil calculate out the result signature=ecca11e8e116455c48c8ad2ef5c1e0ee

Response Description

JSON KEYValue typeDescription
recordObject
access_tokenstringThe access token
expires inlongaccess_token expire time in seconds

Response JSON demo

{
    "record": { 
        "access_token": "ACCESS_TOKEN", 
        "expires_in": 7200, 
    }, 
    "code": 0 
}

Track

Purpose

Get the latest coordinate data for tracking device.

Request type

GET

Parameters

ParameterTypeRequiredDescription
access_tokenstringtrueThe accesstoken
imeisstringtrueTarget IMEI list, separated by comma, max 100 IMEIs in one request.

URI

/api/track

Example

http://api.protrack.kiwi/api/track?access_token=ACCESS_TOKEN&imeis=358899051025339,355139000000234

Response description

JSON KEYValue typeDescription
imeistringThe imei of the target
servertimelongCurrent server time
gpstimelongGps time
hearttimelongHeart time, the last time when the target sent data.
systemtimelongThe system time when the target sent gps dta.
longitudedoubleLongitude
latitudedoublelatitude
courseintcourse(Noth is 0, clockwise increase ,max 360.)
speedintspeed(KM/H)
acctimelongACC status kept time interval in seconds
accstatusintACC status 
1:ACC ON,
0:ACC OFF,
-1:No acc status
doorstatusintDoor status
1:Door open,
0:Door closed,
-1:No door status
chargestatusintCharging status
1:Charging,
0:Not in charging,
-1:No such status 
oilpowerstatusintFule status,
1:Fuel supply ok,
0:Fuel supply off,
-1:No such status
defencestatusintDefence status
1:Defence on,
0:Defence off,
-1:No such status
datastatusint1:Never online,
2:OK,
3:Expired,
4:Offline
batteryintThe battery
-1:No battery status

Response JSON demo

{
    "record": [
        {
        "imei": "358899052025339",
        "course": 195,
        "systemtime": 1419905754,
        "gpstime": 1419906052,
        "speed": 0,
        "hearttime": 1419906952,
        "servertime": 1420964313,
        "longitude": 113.909813,
        "latitude": 22.583197,
        "acctime": 1400,
        "accstatus": 1,
        "doorstatus": 0,
        "chargestatus": 0,
        "oilpowerstatus": 1,
        "defencestatus": 0,
        "datastatus": 2,
        "battery": 100
        }
    ],
    "code": 0
}

Playback

Purpose

Get the GPS data of the target in the time period.

Request type

GET

Parameters

ParameterTypeRequiredDescription
access_tokenstringtrueThe access token
imeistringtrueTarget ' s IMEI
begintimelongtrueBegin time
endtimelongtrueEnd time

URI

api/playback

Example

http://api.protrack365.com/api/playback?access_token=ACCESS_TOKEN&imei=358899051025339&begintime=1406746394&endtime=1407746394

Response description

JSON KEYValue typeDescription
recordStringData is separated by semicolon,the data in each group is:
longitude,latitude,gpstime,speed,course

Response JSON demo

{
"record": "113.97196,22.568616,1406858664,0,228;113.97196,22.56861,1406858684,0,228;113.97196,22.56861,1406858704,0,228;113.97196,22.56861,1406858724,0,228;113.97196,22.56861,1406858724,0,228;113.97196,22.56861,1406858724,0,228;113.97196,22.56861,1406858724,0,228;113.971934,22.568583,1406858780,0,61;113.971925,22.568585,1406858800,0,61",
"code": 0
}

Remark

This api max return 1000 GPS records at one time, when the client get 1000 records, the client has to request next 1000 records, in this request ,the begin time is the last 1000th record’s gpstime, until client get the records less than 1000. When you get the records less than 1000, it means you’ve got all the GPS records.

Error code

CodeDescriptionRemark
10000System error
10001Unknown request
10002Login timeout
10003Not login yet
10004Parameter error
10005Missing required parameter
10006The parameter is out of range
10007Permission denied
10009Request is too frequency
10010Access token doesn’t exist
10011Access token is invalid
10012Access token is out of date
10013IMEI is not authorized
20001Account or password error
20005Target doesn’t exist.
20046Target is expired.




Your shopping cart is empty!