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.
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%
Request:
POST /device/api/login HTTP/1.1
Content-Type: text/json
{"login":"WRONG LOGIN","password":"WRONG PASSWORD"}
Response:
HTTP/1.1 403 Forbidden
Request:
POST /device/api/logout HTTP/1.1 Content-Type: text/json %DEVICE_KEY%
Response:
HTTP/1.1 204 No Content
Request:
POST /device/api/logout HTTP/1.1 Content-Type: text/json %WRONG_DEVICE_KEY%
Response:
HTTP/1.1 400 Bad Request
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
Response:
HTTP/1.1 400 Bad Request
sendPeriod elapsed server will reject your track.¶Response:
HTTP/1.1 409 Conflict
Read more about sendPeriod here.
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
{"savePeriod":5,"sendPeriod":5,"name":"Track name"}
Read more about track settings here.
Response:
HTTP/1.1 400 Bad Request
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"}, ...]
Response:
HTTP/1.1 400 Bad Request
Request:
GET /device/api/trak/continue/%DEVICE_KEY%/%TRACK_ID% HTTP/1.1 Accept: text/json
Response:
HTTP/1.1 200 OK
Content-Type: text/json
{"savePeriod":5,"sendPeriod":5,"name":"Track name"}
Read more about track settings here.
Response:
HTTP/1.1 400 Bad Request
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"}
Response:
HTTP/1.1 400 Bad Request
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.
Response:
HTTP/1.1 400 Bad Request
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
Response:
HTTP/1.1 400 Bad Request
Response:
HTTP/1.1 409 Conflict