You may want to start with the API documentation. https://www.traccar.org/api-reference/
Hi Tony
Thanks for your response. I looked at the API documentation. I am not able to find API which gives me the tracking information (Latitude, Longitude, Speed etc) of a device which sends data to traccar port.
Is it possible for me to push tracking data directly from within traccar code to mqtt? Can you point me out the file where I can do this?
Sumeet, I am interested in exactly the same information as you, but haven't gotten very far as I am still trying to get Traccar going properly so we can test it.
We have an existing tracking system that I am not happy with, that if possible we will replace with Traccar.
It runs on Oracle, and has no APIs. On that system i hook directly into the tables and suck the data out that way.
Depending on the RDBMS you use, you can often trigger changes directly into a messaging queue.
We just wrote a monitoring system that reads the system for changes every minute or so.
This data is then loaded into Posgres for additional reporting and geolocation processing.
Not sure how advisable that approach is with Traccar, as you are not protected in changes to the data structures.
Hi Tony,
Thanks for the response. I do not want another overhead of first saving the data into DB and then writing a trigger to push the same to MQTT. I think there is a way to publish the parsed packet from within traccar open source code.
Hey Sumeet, I think you might be interested in using the traccar Webhook event forwarding (u can enable it using config) where u can push the position data to some services which are pushing the same to MQTT. And regarding not storing the data in DB for positions, You might need to implement a custom config and based on that you can disable writing the positions data to DB. I am afraid to say to achieve this you might require to do some changes, but they will be minimal for sure.
Hi Mayank
Thanks for the response.
Current status:
I have completed 1 and 2. But I am looking for a best place where I can implement 3.
Hey Sumit,
Before I can help you more, I have one question; Are u interested in Dashboard also showing the correct data for the devices or it's just you want to route the positions update coming to your MQTT broker.
Hi Mayank,
We are not interested in the dashboard as we have our own custom app. We are only interested in receiving location data to Broker.
Hey Sumeet,
In that case, If you have some other service which can consume this json position object. You can enable the config as below to enable position forwarding;
<!-- position forwarding -->
<entry key='forward.enable'>true</entry>
<entry key='forward.json'>true</entry>
<entry key='forward.url'>http://<ip>:port/<path></entry>
If you prefer, Traccar can forward positions using query parameters: we can configure this by a disabling forward.json and specifying the parameters we’re interested in.
<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://<ip>:<port>/positions?id={uniqueId}&lat={latitude}&lon={longitude}</entry>
<entry key='forward.json'>false</entry>
The list of possible query parameter values which can be interpolated I’ve taken from the source:
{name} is the name of a device
{uniqueId} its unique identifier
{protocol} the protocol through which a position was reported, e.g. "owntracks"
{fixTime} the time of fix
{latitude} and {longitude} the latitude, and longitude respectively
{altitude}, {speed}, {course}, and {accuracy} should be self-explanatory
{address} the reverse-geo-coded address if available
And then set some custom config and based on this do not write the data in the DB.
In case if you do not have the other service to consume the position json object, rather would like the traccar to handle this; In that case while saving the position object to DB, instead of saving the same to DB pass this to through the broker configured.
Hi
This is a great project with almost all the devices integrated! Thanks for that.
I wanted to know that after decoding the data, can it be sent to a MQTT broker as a JSON? If yes, please let me know how to do it or is there something already available. I do not want it to be saved into any DB, it just has to publish it to a configured broker.
Thanks in advance