gutofoletto / mg-api-node

Unofficial nodejs client for the MyGeotab API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mg-api-node

Unofficial nodejs client for the MyGeotab API

Getting Started

$ npm install mg-api-node --save

Usage

var api = new API(userName, password, database);

api.authenticate(function(err, data) {

  if(err){
    console.log('Error', err);
    return;
  }

  api.call('Get', {
    typeName: 'User',
    search: {
      name: data.userName
    }
  }, function(err, data) {

    if(err){
      console.log('Error', err);
      return;
    }

    console.log('User', data);

  });

});

Session ID

It's also possible to supply session ID and direct server to re-use a session ID. This avoids costly authentication.

var api = new API(userName, password, database, server, options, sessionId);

api.call('Get', {
  typeName: 'User',
  resultsLimit: 1
}, function(err, data) {

  if(err){
    console.log('Error', err);
    return;
  }

  console.log('User', data);

});

Running Tests

$ npm install -g mocha
$ npm install
$ mocha

About

Unofficial nodejs client for the MyGeotab API

License:Apache License 2.0


Languages

Language:JavaScript 100.0%