@datafire/traccar
Client library for Traccar
Installation and Usage
npm install --save @datafire/traccar
let traccar = require('@datafire/traccar').create({
username: "",
password: "",
host: ""
});
.then(data => {
console.log(data);
});
Description
Open Source GPS Tracking Platform
Actions
attributes.computed.get
Without params, it returns a list of Attributes the user has access to
traccar.attributes.computed.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId - deviceId
integer
: Standard users can use this only with _deviceId_s, they have access to - groupId
integer
: Standard users can use this only with _groupId_s, they have access to - refresh
boolean
- all
Output
- output
array
- items Attribute
attributes.computed.post
Create an Attribute
traccar.attributes.computed.post({
"body": {}
}, context)
Input
- input
object
- body required Attribute
Output
- output Attribute
attributes.computed.id.delete
Delete an Attribute
traccar.attributes.computed.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
attributes.computed.id.put
Update an Attribute
traccar.attributes.computed.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Attribute
- id required
Output
- output Attribute
calendars.get
Without params, it returns a list of Calendars the user has access to
traccar.calendars.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId
- all
Output
- output
array
- items Calendar
calendars.post
Create a Calendar
traccar.calendars.post({
"body": {}
}, context)
Input
- input
object
- body required Calendar
Output
- output Calendar
calendars.id.delete
Delete a Calendar
traccar.calendars.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
calendars.id.put
Update a Calendar
traccar.calendars.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Calendar
- id required
Output
- output Calendar
commands.get
Without params, it returns a list of Saved Commands the user has access to
traccar.commands.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId - deviceId
integer
: Standard users can use this only with _deviceId_s, they have access to - groupId
integer
: Standard users can use this only with _groupId_s, they have access to - refresh
boolean
- all
Output
- output
array
- items Command
commands.post
Create a Saved Command
traccar.commands.post({
"body": {}
}, context)
Input
- input
object
- body required Command
Output
- output Command
commands.send.get
Return a list of saved commands linked to Device and its groups, filtered by current Device protocol support
traccar.commands.send.get({}, context)
Input
- input
object
- deviceId
integer
: Standard users can use this only with _deviceId_s, they have access to
- deviceId
Output
- output
array
- items Command
commands.send.post
Dispatch a new command or Saved Command if body.id set
traccar.commands.send.post({
"body": {}
}, context)
Input
- input
object
- body required Command
Output
- output Command
commands.types.get
Fetch a list of available Commands for the Device or all possible Commands if Device ommited
traccar.commands.types.get({}, context)
Input
- input
object
- deviceId
integer
: Internal device identifier. Only works if device has already reported some locations - protocol
string
: Protocol name. Can be used instead of device id - textChannel
boolean
: Whentrue
return SMS commands. If not specified orfalse
return data commands
- deviceId
Output
- output
array
- items CommandType
commands.id.delete
Delete a Saved Command
traccar.commands.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
commands.id.put
Update a Saved Command
traccar.commands.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Command
- id required
Output
- output Command
devices.get
Without any params, returns a list of the user's devices
traccar.devices.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId - id
integer
: To fetch one or more devices. Multiple params can be passed likeid=31&id=42
- uniqueId
string
: To fetch one or more devices. Multiple params can be passed likeuniqueId=333331&uniqieId=44442
- all
Output
- output
array
- items Device
devices.post
Create a Device
traccar.devices.post({
"body": {}
}, context)
Input
- input
object
- body required Device
Output
- output Device
devices.id.delete
Delete a Device
traccar.devices.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
devices.id.put
Update a Device
traccar.devices.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Device
- id required
Output
- output Device
devices.id.accumulators.put
Update total distance and hours of the Device
traccar.devices.id.accumulators.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required DeviceAccumulators
- id required
Output
Output schema unknown
drivers.get
Without params, it returns a list of Drivers the user has access to
traccar.drivers.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId - deviceId
integer
: Standard users can use this only with _deviceId_s, they have access to - groupId
integer
: Standard users can use this only with _groupId_s, they have access to - refresh
boolean
- all
Output
- output
array
- items Driver
drivers.post
Create a Driver
traccar.drivers.post({
"body": {}
}, context)
Input
- input
object
- body required Driver
Output
- output Driver
drivers.id.delete
Delete a Driver
traccar.drivers.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
drivers.id.put
Update a Driver
traccar.drivers.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Driver
- id required
Output
- output Driver
events.id.get
traccar.events.id.get({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
- output Event
geofences.get
Without params, it returns a list of Geofences the user has access to
traccar.geofences.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId - deviceId
integer
: Standard users can use this only with _deviceId_s, they have access to - groupId
integer
: Standard users can use this only with _groupId_s, they have access to - refresh
boolean
- all
Output
- output
array
- items Geofence
geofences.post
Create a Geofence
traccar.geofences.post({
"body": {}
}, context)
Input
- input
object
- body required Geofence
Output
- output Geofence
geofences.id.delete
Delete a Geofence
traccar.geofences.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
geofences.id.put
Update a Geofence
traccar.geofences.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Geofence
- id required
Output
- output Geofence
groups.get
Without any params, returns a list of the Groups the user belongs to
traccar.groups.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId
- all
Output
- output
array
- items Group
groups.post
Create a Group
traccar.groups.post({
"body": {}
}, context)
Input
- input
object
- body required Group
Output
- output Group
groups.id.delete
Delete a Group
traccar.groups.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
groups.id.put
Update a Group
traccar.groups.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Group
- id required
Output
- output Group
maintenance.get
Without params, it returns a list of Maintenance the user has access to
traccar.maintenance.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId - deviceId
integer
: Standard users can use this only with _deviceId_s, they have access to - groupId
integer
: Standard users can use this only with _groupId_s, they have access to - refresh
boolean
- all
Output
- output
array
- items Maintenance
maintenance.post
Create a Maintenance
traccar.maintenance.post({
"body": {}
}, context)
Input
- input
object
- body required Maintenance
Output
- output Maintenance
maintenance.id.delete
Delete a Maintenance
traccar.maintenance.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
maintenance.id.put
Update a Maintenance
traccar.maintenance.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Maintenance
- id required
Output
- output Maintenance
notifications.get
Without params, it returns a list of Notifications the user has access to
traccar.notifications.get({}, context)
Input
- input
object
- all
boolean
: Can only be used by admins or managers to fetch all entities - userId
integer
: Standard users can use this only with their own userId - deviceId
integer
: Standard users can use this only with _deviceId_s, they have access to - groupId
integer
: Standard users can use this only with _groupId_s, they have access to - refresh
boolean
- all
Output
- output
array
- items Notification
notifications.post
Create a Notification
traccar.notifications.post({
"body": {}
}, context)
Input
- input
object
- body required Notification
Output
- output Notification
notifications.test.post
Send test notification to current user via Email and SMS
traccar.notifications.test.post(null, context)
Input
This action has no parameters
Output
Output schema unknown
notifications.types.get
Fetch a list of available Notification types
traccar.notifications.types.get(null, context)
Input
This action has no parameters
Output
- output
array
- items NotificationType
notifications.id.delete
Delete a Notification
traccar.notifications.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
notifications.id.put
Update a Notification
traccar.notifications.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required Notification
- id required
Output
- output Notification
permissions.delete
Unlink an Object from another Object
traccar.permissions.delete({
"body": {}
}, context)
Input
- input
object
- body required Permission
Output
Output schema unknown
permissions.post
Link an Object to another Object
traccar.permissions.post({
"body": {}
}, context)
Input
- input
object
- body required Permission
Output
- output Permission
positions.get
We strongly recommend using Traccar WebSocket API instead of periodically polling positions endpoint. Without any params, it returns a list of last known positions for all the user's Devices. from and to fields are not required with id.
traccar.positions.get({}, context)
Input
- input
object
- deviceId
integer
: deviceId is optional, but requires the from and to parameters when used - from
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- to
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- id
integer
: To fetch one or more positions. Multiple params can be passed likeid=31&id=42
- deviceId
Output
- output
array
- items Position
reports.events.get
At least one deviceId or one groupId must be passed
traccar.reports.events.get({
"from": "",
"to": ""
}, context)
Input
- input
object
- deviceId
array
- groupId
array
- type
array
: % can be used to return events of all types - from required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- to required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- deviceId
Output
- output
array
- items Event
reports.route.get
At least one deviceId or one groupId must be passed
traccar.reports.route.get({
"from": "",
"to": ""
}, context)
Input
- input
object
- deviceId
array
- groupId
array
- from required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- to required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- deviceId
Output
- output
array
- items Position
reports.stops.get
At least one deviceId or one groupId must be passed
traccar.reports.stops.get({
"from": "",
"to": ""
}, context)
Input
- input
object
- deviceId
array
- groupId
array
- from required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- to required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- deviceId
Output
- output
array
- items ReportStops
reports.summary.get
At least one deviceId or one groupId must be passed
traccar.reports.summary.get({
"from": "",
"to": ""
}, context)
Input
- input
object
- deviceId
array
- groupId
array
- from required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- to required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- deviceId
Output
- output
array
- items ReportSummary
reports.trips.get
At least one deviceId or one groupId must be passed
traccar.reports.trips.get({
"from": "",
"to": ""
}, context)
Input
- input
object
- deviceId
array
- groupId
array
- from required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- to required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- deviceId
Output
- output
array
- items ReportTrips
server.get
Fetch Server information
traccar.server.get(null, context)
Input
This action has no parameters
Output
- output Server
server.put
Update Server information
traccar.server.put({
"body": {}
}, context)
Input
- input
object
- body required Server
Output
- output Server
session.delete
Close the Session
traccar.session.delete(null, context)
Input
This action has no parameters
Output
Output schema unknown
session.get
Fetch Session information
traccar.session.get({}, context)
Input
- input
object
- token
string
- token
Output
- output User
session.post
Create a new Session
traccar.session.post({
"body": null
}, context)
Input
- input
object
Output
- output User
statistics.get
Fetch server Statistics
traccar.statistics.get({
"from": "",
"to": ""
}, context)
Input
- input
object
- from required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- to required
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- from required
Output
- output
array
- items Statistics
users.get
Fetch a list of Users
traccar.users.get({}, context)
Input
- input
object
- userId
string
: Can only be used by admin or manager users
- userId
Output
- output
array
- items User
users.post
Create a User
traccar.users.post({
"body": {}
}, context)
Input
- input
object
- body required User
Output
- output User
users.id.delete
Delete a User
traccar.users.id.delete({
"id": 0
}, context)
Input
- input
object
- id required
integer
- id required
Output
Output schema unknown
users.id.put
Update a User
traccar.users.id.put({
"id": 0,
"body": {}
}, context)
Input
- input
object
- id required
integer
- body required User
- id required
Output
- output User
Definitions
Attribute
- Attribute
object
- attribute
string
- description
string
- expression
string
- id
integer
- type
string
: String|Number|Boolean
- attribute
Calendar
- Calendar
object
- attributes
object
- data
string
: base64 encoded in iCalendar format - id
integer
- name
string
- attributes
Command
- Command
object
- attributes
object
- description
string
- deviceId
integer
- id
integer
- type
string
- attributes
CommandType
- CommandType
object
- type
string
- type
Device
- Device
object
- attributes
object
- category
string
- contact
string
- disabled
boolean
- geofenceIds
array
- items
integer
- items
- groupId
integer
- id
integer
- lastUpdate
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- model
string
- name
string
- phone
string
- positionId
integer
- status
string
- uniqueId
string
- attributes
DeviceAccumulators
- DeviceAccumulators
object
- deviceId
integer
- hours
number
- totalDistance
number
: in meters
- deviceId
Driver
- Driver
object
- attributes
object
- id
integer
- name
string
- uniqueId
string
- attributes
Event
- Event
object
- attributes
object
- deviceId
integer
- geofenceId
integer
- id
integer
- maintenanceId
integer
- positionId
integer
- serverTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- type
string
- attributes
Geofence
- Geofence
object
- area
string
- attributes
object
- calendarId
integer
- description
string
- id
integer
- name
string
- area
Group
- Group
object
- attributes
object
- groupId
integer
- id
integer
- name
string
- attributes
Maintenance
- Maintenance
object
- attributes
object
- id
integer
- name
string
- period
number
- start
number
- type
string
- attributes
Notification
- Notification
object
- always
boolean
- attributes
object
- calendarId
integer
- id
integer
- mail
boolean
- sms
boolean
- type
string
- web
boolean
- always
NotificationType
- NotificationType
object
- type
string
- type
Permission
- Permission
object
: This is a permission map that contain two object indexes. It is used to link/unlink objects. Order is important. Example: { deviceId:8, geofenceId: 16 }- attributeId
integer
: Computed Attribute Id, can be second parameter only - calendarId
integer
: Calendar Id, can be second parameter only and only in combination with userId - deviceId
integer
: Device Id, can be first parameter or second only in combination with userId - driverId
integer
: Driver Id, can be second parameter only - geofenceId
integer
: Geofence Id, can be second parameter only - groupId
integer
: Group Id, can be first parameter or second only in combination with userId - managedUserId
integer
: User Id, can be second parameter only and only in combination with userId - userId
integer
: User Id, can be only first parameter
- attributeId
Position
- Position
object
- accuracy
number
- address
string
- altitude
number
- attributes
object
- course
number
- deviceId
integer
- deviceTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- fixTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- id
integer
- latitude
number
- longitude
number
- network
object
- outdated
boolean
- protocol
string
- serverTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- speed
number
: in knots - valid
boolean
- accuracy
ReportStops
- ReportStops
object
- address
string
- deviceId
integer
- deviceName
string
- duration
integer
- endTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- engineHours
integer
- lat
number
- lon
number
- spentFuel
number
: in liters - startTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- address
ReportSummary
- ReportSummary
object
- averageSpeed
number
: in knots - deviceId
integer
- deviceName
string
- distance
number
: in meters - engineHours
integer
- maxSpeed
number
: in knots - spentFuel
number
: in liters
- averageSpeed
ReportTrips
- ReportTrips
object
- averageSpeed
number
: in knots - deviceId
integer
- deviceName
string
- distance
number
: in meters - driverName
string
- driverUniqueId
integer
- duration
integer
- endAddress
string
- endLat
number
- endLon
number
- endTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- maxSpeed
number
: in knots - spentFuel
number
: in liters - startAddress
string
- startLat
number
- startLon
number
- startTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- averageSpeed
Server
- Server
object
- attributes
object
- bingKey
string
- coordinateFormat
string
- deviceReadonly
boolean
- forceSettings
boolean
- id
integer
- latitude
number
- limitCommands
boolean
- longitude
number
- map
string
- mapUrl
string
- poiLayer
string
- readonly
boolean
- registration
boolean
- twelveHourFormat
boolean
- version
string
- zoom
integer
- attributes
Statistics
- Statistics
object
- activeDevices
integer
- activeUsers
integer
- captureTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- messagesReceived
integer
- messagesStored
integer
- requests
integer
- activeDevices
User
- User
object
- administrator
boolean
- attributes
object
- coordinateFormat
string
- deviceLimit
integer
- deviceReadonly
boolean
- disabled
boolean
- email
string
- expirationTime
string
: in IS0 8601 format. eg.1963-11-22T18:30:00Z
- id
integer
- latitude
number
- limitCommands
boolean
- longitude
number
- map
string
- name
string
- password
string
- phone
string
- poiLayer
string
- readonly
boolean
- token
string
- twelveHourFormat
boolean
- userLimit
integer
- zoom
integer
- administrator