Web RESTful API Reference¶
Login
Logout
Post track
Create new track
Get list of existing tracks
Continue existing track
Get track info
Get track settings
Update track settings
Get track
Remove track¶
Briefly¶
Login to post GPS data to Wannatrak server.
You'll receive the DEVICE_KEY on successful login.
You'll use this DEVICE_KEY for further interactions with server as your unique identifier.
If you login for the first time and you don't have previous tracks on the server there will be created a new one with your login name.
If you already have tracks then you will be linked to the last used track. Your GPS data will be attached to it.
To find out a name of your current track call Get track info.
To see your existing tracks use Get list of existing tracks.
If you want to post data to a new track, first of all, Create new track.
To switch to one of existing tracks use Continue existing track.
Login¶
Correct case¶
Request:
POST /device/api/login HTTP/1.1
Content-Type: text/json
{"login":"LOGIN","password":"PASSWORD"}
Response:
HTTP/1.1 200 OK Content-Type: */* %DEVICE_KEY%
Incorrect case¶
Request:
POST /device/api/login HTTP/1.1
Content-Type: text/json
{"login":"WRONG LOGIN","password":"WRONG PASSWORD"}
Response:
HTTP/1.1 403 Forbidden
Logout¶
Correct case¶
Request:
POST /device/api/logout HTTP/1.1 Content-Type: text/json %DEVICE_KEY%
Response:
HTTP/1.1 204 No Content
Incorrect case¶
Request:
POST /device/api/logout HTTP/1.1 Content-Type: text/json %WRONG_DEVICE_KEY%
Response:
HTTP/1.1 400 Bad Request
Post track¶
Correct case¶
Request:
POST /device/api/trak/%DEVICE_KEY% HTTP/1.1 Content-Type: text/json [[Timestamp,Longitude,Latitude,Speed,Course,Altitude],[Timestamp,Longitude,Latitude,Speed,Course,Altitude], ...]
Timestamp- integer number of millis since 1/1/1970
Longitude,LatitudeandCourse- float degrees
Speed- float number of kilometers per hour
Example on js:
Altitude- float number of meters above sea level
1 var http = new XMLHttpRequest();
2 http.open("POST", "http://www.wannatrak.com/device/api/trak/%DEVICE_KEY%", true);
3 var params = '[[127000000,2.5,3.4,4,5,6],[127000001,2.4,3.5,4,5,6]]';
4 http.setRequestHeader("Content-type", "text/json");
5 http.setRequestHeader("Content-length", params.length);
6 http.setRequestHeader("Connection", "close");
7 http.onreadystatechange = function() {
8 if(http.readyState == 4 && http.status == 200) {
9 alert(http.responseText);
10 }
11 }
12 http.send(params);
Response:
HTTP/1.1 204 No Content
Incorrect case¶
Response:
HTTP/1.1 400 Bad Request
Warning! If you try to send track before sendPeriod elapsed server will reject your track.¶
Response:
HTTP/1.1 409 Conflict
Read more about sendPeriod here.
Create new track¶
Correct case¶
Request:
GET /device/api/trak/create/%DEVICE_KEY%/%TRACK_NAME% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
{"id":"%TRACK_ID%","name":"Track name"}
Incorrect case¶
Response:
HTTP/1.1 400 Bad Request
Get list of existing tracks¶
Correct case¶
Request:
GET /device/api/trak/list/%DEVICE_KEY% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
[{"id":"%TRACK_ID%","name":"Track name"}, {"id":"%TRACK_ID_2%","name":"Track name 2"}, ...]
Incorrect case¶
Response:
HTTP/1.1 400 Bad Request
Continue existing track¶
Correct case¶
Request:
GET /device/api/trak/continue/%DEVICE_KEY%/%TRACK_ID% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK Content-Type: */* %NEW_DEVICE_KEY%
Incorrect case¶
Response:
HTTP/1.1 400 Bad Request
Get track info¶
Correct case¶
Request:
GET /device/api/trak/get/%DEVICE_KEY% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
{"id":"%TRACK_ID%","name":"Track name"}
Incorrect case¶
Response:
HTTP/1.1 400 Bad Request
Get track settings¶
Correct case¶
Request:
GET /device/api/trak/settings/%DEVICE_KEY% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
{"savePeriod":5,"sendPeriod":5,"name":"Track name"}
savePeriod- seconds between points in track
sendPeriod- minutes between sending part of track to server
Warning! If you try to send track before sendPeriod elapsed server will reject your track.
Incorrect case¶
Response:
HTTP/1.1 400 Bad Request
Update track settings¶
Correct case¶
Request:
POST /device/api/trak/settings/%DEVICE_KEY% HTTP/1.1
Content-Type: text/json
{"savePeriod":1,"sendPeriod":2,"name":"New track"}
savePeriod- seconds between points in track
sendPeriod- minutes between sending part of track to server
Warning! If you try to send track before sendPeriod elapsed server will reject your track.
Response:
HTTP/1.1 204 No Content
Incorrect case¶
Response:
HTTP/1.1 400 Bad Request
Track with such name already exists case¶
Response:
HTTP/1.1 409 Conflict
Get track¶
Correct case¶
Request:
GET /device/api/trak/%DEVICE_KEY%/%TRACK_ID%/%FROM%/%TO%/%WITH_NOISE% HTTP/1.1 Accept: text/json
FROM- start time in milliseconds since Jan 1 1970
TO- end time in milliseconds since Jan 1 1970
WITH_NOISE- include noise movements in track (true/false)
Number of returned points is limited to 4000.
Short version:
GET /device/api/trak/%DEVICE_KEY%/%TRACK_ID%/%WITH_NOISE% HTTP/1.1 Accept: text/json
From Jan 1 1970 to now
Response:
HTTP/1.1 200 OK Content-Type: text/json [[Timestamp,Longitude,Latitude,Speed,Course,Altitude],[Timestamp,Longitude,Latitude,Speed,Course,Altitude], ...]
Remove track¶
Correct case¶
Request:
DELETE /device/api/trak/remove/%DEVICE_KEY%/%TRACK_ID% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 204 No Content
Incorrect case¶
Request:
DELETE /device/api/trak/remove/%WRONG_DEVICE_KEY%/%TRACK_ID% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 400 Bad Request