Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If message does not contain objects of one of the types, the key would not be included in the JSON structure. Most of the time messages contain a single type of objects.

Info

Before opening a WebSocket you have to create a session first.

See the following two sample projects (HTML/Javascript client and Node.js client).

Sample HTML WebSocket API Client

Here you can find a (non-complete) sample project drawing the devices of an account on a map (including WebSocket live updates).

Sample Node.js WebSocket API Client

...

  1. Log in to https://traccar.powunity.com

  2. click Settings at the top right:

  3. Select Account

  4. Click on the Attributes button in the dialog that opened

  5. Use the + button to add the following attributes to the table - NOTE: Attribute names are case sensitive!

    1. webhookUrl This is the URL that will be called on every new event via a HTTP POST request. We highly encourage to use a URL starting with https:// but http:// is also supported for testing purposes.

    2. webhookPsk Optional. If set, the HTTP(S) requests will contain a Authorization header with this attribute’s data as value. This should allow Basic and Bearer authorization methods to be implemented easily.

    3. webhookTypes Optional. If set, this should be a comma (,) separated list of event types which are to be forwarded by the webhook. If this attribute is not present then all events are sent. Some useful possible values are: deviceOnline, deviceOffline, deviceMoving, deviceStopped, alarm, geofenceEnter, geofenceExit, ignitionOn, ignitionOff

    4. Here is what the Attributes dialog could look like:

      Image RemovedImage Added
  6. Once the attributes are set close the Attributes and Account dialogs. The webhooks are then activated immediately.

...