Hello, I hope these examples can serve as a starting point. excuse my English, I'm using google translator.
Examples are in javascript. but I guess for ios, must exist any command that request GET or POST requests.
// find All devices - GET request var result = HTTP.call( "GET", 'http://your_domain:8082/api/devices/', { auth: 'email@xyz.com:password' , params: { } } ); // add device var name = 'name your device'; var uniqueId = '122323223232'; // usually this is the device imei var result = HTTP.post( 'http://your_domain:8082/api/devices/', { auth: 'email@xyz.com:password' , data:{ groupId:null, id: null, lastUpdate:null, status:'', name:name, uniqueId:uniqueId } } );
with these examples I think you can already make your ios applications. requests for more GET PUT POST DELETE, check the swagger file. you only need to know what type it is (GET, POST, PUT, DELETE) and parameters.
luck
Thank you bro!
I have another question...if i need to retrieve information like speed,latitud longitude how can i do that?
Another question:
In the api documentation the userId parameter refers to what?
Thank you all
If you want an example of how to use API from Swift, you can take a look at Traccar Manager for iOS source code:
Hello again.
when you create traccar users (admin or normal), this in the database generates a unique id. this unique id refers when documentation ask the userId
cuando uses REST en traccar, te daras cuenta que necesitas identificarte.
auth: 'email@xyz.com:password'
if that identification of an administrator. then in REST applications, you can put any other user userId and you will return your data.
but if it is not an administrator, then only you would return your data from your devices for that user.
if you are an administrator and want to see all devices including other users can use the parameter all: true
params: {all:true}
or users requesting user terminals by putting your userIdparams: {userId: 1}
sorry if you do not understand me. I'm using google translator from Spanish to English
answering your questions
to request the latest positions with all the data.
you need to request a GET request to
'http://your_domain:8082/api/positions'
luck
Thank you all for yours answersssssssssssss!!!!
Thank you i am going to try everything !
Thank you!!!!!!!!!!!!!!!!!! :)
This example in javascrip is angular??
Hola mvalverde.
Veo que ya has trabajado con el API de Traccar, yo hasta ahora estoy comenzando y tengo varias dudas. Me gustaría saber si tienes un ejemplo para enviar una orden a cualquier dispositivo como lo indica Anton en otro foro.
"There is also an option in API to send raw text commands to any device."
Muchas Gracias
Hi all,
You can generate all types of code: php client, android client, swift client, etc by using the swagger-editor at http://editor.swagger.io/
mtrntx => example is in Meteor js
shernandez =>
No tengo muchos ejemplos para la api todavia, pero pongo el que uso para apagar un vehículo.
var result = HTTP.post(
'http://domain:8082/api/commands',
{
auth: 'email@xyz.com:password',
data:{
deviceId:idDevice,
type: 'engineStop'
}
}
);
Para prender solo es cambiar 'engineStop' por 'engineResume'. Y no olvidarse que idDevice es el id en la base de datos del vehículo en cuestión y asociado al usuario traccar email@xyz.com.
Y todos los comandos los puedes desarrollar siguiendo http://editor.swagger.io/ para cualquier lenguaje.
Friend, you got a solution? I have the same problem.
If you can share.
You can download the example project that is in this post and have an example !!!!
I downloaded the project but it returns me an error , I can not compile.
Returns this message, even the file being it.
bridging header '/Users/rafamelo/Downloads/traccar-manager-ios-master/TraccarManager/BridgingHeader.h' does not exist
even the file being it
Hi everyone
I am trying to make an IOS APP using swift with the public API that traccar have i think is version 3.3.
I know they are a documentation file on the web that need to open with swagger editor but i need a example how can i make any request like login,getting device info etc from my server using the api.
Example if i want to know a device info how can i do that?
Please give me a detail example i dint understand the api documentation
Thank you for all.