4.5.0 • Published 5 years ago

traccar-api-client v4.5.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

traccar-api-client

Traccar - JavaScript client for traccar No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) This SDK is automatically generated by the Swagger Codegen project:

  • API version: 4.5
  • Package version: 4.5.0
  • Build package: io.swagger.codegen.languages.JavascriptClientCodegen

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install traccar-api-client --save
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your traccar from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('traccar') in javascript files from the directory you ran the last command above from.

git

If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:

    npm install GIT_USER_ID/GIT_REPO_ID --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var Traccar = require('traccar-api-client');

var defaultClient = Traccar.ApiClient.instance;
// Configure HTTP API Server
defaultClient.basePath = 'https://YOUR-TRACCAR-SERVER/api';

// Configure HTTP basic authorization: basicAuth
var basicAuth = defaultClient.authentications['basicAuth'];
basicAuth.username = 'YOUR USERNAME'
basicAuth.password = 'YOUR PASSWORD'

var api = new Traccar.DefaultApi()

var opts = { 
  'all': true, // {Boolean} Can only be used by admins or managers to fetch all entities
  'userId': 56, // {Number} Standard users can use this only with their own _userId_
  'deviceId': 56, // {Number} Standard users can use this only with _deviceId_s, they have access to
  'groupId': 56, // {Number} Standard users can use this only with _groupId_s, they have access to
  'refresh': true // {Boolean} 
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.attributesComputedGet(opts, callback);

Documentation for API Endpoints

All URIs are relative to http://demo.traccar.org/api

ClassMethodHTTP requestDescription
Traccar.DefaultApiattributesComputedGetGET /attributes/computedFetch a list of Attributes
Traccar.DefaultApiattributesComputedIdDeleteDELETE /attributes/computed/{id}Delete an Attribute
Traccar.DefaultApiattributesComputedIdPutPUT /attributes/computed/{id}Update an Attribute
Traccar.DefaultApiattributesComputedPostPOST /attributes/computedCreate an Attribute
Traccar.DefaultApicalendarsGetGET /calendarsFetch a list of Calendars
Traccar.DefaultApicalendarsIdDeleteDELETE /calendars/{id}Delete a Calendar
Traccar.DefaultApicalendarsIdPutPUT /calendars/{id}Update a Calendar
Traccar.DefaultApicalendarsPostPOST /calendarsCreate a Calendar
Traccar.DefaultApicommandsGetGET /commandsFetch a list of Saved Commands
Traccar.DefaultApicommandsIdDeleteDELETE /commands/{id}Delete a Saved Command
Traccar.DefaultApicommandsIdPutPUT /commands/{id}Update a Saved Command
Traccar.DefaultApicommandsPostPOST /commandsCreate a Saved Command
Traccar.DefaultApicommandsSendGetGET /commands/sendFetch a list of Saved Commands supported by Device at the moment
Traccar.DefaultApicommandsSendPostPOST /commands/sendDispatch commands to device
Traccar.DefaultApicommandsTypesGetGET /commands/typesFetch a list of available Commands for the Device or all possible Commands if Device ommited
Traccar.DefaultApidevicesGetGET /devicesFetch a list of Devices
Traccar.DefaultApidevicesIdAccumulatorsPutPUT /devices/{id}/accumulatorsUpdate total distance and hours of the Device
Traccar.DefaultApidevicesIdDeleteDELETE /devices/{id}Delete a Device
Traccar.DefaultApidevicesIdPutPUT /devices/{id}Update a Device
Traccar.DefaultApidevicesPostPOST /devicesCreate a Device
Traccar.DefaultApidriversGetGET /driversFetch a list of Drivers
Traccar.DefaultApidriversIdDeleteDELETE /drivers/{id}Delete a Driver
Traccar.DefaultApidriversIdPutPUT /drivers/{id}Update a Driver
Traccar.DefaultApidriversPostPOST /driversCreate a Driver
Traccar.DefaultApieventsIdGetGET /events/{id}
Traccar.DefaultApigeofencesGetGET /geofencesFetch a list of Geofences
Traccar.DefaultApigeofencesIdDeleteDELETE /geofences/{id}Delete a Geofence
Traccar.DefaultApigeofencesIdPutPUT /geofences/{id}Update a Geofence
Traccar.DefaultApigeofencesPostPOST /geofencesCreate a Geofence
Traccar.DefaultApigroupsGetGET /groupsFetch a list of Groups
Traccar.DefaultApigroupsIdDeleteDELETE /groups/{id}Delete a Group
Traccar.DefaultApigroupsIdPutPUT /groups/{id}Update a Group
Traccar.DefaultApigroupsPostPOST /groupsCreate a Group
Traccar.DefaultApimaintenanceGetGET /maintenanceFetch a list of Maintenance
Traccar.DefaultApimaintenanceIdDeleteDELETE /maintenance/{id}Delete a Maintenance
Traccar.DefaultApimaintenanceIdPutPUT /maintenance/{id}Update a Maintenance
Traccar.DefaultApimaintenancePostPOST /maintenanceCreate a Maintenance
Traccar.DefaultApinotificationsGetGET /notificationsFetch a list of Notifications
Traccar.DefaultApinotificationsIdDeleteDELETE /notifications/{id}Delete a Notification
Traccar.DefaultApinotificationsIdPutPUT /notifications/{id}Update a Notification
Traccar.DefaultApinotificationsPostPOST /notificationsCreate a Notification
Traccar.DefaultApinotificationsTestPostPOST /notifications/testSend test notification to current user via Email and SMS
Traccar.DefaultApinotificationsTypesGetGET /notifications/typesFetch a list of available Notification types
Traccar.DefaultApipermissionsDeleteDELETE /permissionsUnlink an Object from another Object
Traccar.DefaultApipermissionsPostPOST /permissionsLink an Object to another Object
Traccar.DefaultApipositionsGetGET /positionsFetches a list of Positions
Traccar.DefaultApireportsEventsGetGET /reports/eventsFetch a list of Events within the time period for the Devices or Groups
Traccar.DefaultApireportsRouteGetGET /reports/routeFetch a list of Positions within the time period for the Devices or Groups
Traccar.DefaultApireportsStopsGetGET /reports/stopsFetch a list of ReportStops within the time period for the Devices or Groups
Traccar.DefaultApireportsSummaryGetGET /reports/summaryFetch a list of ReportSummary within the time period for the Devices or Groups
Traccar.DefaultApireportsTripsGetGET /reports/tripsFetch a list of ReportTrips within the time period for the Devices or Groups
Traccar.DefaultApiserverGetGET /serverFetch Server information
Traccar.DefaultApiserverPutPUT /serverUpdate Server information
Traccar.DefaultApisessionDeleteDELETE /sessionClose the Session
Traccar.DefaultApisessionGetGET /sessionFetch Session information
Traccar.DefaultApisessionPostPOST /sessionCreate a new Session
Traccar.DefaultApistatisticsGetGET /statisticsFetch server Statistics
Traccar.DefaultApiusersGetGET /usersFetch a list of Users
Traccar.DefaultApiusersIdDeleteDELETE /users/{id}Delete a User
Traccar.DefaultApiusersIdPutPUT /users/{id}Update a User
Traccar.DefaultApiusersPostPOST /usersCreate a User

Documentation for Models

Documentation for Authorization

basicAuth

  • Type: HTTP basic authentication